Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Registration
- {
- public:
- void callback(void)
- {
- callback_();
- }
- void setCallback ((*callback)(void));
- void addToEventSystem(int ID,EventSystem &eventSystem);
- private:
- void (*callback_)(void);
- };
- class EventSystem
- {
- public:
- void register(int ID, Registration* registration);
- void unRegister(int ID, Registration* registration);
- void addNotificationToQueue(int ID);
- void addNotificationToSchedule(int ID, int NotificationTime);
- void processQueuedNotifications(void);
- void processNextScheduled(void);
- int getCurrentTime(void);
- private:
- //placeholder types
- <list> notificationQueue;
- <binaryheap> notificationSchegule;
- };
- class ReceiverObject
- {
- public:
- void doStuff(void);
- void initialize(void)
- {
- keyPressRegistration.setCallback(doStuff);
- //multiple registrations with different ID:s to same eventsystem possible
- keyPressRegistration.addToEventSystem(1234,eventSystem);
- keyPressRegistration.addToEventSystem(42,eventSystem);
- }
- private:
- Registration keyPressRegistration;
- };
- int main ()
- {
- ReceiverObject receiverObject;
- EventSystem eventSystem;
- receiverObject.initialize();
- eventSystem.addNotificationToQueue(1234);
- eventSystem.processQueuedNotifications();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement