#ifndef __BASICEVENTHEAP_H_INCL__ #define __BASICEVENTHEAP_H_INCL__ #include "basicLogCollection.h" #include "basicMutex.h" #include "basicThread.h" #include "basicEvent.h" #include "basicEventHandler.h" /** * @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; pEventQueue m_vEventQueue; public: // Method to fetch singleton instance. static basicEventHeap* getInstance(); // Destructor virtual ~basicEventHeap(); void addHandler( basicEventHandler *handler ); void removeHandler(basicEventHandler *handler); void broadcast( basicEvent *Evt ); protected: // Constructor - protected so users cannot call it. basicEventHeap(); void m_fThreadProc( void ); private: // private static member referencing the single instance of the object // TODO: Replace basicEventHeap with the type of object you want to // return the single instance of static basicEventHeap* _instance; // Copy constructor // Declared but not defined to prevent auto-generated // copy constructor. Refer to "Effective C++" by Meyers //basicEventHeap(const basicEventHeap& src); // Assignment operator // Declared but not defined to prevent auto-generated // assignment operator. Refer to "Effective C++" by Meyers //basicEventHeap& operator=(const basicEventHeap& src); }; // 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(){ while (m_pRing->count) m_pRing->pop(); delete( m_pRing ); delete( m_pDispatchingMutex ); delete( m_pHandlerMutex ); }; // TODO: Uncomment the copy constructor when you need it. //inline basicEventHeap::basicEventHeap(const basicEventHeap& src) //{ // // TODO: copy //} // TODO: Uncomment the assignment operator when you need it. //inline basicEventHeap& basicEventHeap::operator=(const basicEventHeap& rhs) //{ // if (this == &rhs) { // return *this; // } // // // TODO: assignment // // return *this; //} #endif // __BASICEVENTHEAP_H_INCL__