#ifndef __BASICEVENTHEAP_H_INCL__ #define __BASICEVENTHEAP_H_INCL__ #include "basicLogCollection.h" #include "basicMutex.h" #include "basicThread.h" #include "basicEvent.h" #include "basicEventHandler.h" typedef std::vector< basicEventHandler *> V_EVT_HANDLER; /** * @Description Singleton class to manage Events in the System * * @author Gagua */ class basicEventHeap: public basicThread{ private: basicLogCollection *m_pLog; basicMutex *m_pDispatchingMutex; basicMutex *m_pHandlerMutex; //EventHandlerRing *m_pRing; V_EVT_HANDLER m_vHandlers; pEventQueue m_vEventQueue; public: static basicEventHeap* getInstance(); virtual ~basicEventHeap(); void addHandler( basicEventHandler *handler, bool atBottom = false ); void removeHandler( basicEventHandler *handler ); void broadcast( EVENT_CONTAINER *Evt ); protected: basicEventHeap(); void m_fThreadProc( void ); private: static basicEventHeap* _instance; }; // Constructor implementation inline basicEventHeap::basicEventHeap(){ m_pLog = basicLogCollection::getInstance(); //m_pRing = new EventHandlerRing(); m_pDispatchingMutex = new basicMutex(); m_pHandlerMutex = new basicMutex(); basicThread::init(); }; // Destructor implementation inline basicEventHeap::~basicEventHeap(){ waitThreadEnd( true ); m_vHandlers.clear(); //while (m_pRing->count) m_pRing->pop(); //delete( m_pRing ); delete( m_pDispatchingMutex ); delete( m_pHandlerMutex ); }; #endif // __BASICEVENTHEAP_H_INCL__