1 mike 1.6 //%///-*-c++-*-/////////////////////////////////////////////////////////////////
|
2 mike 1.4 //
|
3 mike 1.6 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,
4 // The Open Group, Tivoli Systems
|
5 mike 1.4 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to
8 // deal in the Software without restriction, including without limitation the
9 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 // sell copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
14 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
15 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
16 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
17 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 //==============================================================================
23 //
24 // Author: Mike Brasher (mbrasher@bmc.com)
25 //
|
26 mike 1.6 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
27 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
28 // (carolann_graves@hp.com)
|
29 mday 1.9 // Modified By: Mike Day (mdday@us.ibm.com)
|
30 mike 1.4 //
31 //%/////////////////////////////////////////////////////////////////////////////
32
33 #ifndef Pegasus_Message_h
34 #define Pegasus_Message_h
35
|
36 mike 1.6 #include <Pegasus/Common/Config.h>
|
37 mike 1.4 #include <iostream>
|
38 mike 1.6 #include <cstring>
39 #include <Pegasus/Common/Exception.h>
40 #include <Pegasus/Common/IPC.h>
|
41 mike 1.4
42 PEGASUS_NAMESPACE_BEGIN
43
|
44 mday 1.18 // REVIEW: could class be renamed to MessageMask (coding standard)
|
45 mike 1.11
|
46 mike 1.6 class PEGASUS_COMMON_LINKAGE message_mask
47 {
48 public:
|
49 mike 1.11
|
50 mike 1.6 static Uint32 type_legacy;
|
51 mday 1.9 static Uint32 type_CIMOperation;
52 static Uint32 type_CIMAsyncOperation;
53 static Uint32 type_export;
54 static Uint32 type_lifetime;
|
55 mike 1.6 static Uint32 type_socket;
56 static Uint32 type_connection;
57 static Uint32 type_http;
58 static Uint32 type_cimom;
|
59 mday 1.9 static Uint32 type_control;
60 static Uint32 type_service;
61 static Uint32 type_broadcast;
|
62 mike 1.6
|
63 mday 1.9 static Uint32 ha_no_delete;
64 static Uint32 ha_request;
65 static Uint32 ha_reply;
|
66 mday 1.10 static Uint32 ha_synchronous;
|
67 mday 1.13 static Uint32 ha_async;
68
|
69 mike 1.7 // more for documentation than for use
70
|
71 mday 1.9 inline Uint32 get_type(Uint32 flags)
|
72 mike 1.6 {
73 return (flags & 0x000fffff);
74 }
75
76 inline Uint32 get_handling(Uint32 flags)
77 {
78 return( flags & 0xfff00000);
79 }
80 };
81
|
82 mday 1.20 class cimom;
|
83 mike 1.4 class MessageQueue;
|
84 mday 1.19 class MessageQueueService;
85 class AsyncLegacyOperationStart;
86 class AsyncLegacyOperationResult;
|
87 mike 1.4
88 /** The Message class and derived classes are used to pass messages between
89 modules. Messages are passed between modules using the message queues
90 (see MessageQueue class). Derived classes may add their own fields.
91 This base class defines two common fields: type, which is the type of
92 the message, and key which is a key value whose meaning is defined by
93 the derived class. The MessageQueue class provides methods for finding
94 messages by both type and key.
95
96 The Message class also provides previous and next pointers which are
97 used to place the messages on a queue by the MessageQueue class.
98 */
|
99 mike 1.5 class PEGASUS_COMMON_LINKAGE Message
|
100 mike 1.4 {
|
101 mday 1.8 public:
|
102 mike 1.4
|
103 mday 1.8 Message(
|
104 mday 1.20 Uint32 type,
105 Uint32 destination = 0,
|
106 mday 1.8 Uint32 key = getNextKey(),
107 Uint32 routing_code = 0,
|
108 mday 1.20 Uint32 mask = message_mask::type_legacy )
|
109 mday 1.8 :
110 _type(type),
111 _key(key),
112 _routing_code(routing_code),
113 _mask(mask),
114 _next(0),
|
115 mday 1.19 _prev(0),
|
116 mday 1.20 _async(0),
117 dest(destination)
|
118 mday 1.8 {
119
120 }
|
121 mike 1.6
|
122 mday 1.8 virtual ~Message();
|
123 mike 1.4
|
124 mday 1.8 Uint32 getType() const { return _type; }
|
125 mike 1.4
|
126 mday 1.8 void setType(Uint32 type) { _type = type; }
|
127 mike 1.4
|
128 mday 1.8 Uint32 getKey() const { return _key; }
|
129 mike 1.4
|
130 mday 1.8 void setKey(Uint32 key) { _key = key; }
|
131 mike 1.4
|
132 mday 1.8 Uint32 getRouting() const { return _routing_code; }
133 void setRouting(Uint32 routing) { _routing_code = routing; }
|
134 mike 1.4
|
135 mday 1.8 Uint32 getMask() const { return _mask; }
|
136 mike 1.6
|
137 mday 1.8 void setMask(Uint32 mask) { _mask = mask; }
|
138 mike 1.6
|
139 mday 1.8 Message* getNext() { return _next; }
|
140 mike 1.4
|
141 mday 1.8 const Message* getNext() const { return _next; }
|
142 mike 1.4
|
143 mday 1.8 Message* getPrevious() { return _prev; }
|
144 mike 1.4
|
145 mday 1.8 const Message* getPrevious() const { return _prev; }
|
146 mike 1.4
|
147 mday 1.8 static Uint32 getNextKey()
|
148 mike 1.6 {
149
150 _mut.lock( pegasus_thread_self() ) ;
151 Uint32 ret = _nextKey++;
152 _mut.unlock();
153 return ret;
154 }
155
|
156 mday 1.8 virtual void print(PEGASUS_STD(ostream)& os) const;
|
157 mike 1.4
|
158 mday 1.13 // << Thu Dec 27 10:46:04 2001 mdd >> for use with DQueue container
159 // as used by AsyncOpNode
160 Boolean operator == (void *msg )
161 {
|
162 mday 1.16 if (reinterpret_cast<void *>(this) == msg )
|
163 mday 1.13 return true;
164 return false;
165 }
166
167
|
168 mday 1.8 private:
|
169 mike 1.6 Uint32 _type;
170 Uint32 _key;
|
171 mday 1.8 Uint32 _routing_code;
|
172 mike 1.6 Uint32 _mask;
173 Message* _next;
174 Message* _prev;
|
175 mday 1.19 protected:
176 Message *_async;
|
177 mday 1.21 public:
|
178 mday 1.20 Uint32 dest;
179
|
180 mday 1.19 private:
|
181 mike 1.6 MessageQueue* _owner;
182 static Uint32 _nextKey;
183 static Mutex _mut;
|
184 mday 1.20 friend class cimom;
|
185 mike 1.6 friend class MessageQueue;
|
186 mday 1.19 friend class MessageQueueService;
187 friend class AsyncLegacyOperationStart;
188 friend class AsyncLegacyOperationResult;
189
|
190 mike 1.4 };
|
191 mike 1.5
|
192 mike 1.6
|
193 mike 1.5 enum MessageType
194 {
195 DUMMY_MESSAGE,
196
197 // CIM Message types:
198
199 CIM_GET_CLASS_REQUEST_MESSAGE,
200 CIM_GET_INSTANCE_REQUEST_MESSAGE,
|
201 mike 1.6 CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
|
202 mike 1.5 CIM_DELETE_CLASS_REQUEST_MESSAGE,
203 CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
204 CIM_CREATE_CLASS_REQUEST_MESSAGE,
205 CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
206 CIM_MODIFY_CLASS_REQUEST_MESSAGE,
207 CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
208 CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE,
209 CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
210 CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
211 CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
212 CIM_EXEC_QUERY_REQUEST_MESSAGE,
213 CIM_ASSOCIATORS_REQUEST_MESSAGE,
214 CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
215 CIM_REFERENCES_REQUEST_MESSAGE,
216 CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
217 CIM_GET_PROPERTY_REQUEST_MESSAGE,
218 CIM_SET_PROPERTY_REQUEST_MESSAGE,
219 CIM_GET_QUALIFIER_REQUEST_MESSAGE,
220 CIM_SET_QUALIFIER_REQUEST_MESSAGE,
221 CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
222 CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
223 mike 1.5 CIM_INVOKE_METHOD_REQUEST_MESSAGE,
|
224 mike 1.6 CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
225 CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
226 CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
|
227 kumpf 1.15 CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
|
228 kumpf 1.17 CIM_HANDLE_INDICATION_REQUEST_MESSAGE,
|
229 kumpf 1.15 CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
230 CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
|
231 mike 1.5 CIM_GET_CLASS_RESPONSE_MESSAGE,
232 CIM_GET_INSTANCE_RESPONSE_MESSAGE,
|
233 mike 1.6 CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
|
234 mike 1.5 CIM_DELETE_CLASS_RESPONSE_MESSAGE,
235 CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,
236 CIM_CREATE_CLASS_RESPONSE_MESSAGE,
237 CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
238 CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
239 CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
240 CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
241 CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
242 CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
243 CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
244 CIM_EXEC_QUERY_RESPONSE_MESSAGE,
245 CIM_ASSOCIATORS_RESPONSE_MESSAGE,
246 CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
247 CIM_REFERENCES_RESPONSE_MESSAGE,
248 CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
249 CIM_GET_PROPERTY_RESPONSE_MESSAGE,
250 CIM_SET_PROPERTY_RESPONSE_MESSAGE,
251 CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
252 CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
253 CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
254 CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
255 mike 1.5 CIM_INVOKE_METHOD_RESPONSE_MESSAGE,
|
256 mike 1.6 CIM_ENABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
257 CIM_MODIFY_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
258 CIM_DISABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
|
259 kumpf 1.15 CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
260 CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,
261 CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
|
262 kumpf 1.17 CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
|
263 mike 1.6
264 // Monitor-related messages:
265
266 SOCKET_MESSAGE,
267
268 // Connection-oriented messages:
269
270 CLOSE_CONNECTION_MESSAGE,
271
272 // HTTP messages:
273
274 HTTP_MESSAGE,
|
275 mike 1.5
276 NUMBER_OF_MESSAGES
277 };
278
279 PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
|
280 mike 1.6
281 /** This class implements a stack of queue-ids. Many messages must keep a
282 stack of queue-ids of queues which they must be returned to. This provides
283 a light efficient stack for this purpose.
284 */
285 class QueueIdStack
286 {
287 public:
288
289 QueueIdStack() : _size(0)
290 {
291 }
292
293 QueueIdStack(const QueueIdStack& x) : _size(x._size)
294 {
295 memcpy(_items, x._items, sizeof(_items));
296 }
297
298 PEGASUS_EXPLICIT QueueIdStack(Uint32 x) : _size(0)
299 {
300 push(x);
301 mike 1.6 }
302
303 PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2) : _size(0)
304 {
305 push(x1);
306 push(x2);
307 }
308
309 ~QueueIdStack()
310 {
311 }
312
313 QueueIdStack& operator=(const QueueIdStack& x)
314 {
315 if (this != &x)
316 {
317 memcpy(_items, x._items, sizeof(_items));
318 _size = x._size;
319 }
320 return *this;
321 }
322 mike 1.6
323 Uint32 size() const
324 {
325 return _size;
326 }
327
328 Boolean isEmpty() const
329 {
330 return _size == 0;
331 }
332
333 void push(Uint32 x)
334 {
335 if (_size == MAX_SIZE)
336 throw StackOverflow();
337
338 _items[_size++] = x;
339 }
340
341 Uint32& top()
342 {
343 mike 1.6 if (_size == 0)
344 throw StackUnderflow();
345
346 return _items[_size-1];
347 }
348
349 Uint32 top() const
350 {
351 return ((QueueIdStack*)this)->top();
352 }
353
354 void pop()
355 {
356 if (_size == 0)
357 throw StackUnderflow();
358
359 _size--;
360 }
361
362 /** Make a copy of this stack and then pop the top element. */
363 QueueIdStack copyAndPop() const
364 mike 1.6 {
365 return QueueIdStack(*this, 0);
366 }
367
368 private:
369
370 // Copy the given stack but then pop the top element:
371 QueueIdStack(const QueueIdStack& x, int) : _size(x._size)
372 {
373 memcpy(_items, x._items, sizeof(_items));
374 pop();
375 }
376
377 enum { MAX_SIZE = 5 };
378 Uint32 _items[MAX_SIZE];
379 Uint32 _size;
380 };
|
381 mike 1.4
382 PEGASUS_NAMESPACE_END
383
384 #endif /* Pegasus_Message_h */
|