00001 /* 00002 * EvtQueue.h 00003 * 00004 * Copyright 2003, MobileSpear Inc. (www.mobilespear.com). All rights reserved. 00005 * Copyright 2003, David Resnick. All rights reserved. 00006 * 00007 * See the file doc\license.txt for the terms of usage and distribution. 00008 */ 00009 00010 #ifndef _BOGOTEL_EVTQUEUE_H 00011 #define _BOGOTEL_EVTQUEUE_H 00012 00013 #include <boost/thread/mutex.hpp> 00014 #include <boost/thread/condition.hpp> 00015 #include <boost/thread/thread.hpp> 00016 00017 #include <deque> 00018 00019 namespace bogotel { 00020 00021 class CEvt 00022 { 00023 public: 00024 00025 CEvt() : 00026 m_pUsrAttr(NULL), 00027 m_lVoiceDevHandle(0), 00028 m_lSignalDevHandle(0), 00029 m_lType(0), 00030 m_lLen(0), 00031 m_lCrn(0), 00032 m_ulFlags(0), 00033 m_iSysType(0) 00034 {} 00035 00036 void* m_pUsrAttr; 00037 long m_lVoiceDevHandle; 00038 long m_lSignalDevHandle; 00039 long m_lType; 00040 long m_lLen; 00041 long m_lCrn; 00042 unsigned long m_ulFlags; 00043 int m_iSysType; 00044 00045 const std::string& toString(); 00046 00047 enum SysType { 00048 DEVICE = 0, 00049 DISABLE_HANDLER = 1 00050 }; 00051 00052 private: 00053 static const char *s_TypePlay; 00054 static const char *s_TypeGetDig; 00055 static const char *s_TypeError; 00056 static const char *s_TypeDial; 00057 static const char *s_TypeUnknown; 00058 }; 00059 00060 typedef std::deque<CEvt *> DEQUE_EVT; 00061 00062 class CEvtQueue 00063 { 00064 public: 00065 CEvtQueue(); 00066 virtual ~CEvtQueue(); 00067 00068 int wait(long lTimeout, CEvt** ppEvt); 00069 int add(CEvt* pEvt); 00070 00071 protected: 00072 boost::mutex m_mtxQueue; 00073 boost::mutex m_mtxWait; 00074 boost::condition m_condEvent; 00075 00076 DEQUE_EVT m_dequeEvt; 00077 00078 int getFromQueue(CEvt** ppEvt); 00079 }; 00080 } 00081 00082 #endif // ! _BOGOTEL_EVTQUEUE_H