Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
// "program": "${workspaceFolder}/build/debug/bin/cpp_lab_project", // path to the executable
"program": "${workspaceFolder}/build/debug/bin/mvc_ap", // path to the executable
"program": "${workspaceFolder}/build/debug/bin/cpp_lab_project", // path to the executable
// "program": "${workspaceFolder}/build/debug/bin/mvc_ap", // path to the executable
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}", // working directory
Expand Down
12 changes: 0 additions & 12 deletions scripts/gen_coverage_gcovr.sh
Original file line number Diff line number Diff line change
@@ -1,37 +1,27 @@
#!/usr/bin/env bash
set -e

# -----------------------------------------------------------------------------
# Check gcovr installation
# -----------------------------------------------------------------------------
if ! command -v gcovr >/dev/null 2>&1; then
echo "Error: gcovr is not installed."
echo "Install with: pip install gcovr or sudo apt install gcovr or sudo apt install python3-gcovr"
exit 1
fi

# -----------------------------------------------------------------------------
# Configure project (only if build folder does not exist)
# -----------------------------------------------------------------------------
if [ ! -d build ]; then
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -O0 -g"
fi

# -----------------------------------------------------------------------------
# Build project
# -----------------------------------------------------------------------------
cmake --build build

# -----------------------------------------------------------------------------
# Run unit tests
# -----------------------------------------------------------------------------
ctest --test-dir build --output-on-failure

# -----------------------------------------------------------------------------
# Generate coverage report
# -----------------------------------------------------------------------------
mkdir -p coverage_gcovr

gcovr -r . build \
Expand All @@ -40,7 +30,5 @@ gcovr -r . build \
--html-details \
-o coverage_gcovr/index.html

# -----------------------------------------------------------------------------
# Open coverage report
# -----------------------------------------------------------------------------
xdg-open coverage_gcovr/index.html
16 changes: 0 additions & 16 deletions scripts/gen_coverage_lcov.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,30 @@
#!/usr/bin/env bash
set -e

# -----------------------------------------------------------------------------
# Check lcov installation
# -----------------------------------------------------------------------------
if ! command -v lcov >/dev/null 2>&1; then
echo "Error: lcov is not installed."
echo "Install with: sudo apt install lcov"
exit 1
fi

# -----------------------------------------------------------------------------
# Configure project (only if build folder does not exist)
# -----------------------------------------------------------------------------
if [ ! -d build ]; then
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -O0 -g"
fi

# -----------------------------------------------------------------------------
# Build project
# -----------------------------------------------------------------------------
cmake --build build

# -----------------------------------------------------------------------------
# Reset previous coverage
# -----------------------------------------------------------------------------
lcov --directory build --zerocounters

# -----------------------------------------------------------------------------
# Run unit tests
# -----------------------------------------------------------------------------
ctest --test-dir build --output-on-failure

# -----------------------------------------------------------------------------
# Capture coverage
# -----------------------------------------------------------------------------
mkdir -p coverage_lcov

lcov --capture \
Expand All @@ -49,13 +37,9 @@ lcov --capture \
lcov --remove coverage_lcov/coverage.info '/usr/*' \
--output-file coverage_lcov/coverage.info

# -----------------------------------------------------------------------------
# Generate HTML report
# -----------------------------------------------------------------------------
genhtml coverage_lcov/coverage.info \
--output-directory coverage_lcov

# -----------------------------------------------------------------------------
# Open coverage report
# -----------------------------------------------------------------------------
xdg-open coverage_lcov/index.html
11 changes: 0 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ add_subdirectory(core)
add_subdirectory(controller)
add_subdirectory(dp)
add_subdirectory(socket)
add_subdirectory(exercise)
add_subdirectory(ap)

# main application executable does NOT link to this library.
Expand All @@ -26,24 +25,14 @@ add_executable(${PROJECT_NAME}
${SOCKET_SOURCES}
${CONTROLLER_SOURCES}
${DP_SOURCES}
${EXCERCISE_SOURCES}
)

# Add header include paths
# PRIVATE -> this target only
# PUBLIC -> this target + dependent targets
# INTERFACE -> dependent targets only
target_include_directories(${PROJECT_NAME}
PRIVATE ${APP_HEADERS}
)

# Optional: add project-specific compiler options
target_compile_options(${PROJECT_NAME}
PRIVATE -Wall -Wextra -Wpedantic
)

target_link_libraries(${PROJECT_NAME}
PRIVATE
ex_account
ex_student_manager
)
1 change: 0 additions & 1 deletion src/ap/mvc/model/SharedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class SharedData {
private:
void notifyObservers();

private:
std::string data_;
std::vector<IObserver*> observers_;
};
1 change: 0 additions & 1 deletion src/ap/mvc/view/DisplayWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class DisplayWidget : public Gtk::Box, public IObserver {
private:
void updateLabel(const std::string& text);

private:
std::string color_;
Gtk::Frame frame_;
Gtk::Box innerBox_;
Expand Down
96 changes: 48 additions & 48 deletions src/ap/simple_ap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,94 +6,94 @@
class MainWindow : public Gtk::Window {

// --- Layout Containers ---
Gtk::Box m_mainLayout;
Gtk::Box m_topRowLayout;
Gtk::Box m_mainLayout_;
Gtk::Box m_topRowLayout_;

// --- Widgets ---
// We must declare everything here so that the buttons are accessible

// Editor
Gtk::Frame frame_Editor;
Gtk::Box m_boxEditor;
Gtk::Entry entry_Input;
Gtk::Button button_Update;
Gtk::Frame frame_Editor_;
Gtk::Box m_boxEditor_;
Gtk::Entry entry_Input_;
Gtk::Button button_Update_;

// Monitor A
Gtk::Frame frame_MonitorA;
Gtk::Box m_boxMonitorA;
Gtk::Label m_labelMonitorA;
Gtk::Frame frame_MonitorA_;
Gtk::Box m_boxMonitorA_;
Gtk::Label m_labelMonitorA_;

// Monitor B
Gtk::Frame frame_MonitorB;
Gtk::Box m_boxMonitorB;
Gtk::Label m_labelMonitorB;
Gtk::Frame frame_MonitorB_;
Gtk::Box m_boxMonitorB_;
Gtk::Label m_labelMonitorB_;

public:
MainWindow()
: m_mainLayout(Gtk::Orientation::VERTICAL),
m_topRowLayout(Gtk::Orientation::HORIZONTAL),
m_boxEditor(Gtk::Orientation::VERTICAL),
m_boxMonitorA(Gtk::Orientation::VERTICAL),
m_boxMonitorB(Gtk::Orientation::VERTICAL) {
: m_mainLayout_(Gtk::Orientation::VERTICAL),
m_topRowLayout_(Gtk::Orientation::HORIZONTAL),
m_boxEditor_(Gtk::Orientation::VERTICAL),
m_boxMonitorA_(Gtk::Orientation::VERTICAL),
m_boxMonitorB_(Gtk::Orientation::VERTICAL) {
set_title("No-MVC (Coupled) Demo");
set_default_size(600, 400);

// 1. SETUP UI (Visually identical to MVC)
// --- Monitor A ---
frame_MonitorA.set_label("ZONE 2: MONITOR A (Blue)");
m_labelMonitorA.set_markup(
frame_MonitorA_.set_label("ZONE 2: MONITOR A (Blue)");
m_labelMonitorA_.set_markup(
"<span foreground='blue' size='x-large'>Initial Data</span>");
m_boxMonitorA.append(m_labelMonitorA);
frame_MonitorA.set_child(m_boxMonitorA);
frame_MonitorA.set_hexpand(true); // Stretch
m_boxMonitorA_.append(m_labelMonitorA_);
frame_MonitorA_.set_child(m_boxMonitorA_);
frame_MonitorA_.set_hexpand(true); // Stretch

// --- Monitor B ---
frame_MonitorB.set_label("ZONE 3: MONITOR B (Red)");
m_labelMonitorB.set_markup(
frame_MonitorB_.set_label("ZONE 3: MONITOR B (Red)");
m_labelMonitorB_.set_markup(
"<span foreground='red' size='x-large'>Initial Data</span>");
m_boxMonitorB.append(m_labelMonitorB);
frame_MonitorB.set_child(m_boxMonitorB);
frame_MonitorB.set_hexpand(true);
m_boxMonitorB_.append(m_labelMonitorB_);
frame_MonitorB_.set_child(m_boxMonitorB_);
frame_MonitorB_.set_hexpand(true);

// --- Editor ---
frame_Editor.set_label("ZONE 1: EDITOR");
entry_Input.set_text("Initial Data");
button_Update.set_label("Direct Update"); // Live updates
m_boxEditor.append(entry_Input);
m_boxEditor.append(button_Update);
frame_Editor.set_child(m_boxEditor);
frame_Editor_.set_label("ZONE 1: EDITOR");
entry_Input_.set_text("Initial Data");
button_Update_.set_label("Direct Update"); // Live updates
m_boxEditor_.append(entry_Input_);
m_boxEditor_.append(button_Update_);
frame_Editor_.set_child(m_boxEditor_);

// --- Layout ---
m_topRowLayout.append(frame_MonitorA);
m_topRowLayout.append(frame_MonitorB);
m_mainLayout.append(m_topRowLayout);
m_mainLayout.append(frame_Editor);
m_topRowLayout_.append(frame_MonitorA_);
m_topRowLayout_.append(frame_MonitorB_);
m_mainLayout_.append(m_topRowLayout_);
m_mainLayout_.append(frame_Editor_);

// Margin for aesthetics
m_boxEditor.set_margin(10);
m_boxEditor.set_spacing(5);
m_boxMonitorA.set_margin(20);
m_boxMonitorB.set_margin(20);
set_child(m_mainLayout);
m_boxEditor_.set_margin(10);
m_boxEditor_.set_spacing(5);
m_boxMonitorA_.set_margin(20);
m_boxMonitorB_.set_margin(20);
set_child(m_mainLayout_);

// 2. LOGIC HANDLING
// Here, the button must "know" exactly who m_labelMonitorA and m_labelMonitorB are.
// It directly controls the other widgets.
// (THE BAD PART)
button_Update.signal_clicked().connect([this]() {
button_Update_.signal_clicked().connect([this]() {
// Step 1: Get data directly from UI (Entry)
std::string text = entry_Input.get_text();
std::string text = entry_Input_.get_text();
// There may be processing logic here (Validating...)
if (text.empty())
return;

// Step 2: Update Monitor A (Hard-coded) directly
m_labelMonitorA.set_markup("<span foreground='blue' size='x-large'>" +
text + "</span>");
m_labelMonitorA_.set_markup("<span foreground='blue' size='x-large'>" +
text + "</span>");

// Step 3: Update Monitor B (Hard-coded) directly
m_labelMonitorB.set_markup("<span foreground='red' size='x-large'>" +
text + "</span>");
m_labelMonitorB_.set_markup("<span foreground='red' size='x-large'>" +
text + "</span>");
std::cout << "Updated directly without Model!" << std::endl;
});
}
Expand Down
Loading
Loading