Refactor notification service abstraction

- Removed observer map from Subject base class
- Removed notify() from Subject interface
- Made NotificationManagementService abstract with pure virtual methods
- Added static observer maps to notification service implementations
- Added attach() and detach() overrides in inventory, payment, and service management services
- Added update() override in User model for observer pattern support
- Updated notification method declarations with override specifiers
This commit is contained in:
2026-05-19 19:39:55 +05:30
parent 007927bf34
commit 56c5c2dc70
7 changed files with 21 additions and 10 deletions
@@ -10,6 +10,7 @@ class InventoryManagementService : public NotificationManagementService
{
private:
DataStore& m_dataStore;
static util::Map<std::string, User*> m_observers;
public:
InventoryManagementService() : m_dataStore(DataStore::getInstance()) {}
util::Map<std::string, InventoryItem*> getInventoryItems();
@@ -17,5 +18,7 @@ public:
void addInventoryItem(const std::string& partName, int quantity, double price);
void removeInventoryItem(const std::string& inventoryItemID);
void sendLowStockAlerts();
void sendNotification(User* user, const std::string& title, const std::string& message);
void sendNotification(User* user, const std::string& title, const std::string& message) override;
void attach(User* user) override;
void detach(User* user) override;
};