You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6 KiB

7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
7 years ago
7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
  1. #ifndef __BASICEVENTHEAP_H_INCL__
  2. #define __BASICEVENTHEAP_H_INCL__
  3. #include "basicLogCollection.h"
  4. #include "basicMutex.h"
  5. #include "basicThread.h"
  6. #include "basicEvent.h"
  7. #include "basicEventHandler.h"
  8. typedef std::vector< basicEventHandler *> V_EVT_HANDLER;
  9. /**
  10. * @Description Singleton class to manage Events in the System
  11. *
  12. * @author Gagua
  13. */
  14. class basicEventHeap: public basicThread{
  15. private:
  16. basicLogCollection *m_pLog;
  17. basicMutex *m_pDispatchingMutex;
  18. basicMutex *m_pHandlerMutex;
  19. //EventHandlerRing *m_pRing;
  20. V_EVT_HANDLER m_vHandlers;
  21. pEventQueue m_vEventQueue;
  22. public:
  23. static basicEventHeap* getInstance();
  24. virtual ~basicEventHeap();
  25. void addHandler( basicEventHandler *handler, bool atBottom = false );
  26. void removeHandler( basicEventHandler *handler );
  27. void broadcast( EVENT_CONTAINER *Evt );
  28. protected:
  29. basicEventHeap();
  30. void m_fThreadProc( void );
  31. private:
  32. static basicEventHeap* _instance;
  33. };
  34. // Constructor implementation
  35. inline basicEventHeap::basicEventHeap(){
  36. m_pLog = basicLogCollection::getInstance();
  37. //m_pRing = new EventHandlerRing();
  38. m_pDispatchingMutex = new basicMutex();
  39. m_pHandlerMutex = new basicMutex();
  40. basicThread::init();
  41. };
  42. // Destructor implementation
  43. inline basicEventHeap::~basicEventHeap(){
  44. waitThreadEnd( true );
  45. m_vHandlers.clear();
  46. //while (m_pRing->count) m_pRing->pop();
  47. //delete( m_pRing );
  48. delete( m_pDispatchingMutex );
  49. delete( m_pHandlerMutex );
  50. };
  51. #endif // __BASICEVENTHEAP_H_INCL__