Advertisement
Guest User

Heyta neponiatnaia

a guest
Jan 17th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. class Registration
  2. {
  3. public:
  4.     void callback(void)
  5.     {
  6.         callback_();
  7.     }
  8.     void setCallback ((*callback)(void));
  9.     void addToEventSystem(int ID,EventSystem &eventSystem);
  10.  
  11. private:
  12.     void (*callback_)(void);
  13. };
  14.  
  15.  
  16.  
  17. class EventSystem
  18. {
  19. public:
  20.     void register(int ID, Registration* registration);
  21.     void unRegister(int ID, Registration* registration);
  22.     void addNotificationToQueue(int ID);
  23.     void addNotificationToSchedule(int ID, int NotificationTime);
  24.     void processQueuedNotifications(void);
  25.     void processNextScheduled(void);
  26.     int getCurrentTime(void);
  27.  
  28. private:
  29.     //placeholder types
  30.     <list> notificationQueue;
  31.     <binaryheap> notificationSchegule;
  32. };
  33.  
  34. class ReceiverObject
  35. {
  36. public:
  37.     void doStuff(void);
  38.     void initialize(void)
  39.     {
  40.         keyPressRegistration.setCallback(doStuff);
  41.         //multiple registrations with different ID:s to same eventsystem possible
  42.         keyPressRegistration.addToEventSystem(1234,eventSystem);
  43.         keyPressRegistration.addToEventSystem(42,eventSystem);
  44.     }
  45.  
  46. private:
  47.     Registration keyPressRegistration;
  48. };
  49. int main ()
  50. {
  51.    ReceiverObject receiverObject;
  52.    EventSystem eventSystem;
  53.    receiverObject.initialize();
  54.    eventSystem.addNotificationToQueue(1234);
  55.    eventSystem.processQueuedNotifications();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement