msglist.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:2k
- #ifndef _ASIDER_TANK_ALPHA3_MSGLIST_H_
- #define _ASIDER_TANK_ALPHA3_MSGLIST_H_
- #define MAXLIST 256
- #define INCSTEP 32
- //-----------------------------------------------------------------------------
- // Classes defined in this header file
- //-----------------------------------------------------------------------------
- class CMsgElem;
- class CMsgList;
- //-----------------------------------------------------------------------------
- // Name: class CMsgList
- // Desc: Class to handle messages using List structrue
- //-----------------------------------------------------------------------------
- class CMsgList
- {
- CMsgElem **m_ppElems;
- int m_nSize;
- int m_nHead;
- int m_nTail;
- int m_nTotal;
- int m_nMax;
- bool m_bSync;
-
- public:
- CMsgList();
- ~CMsgList();
- // Access functions
- void Lock();
- void UnLock();
- int GetSize() { return m_nSize; }
- int GetRemain() { return m_nTotal; }
- void SetMax( int max ) { m_nMax = max; }
- // Status functions
- bool IsSync() { return m_bSync; }
- bool IsFull() { return m_nTotal == m_nSize; }
- bool IsEmpty() { return m_nTotal == 0; }
- bool NotInit() { return m_ppElems == NULL; }
-
- // Creation/destruction methods
- bool CreatMsgList( unsigned int size, bool sync );
- void DestroyList();
-
- // List methods
- CMsgElem *Peek();
- CMsgElem *Pop();
- bool Push( const CMsgElem *pelem );
- bool EnlargeSize();
- };
- //-----------------------------------------------------------------------------
- // Name: class CMsgElem
- // Desc: Class to store a message's infomations
- //-----------------------------------------------------------------------------
- class CMsgElem
- {
- friend class CMsgList;
- protected:
- int m_nMsg;
- DWORD m_dwMsgType;
-
- char *m_psBuffer;
- int m_nParamSize;
- public:
- CMsgElem();
- ~CMsgElem();
- // Access functions
- int GetMsg() { return m_nMsg; }
- DWORD GetMsgType() { return m_dwMsgType; }
- int GetParamSize() { return m_nParamSize; }
- LPCSTR GetParam() { return m_psBuffer; }
- // Status functions
- bool IsParamAvailable() { return m_nParamSize>0; }
- // Creation/destruction methods
- bool CreateMsgElem( int msg, LPCSTR param,int size, DWORD type );
- bool CreateMsgElemFromBuf( LPCSTR buf, int &size, DWORD type );
- // Methods
- };
- #endif //_ASIDER_TANK_ALPHA3_MSGLIST_H_