SignalEvent.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef SIGNALEVENT_H
  2. #define SIGNALEVENT_H
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <string>
  6. #include <vector>
  7. #include <map>
  8. #include <ctime>
  9. #include <functional>
  10. using namespace std;
  11. /*
  12. SignalEvent carries data and the name of the emitted event from the SignalBus to be parsed and can be extended by any other class
  13. This is used to share states dynamically in the observer pattern
  14. */
  15. class SignalEvent{
  16. public:
  17. //creates signal event with the event name
  18. SignalEvent(string n);
  19. ~SignalEvent();
  20. //get event name
  21. string getEventName() const;
  22. //creates a copy of the signal event
  23. virtual SignalEvent* clone() = 0;
  24. protected:
  25. SignalEvent();
  26. string name;
  27. };
  28. /*
  29. Default Event that can be used to send signals that do not need to carry additional data
  30. */
  31. class SignalDefaultEvent: public SignalEvent{
  32. public:
  33. //creates the event object
  34. SignalDefaultEvent(string n);
  35. //copy constructor
  36. SignalDefaultEvent(SignalDefaultEvent& other);
  37. ~SignalDefaultEvent();
  38. //clone the signal event
  39. SignalEvent* clone();
  40. time_t callTime; //records the step time it gets called
  41. int callCount; //records the amount of times the event was called
  42. };
  43. #endif