My Sweet Home (MSH) is a smart home management system that controls IoT devices through a screen panel interface. The system demonstrates the implementation of various design patterns in C++98.
| Pattern | Implementation | Description |
|---|---|---|
| Singleton | Alarm, Storage |
Single instance devices |
| Factory Method | SimpleDeviceFactory |
Creates devices by type |
| Abstract Factory | DeviceFactory, DetectorFactory |
Creates device families |
| Prototype | Device::clone() |
Clone devices with configuration |
| State | ModeState, SystemState |
Mode and system states |
| Memento | HomeMemento, StateManager |
State history and undo |
| Observer | IDeviceObserver, NotificationSystem |
Device failure notifications |
| Strategy | NotificationStrategy |
Different notification methods |
| Chain of Responsibility | SecurityHandler, DetectionHandler |
Security/detection sequences |
| Template Method | Device::powerOn(), Device::powerOff() |
Device operations |
| Facade | HomeController |
Simplified system interface |
MySweetHome/
├── CMakeLists.txt
├── include/
│ ├── Alarm.h
│ ├── AlarmHandler.h
│ ├── Camera.h
│ ├── DetectionSystem.h
│ ├── Detector.h
│ ├── Device.h
│ ├── DeviceFactory.h
│ ├── GasDetector.h
│ ├── HomeController.h
│ ├── Light.h
│ ├── LightHandler.h
│ ├── Menu.h
│ ├── ModeManager.h
│ ├── NotificationSystem.h
│ ├── PoliceHandler.h
│ ├── SecurityHandler.h
│ ├── SecuritySystem.h
│ ├── SmokeDetector.h
│ ├── SoundSystem.h
│ ├── StateManager.h
│ ├── Storage.h
│ ├── Television.h
│ └── nlohmann/
│ └── json.hpp
├── src/
│ ├── Alarm.cpp
│ ├── AlarmHandler.cpp
│ ├── Camera.cpp
│ ├── Detector.cpp
│ ├── Device.cpp
│ ├── DeviceFactory.cpp
│ ├── GasDetector.cpp
│ ├── HomeController.cpp
│ ├── Light.cpp
│ ├── LightHandler.cpp
│ ├── main.cpp
│ ├── Menu.cpp
│ ├── ModeManager.cpp
│ ├── NotificationSystem.cpp
│ ├── PoliceHandler.cpp
│ ├── SecurityHandler.cpp
│ ├── SecuritySystem.cpp
│ ├── SmokeDetector.cpp
│ ├── SoundSystem.cpp
│ ├── StateManager.cpp
│ ├── Storage.cpp
│ └── Television.cpp
└── tests/
├── CMakeLists.txt
└── test_main.cpp
- CMake 3.10 or higher
- C++ Compiler supporting C++98 (e.g., g++, clang)
# Create build directory
mkdir build && cd build
# Configure project
cmake ..
# Build application and tests
make./bin/mshThis project uses CTest for unit testing.
# Run all tests
ctest --output-on-failure
# Alternatively, run the test executable directly
./tests/unit_tests
# Run Sequence Verification Test (Security & Detection)
./tests/manual_sequence_testA modern, web-based interface is available to interact with the C++ system in real-time.
- Live Terminal: Interact with the
mshC++ application via a web browser. - Multi-User Support: Each user gets an isolated session with their own process and filesystem workspace.
- Auto-Cleanup: Sessions are automatically destroyed after 5 minutes of inactivity or upon disconnection.
- Responsive UI: Dark/Light mode support, adjustable font sizes, and mobile-friendly layout.
- Secure: Input validation and process isolation.
The easiest way to run the web interface is using the provided Dockerfile.
# Build the image
docker build -t msh-smart-home .
# Run the container (Access at http://localhost:3000)
docker run -p 3000:3000 -it msh-smart-home# Navigate to web directory
cd web
# Install dependencies
npm install
# Start the server
node server.jsThen open http://localhost:3000 in your browser.
Device (Abstract Base)
├── Light
│ ├── PhilipsHueLight
│ └── IKEATradfriLight
├── Camera
│ ├── SamsungCamera
│ └── XiaomiCamera
├── Television
│ ├── SamsungTV
│ └── LGTV
├── Detector (Cannot be powered off)
│ ├── SmokeDetector
│ │ ├── NestSmokeDetector
│ │ └── FirstAlertSmokeDetector
│ └── GasDetector
│ ├── NestGasDetector
│ └── KiddeGasDetector
├── SoundSystem
│ ├── SonosSoundSystem
│ └── BoseSoundSystem
└── Alarm (Singleton, cannot be powered off)
| Mode | Light | TV | Music |
|---|---|---|---|
| Normal | ON | OFF | OFF |
| Evening | OFF | OFF | OFF |
| Party | ON | OFF | ON |
| Cinema | OFF | ON | OFF |
- Normal: Standard operation - all features available
- High Performance: Maximum performance - increased resource usage
- Low Power: Energy saving mode - reduced functionality
- Sleep: Minimal operation - only critical systems active
When motion is detected (and security is active):
- Alarm triggers (3 seconds)
- Lights turn on (2 seconds)
- Police called
When smoke/gas is detected:
- Alarm triggers (3 seconds) - can be interrupted by user
- Lights blink on/off (5 times) - can be interrupted by user
- Fire Station called
| HLR | Description | Implementation |
|---|---|---|
| REQ1 | Operation menu | Menu class |
| REQ2 | Manual display | Menu::displayManual() |
| REQ3 | Keyboard interaction | Menu::getMenuChoice() |
| REQ4 | Persistent logging | Storage class (Singleton) |
| REQ5 | Device types | Light, Detector, Camera, Television |
| REQ6 | Power on/off | Device::powerOn(), Device::powerOff() |
| REQ7 | Modes | ModeManager, ModeState classes |
| REQ8 | Add/remove devices | HomeController device management |
| REQ9 | Failure notifications | NotificationSystem, IDeviceObserver |
| REQ10 | Configuration copy | Device::copyConfigurationFrom(), Prototype pattern |
| REQ11 | State history | StateManager, HomeMemento (Memento pattern) |
| REQ12 | State restore | StateManager::restorePreviousState() |
| REQ13 | Security sequence | SecuritySystem, Chain of Responsibility |
| REQ14 | Detection alarm | DetectionSystem |
| REQ15 | Light blinking | DetectionBlinkHandler |
| REQ16 | Fire station call | FireStationCallHandler |
MY SWEET HOME (MSH)
[1] Get Home Status
[2] Add Device
[3] Remove Device
[4] Power On Device
[5] Power Off Device
[6] Change Mode
[7] Change State
[8] Manual
[9] About
[10] Shutdown
- Integrator: Anıl Akpınar - Integration & Build System
- Developer 1: Ömer Faruk Çakmak - Device Core & Factories
- Developer 2: Mehmet Efe Ergin - Actuators & Prototype
- Developer 3: Zeynep Bilge Tuğ - Detectors & Alarm
- Developer 4: Hüseyin Saçıkay - Storage & Menu
- Developer 5: Yusuf Berk Baytok - Mode System
- Developer 6: Yunis Ibrahimov - State History
- Developer 7: Burak Yıldırım - Security System
- Developer 8: Dünyamalı Goyushlu - Detection System
- Course: CENG-464 Design Patterns with C++
- Instructor: Murat Yilmaz
- University: OSTIM Technical University
- Date: 2025
This project is developed for educational purposes as part of the CENG-464 course.