-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bf6f0af
commit 1335f27
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef EVENTS_HPP | ||
#define EVENTS_HPP | ||
|
||
#include <vector> | ||
|
||
namespace event { | ||
|
||
// Base event class | ||
class Event { | ||
public: | ||
virtual ~Event() = default; | ||
}; | ||
|
||
// Device announcement event | ||
class DeviceAnnouncementEvent : public Event { | ||
Device& device; | ||
|
||
public: | ||
explicit DeviceAnnouncementEvent(Device& device) : device(device) {} | ||
|
||
[[nodiscard]] Device& get_device() const { return device; } | ||
}; | ||
|
||
// Reporting event | ||
class ReportingEvent : public Event { | ||
}; | ||
|
||
// Event handler interface | ||
class IEventHandler { | ||
public: | ||
virtual void handleEvent(const Event& event) = 0; | ||
virtual ~IEventHandler() = default; | ||
}; | ||
|
||
// Zigbee device mocker | ||
class ZigbeeDeviceMocker { | ||
private: | ||
std::vector<IEventHandler*> eventHandlers; // Event handler interface pointers | ||
|
||
public: | ||
// Register an event handler | ||
void registerEventHandler(IEventHandler* handler) { | ||
eventHandlers.push_back(handler); | ||
} | ||
|
||
// Emit an event and notify all registered event handlers | ||
void emitEvent(const Event& event) { | ||
for (auto handler : eventHandlers) { | ||
handler->handleEvent(event); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace event | ||
|
||
#endif // EVENTS_HPP |