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 chip 1.24 // 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 mike 1.4 // 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 chip 1.24 //
13 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
14 mike 1.4 // 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 chip 1.24 // 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 mike 1.4 // 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 chip 1.24 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
|
28 mike 1.6 // (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 chip 1.24 class PEGASUS_COMMON_LINKAGE message_mask
|
47 mike 1.6 {
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 chip 1.24
|
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 mday 1.22 static Uint32 ha_wait;
|
69 chip 1.24
70
71 // more for documentation than for use
|
72 mike 1.7
|
73 mday 1.9 inline Uint32 get_type(Uint32 flags)
|
74 mike 1.6 {
75 return (flags & 0x000fffff);
76 }
77
78 inline Uint32 get_handling(Uint32 flags)
79 {
80 return( flags & 0xfff00000);
81 }
82 };
83
|
84 mday 1.20 class cimom;
|
85 mike 1.4 class MessageQueue;
|
86 mday 1.19 class MessageQueueService;
87 class AsyncLegacyOperationStart;
88 class AsyncLegacyOperationResult;
|
89 mike 1.4
|
90 chip 1.24 /** The Message class and derived classes are used to pass messages between
|
91 mike 1.4 modules. Messages are passed between modules using the message queues
92 (see MessageQueue class). Derived classes may add their own fields.
93 This base class defines two common fields: type, which is the type of
94 the message, and key which is a key value whose meaning is defined by
95 the derived class. The MessageQueue class provides methods for finding
96 messages by both type and key.
97
98 The Message class also provides previous and next pointers which are
99 used to place the messages on a queue by the MessageQueue class.
100 */
|
101 mike 1.5 class PEGASUS_COMMON_LINKAGE Message
|
102 mike 1.4 {
|
103 mday 1.8 public:
|
104 mike 1.4
|
105 mday 1.8 Message(
|
106 mday 1.20 Uint32 type,
107 Uint32 destination = 0,
|
108 chip 1.24 Uint32 key = getNextKey(),
|
109 mday 1.8 Uint32 routing_code = 0,
|
110 chip 1.24 Uint32 mask = message_mask::type_legacy )
111 :
112 _type(type),
113 _key(key),
114 _routing_code(routing_code),
|
115 mday 1.8 _mask(mask),
|
116 chip 1.24 _next(0),
|
117 mday 1.19 _prev(0),
|
118 mday 1.20 _async(0),
119 dest(destination)
|
120 chip 1.24 {
|
121 mday 1.8
122 }
|
123 mike 1.6
|
124 mday 1.22 Message(Message & msg)
125 {
126 if( this != &msg)
127 {
128 _type = msg._type;
129 _key = msg._key;
130 _routing_code = msg._routing_code;
131 _mask = msg._mask;
132 _next = _prev = _async = 0;
133 dest = msg.dest;
134 }
135 }
136
|
137 chip 1.24
138 virtual ~Message();
|
139 mike 1.4
|
140 mday 1.8 Uint32 getType() const { return _type; }
|
141 mike 1.4
|
142 mday 1.8 void setType(Uint32 type) { _type = type; }
|
143 mike 1.4
|
144 mday 1.8 Uint32 getKey() const { return _key; }
|
145 mike 1.4
|
146 mday 1.8 void setKey(Uint32 key) { _key = key; }
|
147 mike 1.4
|
148 mday 1.8 Uint32 getRouting() const { return _routing_code; }
149 void setRouting(Uint32 routing) { _routing_code = routing; }
|
150 mike 1.4
|
151 mday 1.8 Uint32 getMask() const { return _mask; }
|
152 chip 1.24
|
153 mday 1.8 void setMask(Uint32 mask) { _mask = mask; }
|
154 chip 1.24
|
155 mday 1.8 Message* getNext() { return _next; }
|
156 mike 1.4
|
157 mday 1.8 const Message* getNext() const { return _next; }
|
158 mike 1.4
|
159 mday 1.8 Message* getPrevious() { return _prev; }
|
160 mike 1.4
|
161 mday 1.8 const Message* getPrevious() const { return _prev; }
|
162 mike 1.4
|
163 chip 1.24 static Uint32 getNextKey()
164 {
165
166 _mut.lock( pegasus_thread_self() ) ;
|
167 mike 1.6 Uint32 ret = _nextKey++;
168 _mut.unlock();
169 return ret;
170 }
|
171 chip 1.24
|
172 mday 1.8 virtual void print(PEGASUS_STD(ostream)& os) const;
|
173 mike 1.4
|
174 chip 1.24 // << Thu Dec 27 10:46:04 2001 mdd >> for use with DQueue container
175 // as used by AsyncOpNode
|
176 kumpf 1.23 Boolean operator == (const void *msg )
|
177 mday 1.13 {
|
178 mday 1.16 if (reinterpret_cast<void *>(this) == msg )
|
179 mday 1.13 return true;
180 return false;
181 }
|
182 chip 1.24
|
183 mday 1.22 Message *get_async(void)
184 {
185 Message *ret = _async;
186 _async = 0;
187 return ret;
|
188 chip 1.24
|
189 mday 1.22 }
|
190 chip 1.24
|
191 mday 1.22 void put_async(Message * msg)
192 {
193 _async = msg;
194 }
|
195 chip 1.24
196
|
197 mday 1.8 private:
|
198 mike 1.6 Uint32 _type;
199 Uint32 _key;
|
200 mday 1.8 Uint32 _routing_code;
|
201 mike 1.6 Uint32 _mask;
202 Message* _next;
203 Message* _prev;
|
204 mday 1.19 protected:
205 Message *_async;
|
206 mday 1.21 public:
|
207 mday 1.20 Uint32 dest;
|
208 chip 1.24
|
209 mday 1.19 private:
|
210 mike 1.6 MessageQueue* _owner;
211 static Uint32 _nextKey;
212 static Mutex _mut;
|
213 mday 1.20 friend class cimom;
|
214 mike 1.6 friend class MessageQueue;
|
215 mday 1.19 friend class MessageQueueService;
216 friend class AsyncLegacyOperationStart;
217 friend class AsyncLegacyOperationResult;
|
218 chip 1.24
|
219 mike 1.4 };
|
220 mike 1.5
|
221 mike 1.6
|
222 mike 1.5 enum MessageType
223 {
224 DUMMY_MESSAGE,
225
226 // CIM Message types:
227
228 CIM_GET_CLASS_REQUEST_MESSAGE,
229 CIM_GET_INSTANCE_REQUEST_MESSAGE,
|
230 mike 1.6 CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
|
231 mike 1.5 CIM_DELETE_CLASS_REQUEST_MESSAGE,
232 CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
233 CIM_CREATE_CLASS_REQUEST_MESSAGE,
234 CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
235 CIM_MODIFY_CLASS_REQUEST_MESSAGE,
236 CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
237 CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE,
238 CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
239 CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
240 CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
241 CIM_EXEC_QUERY_REQUEST_MESSAGE,
242 CIM_ASSOCIATORS_REQUEST_MESSAGE,
243 CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
244 CIM_REFERENCES_REQUEST_MESSAGE,
245 CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
246 CIM_GET_PROPERTY_REQUEST_MESSAGE,
247 CIM_SET_PROPERTY_REQUEST_MESSAGE,
248 CIM_GET_QUALIFIER_REQUEST_MESSAGE,
249 CIM_SET_QUALIFIER_REQUEST_MESSAGE,
250 CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
251 CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
252 mike 1.5 CIM_INVOKE_METHOD_REQUEST_MESSAGE,
|
253 mike 1.6 CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
254 CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
255 CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
|
256 kumpf 1.15 CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
|
257 kumpf 1.17 CIM_HANDLE_INDICATION_REQUEST_MESSAGE,
|
258 kumpf 1.15 CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
259 CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
|
260 chip 1.25
261 // new
262 CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,
263 CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
264 CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
265
|
266 mike 1.5 CIM_GET_CLASS_RESPONSE_MESSAGE,
267 CIM_GET_INSTANCE_RESPONSE_MESSAGE,
|
268 mike 1.6 CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
|
269 mike 1.5 CIM_DELETE_CLASS_RESPONSE_MESSAGE,
270 CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,
271 CIM_CREATE_CLASS_RESPONSE_MESSAGE,
272 CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
273 CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
274 CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
275 CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
276 CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
277 CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
278 CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
279 CIM_EXEC_QUERY_RESPONSE_MESSAGE,
280 CIM_ASSOCIATORS_RESPONSE_MESSAGE,
281 CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
282 CIM_REFERENCES_RESPONSE_MESSAGE,
283 CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
284 CIM_GET_PROPERTY_RESPONSE_MESSAGE,
285 CIM_SET_PROPERTY_RESPONSE_MESSAGE,
286 CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
287 CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
288 CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
289 CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
290 mike 1.5 CIM_INVOKE_METHOD_RESPONSE_MESSAGE,
|
291 mike 1.6 CIM_ENABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
292 CIM_MODIFY_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
293 CIM_DISABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
|
294 kumpf 1.15 CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
295 CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,
296 CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
|
297 kumpf 1.17 CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
|
298 mike 1.6
|
299 chip 1.25 // new
300 CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
301 CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
302 CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
|
303 chip 1.24
|
304 mike 1.6 // Monitor-related messages:
305
306 SOCKET_MESSAGE,
307
308 // Connection-oriented messages:
309
310 CLOSE_CONNECTION_MESSAGE,
311
312 // HTTP messages:
313
314 HTTP_MESSAGE,
|
315 mike 1.5
316 NUMBER_OF_MESSAGES
317 };
318
319 PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
|
320 mike 1.6
321 /** This class implements a stack of queue-ids. Many messages must keep a
322 stack of queue-ids of queues which they must be returned to. This provides
323 a light efficient stack for this purpose.
324 */
325 class QueueIdStack
326 {
327 public:
328
|
329 chip 1.24 QueueIdStack() : _size(0)
330 {
|
331 mike 1.6 }
332
|
333 chip 1.24 QueueIdStack(const QueueIdStack& x) : _size(x._size)
|
334 mike 1.6 {
335 memcpy(_items, x._items, sizeof(_items));
336 }
337
|
338 chip 1.24 PEGASUS_EXPLICIT QueueIdStack(Uint32 x) : _size(0)
339 {
340 push(x);
|
341 mike 1.6 }
342
|
343 chip 1.24 PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2) : _size(0)
|
344 mike 1.6 {
|
345 chip 1.24 push(x1);
346 push(x2);
|
347 mike 1.6 }
348
|
349 chip 1.24 ~QueueIdStack()
350 {
|
351 mike 1.6 }
352
|
353 chip 1.24 QueueIdStack& operator=(const QueueIdStack& x)
|
354 mike 1.6 {
355 if (this != &x)
356 {
357 memcpy(_items, x._items, sizeof(_items));
358 _size = x._size;
359 }
360 return *this;
361 }
362
|
363 chip 1.24 Uint32 size() const
364 {
365 return _size;
|
366 mike 1.6 }
367
|
368 chip 1.24 Boolean isEmpty() const
369 {
370 return _size == 0;
|
371 mike 1.6 }
372
|
373 chip 1.24 void push(Uint32 x)
|
374 mike 1.6 {
375 if (_size == MAX_SIZE)
376 throw StackOverflow();
377
378 _items[_size++] = x;
379 }
380
381 Uint32& top()
382 {
383 if (_size == 0)
384 throw StackUnderflow();
385
386 return _items[_size-1];
387 }
388
|
389 chip 1.24 Uint32 top() const
|
390 mike 1.6 {
|
391 chip 1.24 return ((QueueIdStack*)this)->top();
|
392 mike 1.6 }
393
|
394 chip 1.24 void pop()
|
395 mike 1.6 {
396 if (_size == 0)
397 throw StackUnderflow();
398
399 _size--;
400 }
401
402 /** Make a copy of this stack and then pop the top element. */
403 QueueIdStack copyAndPop() const
404 {
405 return QueueIdStack(*this, 0);
406 }
407
408 private:
409
410 // Copy the given stack but then pop the top element:
|
411 chip 1.24 QueueIdStack(const QueueIdStack& x, int) : _size(x._size)
|
412 mike 1.6 {
413 memcpy(_items, x._items, sizeof(_items));
414 pop();
415 }
416
417 enum { MAX_SIZE = 5 };
418 Uint32 _items[MAX_SIZE];
419 Uint32 _size;
420 };
|
421 mike 1.4
422 PEGASUS_NAMESPACE_END
423
424 #endif /* Pegasus_Message_h */
|