sipxportlib  Version 3.3
OsMsgDispatcher.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 SIPez LLC.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2007 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // $$
10 
11 // Author: Keith Kyzivat <kkyzivat AT SIPez DOT com>
12 
13 #ifndef _OsMsgDispatcher_h_
14 #define _OsMsgDispatcher_h_
15 
16 // SYSTEM INCLUDES
17 #include <os/OsMsgQ.h>
18 
19 // APPLICATION INCLUDES
20 #include "os/OsMsg.h"
21 
22 // DEFINES
23 // MACROS
24 // EXTERNAL FUNCTIONS
25 // EXTERNAL VARIABLES
26 // CONSTANTS
27 // STRUCTS
28 // TYPEDEFS
29 // FORWARD DECLARATIONS
30 
40 {
41 /* //////////////////////////// PUBLIC //////////////////////////////////// */
42 public:
43 
44 /* ============================ CREATORS ================================== */
46 
47 
54  OsMsgDispatcher(OsMsgQ* msgQ);
61  virtual ~OsMsgDispatcher();
63 
65 
66 /* ============================ MANIPULATORS ============================== */
68 
69  virtual OsStatus post(const OsMsg& msg);
84  virtual OsStatus receive(OsMsg*& rpMsg,
86  const OsTime& rTimeout=OsTime::OS_INFINITY);
100 
101 /* ============================ ACCESSORS ================================= */
103 
104 
106  inline virtual int numMsgs(void);
107 
109  inline int maxMsgs() const;
110 
111 /* ============================ INQUIRY =================================== */
113 
114 
116  inline virtual UtlBoolean isEmpty(void);
117 
118  inline UtlBoolean isMsgsLost() const;
119 
121 
122 /* //////////////////////////// PROTECTED ///////////////////////////////// */
123 protected:
124 
125  OsMsgQ* mMsgQueue;
127 
129 
131 /* //////////////////////////// PRIVATE /////////////////////////////////// */
132 private:
133 
135  inline void setMsgsLost();
136 
138  OsMsgDispatcher(const OsMsgDispatcher& rMsgDispatcher);
139 
141  OsMsgDispatcher& operator=(const OsMsgDispatcher& rhs);
142 };
143 
144 /* ============================ INLINE METHODS ============================ */
145 
146 
148 {
149  return mMsgQueue->numMsgs();
150 }
151 
153 {
154  return mMsgQueue->maxMsgs();
155 }
156 
158 {
159  return mMsgQueue->isEmpty();
160 }
161 
163 {
164  return mMsgsLost;
165 }
166 
167 void OsMsgDispatcher::setMsgsLost()
168 {
169  mMsgsLost = TRUE;
170 }
171 
172 #endif // _OsMsgDispatcher_h_
int maxMsgs() const
Returns the maximum number of messages that can be queued.
Definition: OsMsgDispatcher.h:152
virtual UtlBoolean isEmpty(void)
Return TRUE if the message queue is empty, FALSE otherwise.
Definition: OsMsgDispatcher.h:157
Dispatcher for Resource Notification Messages.
Definition: OsMsgDispatcher.h:39
UtlBoolean mQueueOwned
Indicates whether or not mMsgQueue is owned by the dispatcher.
Definition: OsMsgDispatcher.h:126
virtual OsStatus receive(OsMsg *&rpMsg, const OsTime &rTimeout=OsTime::OS_INFINITY)
Receive a message from the dispatcher queue.
Definition: OsMsgDispatcher.cpp:66
UtlBoolean isMsgsLost() const
Definition: OsMsgDispatcher.h:162
OsMsgQ * mMsgQueue
The message queue that this dispatcher is using.
Definition: OsMsgDispatcher.h:125
OsStatus
Definition: OsStatus.h:27
UtlBoolean mMsgsLost
Whether any messages have been dropped on the < floor due to the queue being full.
Definition: OsMsgDispatcher.h:128
OsMsgDispatcher()
Default constructor.
Definition: OsMsgDispatcher.cpp:26
Definition: OsTime.h:45
virtual OsStatus post(const OsMsg &msg)
Post a resource notification message.
Definition: OsMsgDispatcher.cpp:51
Definition: OsTime.h:37
virtual ~OsMsgDispatcher()
Destructor.
Definition: OsMsgDispatcher.cpp:40
int UtlBoolean
Definition: UtlDefs.h:41
Definition: OsMsg.h:36
#define TRUE
Definition: UtlDefs.h:25
virtual int numMsgs(void)
Return the number of messages in the queue.
Definition: OsMsgDispatcher.h:147