Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

spl_event_mgr.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------- //
00002 //
00003 // MODULE  : spl_event_mgr.h
00004 //
00005 // PURPOSE : CSplEventMgr class - Definition
00006 //
00007 // CREATED : 04/07/01
00008 //
00009 // (c) 2001 LithTech, Inc.  All Rights Reserved
00010 //
00011 // ----------------------------------------------------------------------- //
00012 
00013 #ifndef __SPL_EVENT_MGR_H__
00014 #define __SPL_EVENT_MGR_H__
00015 
00016 #include "i_spl_event_mgr.h"
00017 
00018 const float FLOAT_EPSILON = 5e-6f;
00019 
00020 class CCallbackRecord
00021 {
00022 public:
00023     CCallbackRecord(IEventCallback* pEC, ECallbackType eCT, uint8 nCount,
00024         float fTime, uint8 nPriority, IEventData *pEventData) : m_pEC(pEC), m_eCT(eCT),
00025         m_nCountRemaining(nCount), m_fTimeRemaining(fTime),
00026         m_fLoopTime(fTime), m_nPriority(nPriority), m_pEventData(pEventData),
00027         m_pNext(NULL) {}
00028     
00029     CCallbackRecord() : m_pEC(NULL), m_eCT(CBT_INVALID),
00030         m_nCountRemaining(0), m_pEventData(NULL),
00031         m_fTimeRemaining(0.0f), m_fLoopTime(0.0f), m_nPriority(0),
00032         m_pNext(NULL) {}
00033 
00034     IEventCallback* m_pEC;
00035     ECallbackType   m_eCT;
00036     uint8           m_nCountRemaining;
00037     float           m_fTimeRemaining;
00038     float           m_fLoopTime;
00039     uint8           m_nPriority;
00040     IEventData*     m_pEventData;
00041     CCallbackRecord* m_pNext;
00042 };
00043 
00044 class CCallbackRequest
00045 {
00046 public:
00047     CCallbackRequest(IEventCallback* pEC, uint8 nEvent, uint8 nPriority,
00048         ECallbackType eCT, uint8 nCount, float fTime) :
00049     m_bAddRequest(true),
00050         m_pEC(pEC), m_eCT(eCT), m_nCount(nCount),
00051         m_nEvent(nEvent), m_nPriority(nPriority),
00052         m_fTime(fTime), m_pNext(NULL) {}
00053     
00054     CCallbackRequest(IEventCallback* pEC, uint8 nEvent, uint8 nPriority) :
00055     m_bAddRequest(false),
00056         m_pEC(pEC), m_eCT(CBT_INVALID), m_nCount(0),
00057         m_nEvent(nEvent), m_nPriority(nPriority),
00058         m_fTime(0.0f), m_pNext(NULL) {}
00059     
00060     CCallbackRequest() : m_pEC(NULL), m_eCT(CBT_INVALID), m_nCount(0),
00061         m_fTime(0.0f), m_nEvent(0), m_nPriority(0), m_pNext(NULL) {}
00062     
00063     bool            m_bAddRequest;
00064     IEventCallback* m_pEC;
00065     ECallbackType   m_eCT;
00066     uint8           m_nCount;
00067     float           m_fTime;
00068     uint8           m_nEvent;
00069     uint8           m_nPriority;
00070     CCallbackRequest* m_pNext;
00071 };
00072 
00073 class CEventClass
00074 {
00075 public:
00076 
00077     CEventClass(uint32 nEvent) : m_nEvent(nEvent),
00078         m_pCallbackHead(NULL), m_pNext(NULL) {}
00079 
00080 
00081     uint32          m_nEvent;
00082     CCallbackRecord* m_pCallbackHead;
00083     CEventClass*    m_pNext;
00084 };
00085 
00086 
00087 class CEventProcessingState
00088 {
00089 public:
00090     CEventProcessingState() : m_pPrevEvent(NULL), m_pCurEvent(NULL),
00091         m_pPrevCallbackRec(NULL), m_pCurCallbackRec(NULL),
00092         m_pNextCallbackRec(NULL) {}
00093 
00094     CEventClass     *m_pPrevEvent;
00095     CEventClass     *m_pCurEvent;
00096     CCallbackRecord *m_pPrevCallbackRec;
00097     CCallbackRecord *m_pCurCallbackRec;
00098     CCallbackRecord *m_pNextCallbackRec;
00099 };
00100 
00101 class CCallbackData
00102 {
00103 public:
00104     CCallbackData() : 
00105         m_nEvent(EVENTMGR_EVENT_ANY), m_fFrameTime(0.0f), m_fGameTime(0.0f),
00106         m_nPriority(EVENTMGR_PRIORITY_ANY), m_pEventData(NULL) {}
00107     uint8           m_nEvent;
00108     float           m_fFrameTime;
00109     float           m_fGameTime;
00110     IEventData      *m_pEventData;
00111     uint8           m_nPriority;
00112 };
00113 
00114 /*
00115 nEvent - list of uint32 registered priorities
00116 
00117 nPriority - list of IEventCallback*
00118 */
00119 
00120 class CSplEventMgr : public ISplEventMgr
00121 {
00122 public:
00123     CSplEventMgr();
00124     ~CSplEventMgr();
00125     
00126     
00127     declare_interface(CSplEventMgr);
00128     
00129     interface_version(CSplEventMgr, 0);
00130     
00131     virtual LTRESULT Event(uint8 nEvent, float fFrameTime, float fGameTime,
00132         IEventData *pEventData = NULL,
00133         uint8 nPriority = EVENTMGR_PRIORITY_ANY);
00134     
00135     virtual LTRESULT AddCallback(IEventCallback *pEC, uint8 nEvent,
00136                        ECallbackType eCT, uint8 nCount, float fTime,
00137                        uint8 nPriority = EVENTMGR_PRIORITY_DEFAULT);
00138     
00139     virtual LTRESULT RemoveCallback(IEventCallback *pEC,
00140         uint8 nEvent = EVENTMGR_EVENT_ANY,
00141         uint8 nPriority = EVENTMGR_PRIORITY_ANY);
00142     
00143     virtual LTRESULT GetCallbackInfo(IEventCallback *pEC, uint8 nEvent,
00144         uint8 nPriority, ECallbackType &eCT, uint8 &nCountRemaining,
00145         float &fLoopTime, float &fTimeRemaining);
00146     
00147     virtual void DumpData(printf_fn pPrintfFn);
00148     
00149     virtual void DebugSpew(printf_fn pPrintfFn);
00150     
00151 private:
00152     
00153     LTRESULT    EventTopLoop(CEventProcessingState *pState,
00154                     CCallbackData *pData);
00155     LTRESULT    EventLoop(CEventProcessingState *pState,
00156                     CCallbackData *pData);
00157 
00158     LTRESULT    EventCallbackLoop(CEventProcessingState *pState,
00159                     CCallbackData *pData);
00160     LTRESULT    Callback(CEventProcessingState *pState,
00161                     CCallbackData *pData);
00162     LTRESULT    RetireCallback(CEventProcessingState *pState);
00163 
00164     void        ProcessRequests();
00165     
00166     void        InsertCallback(CEventClass *&pEvent, uint8 nEvent,
00167                     CCallbackRecord *pNewCallback);
00168     void        InsertCallback(CEventClass *pEvent, 
00169                     CCallbackRecord *pNewCallback);
00170     void        InsertCallback(CCallbackRecord *pAfterThis,
00171                     CCallbackRecord *pNewCallback);
00172     void        InsertHead(CEventClass *pEvent, 
00173                     CCallbackRecord *pNewCallback);
00174 
00175     LTRESULT    DeleteCallback(CEventClass *&pEvent, uint8 nEvent,
00176                     CCallbackRequest *pDeleteRequest);
00177     LTRESULT    DeleteCallback(CEventClass *pEvent,
00178                     CCallbackRequest *pDeleteRequest);
00179     void        DeleteCallback(CCallbackRecord *pAfterThis);
00180     void        DeleteHead(CEventClass *pEvent);
00181     
00182     void        DeleteEvent(CEventClass *pAfterThis);
00183     void        DeleteHeadEvent(CEventClass *&pEventHead);
00184 
00185     void        DumpRecord(printf_fn pPrintfFn, CCallbackRecord &cbRec);
00186     
00187     printf_fn           m_pPrintfFn;
00188 
00189     CEventClass         *m_pEventList;
00190     CCallbackRequest    *m_pCBRequestList;
00191     
00192     bool                m_bProcessingEvent;
00193     
00194 };
00195 
00196 #endif // __SPL_EVENT_MGR_H__

Generated on Mon Mar 4 08:42:23 2002 for Aria by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002