(file) Return to Message.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 karl  1.72 //%2006////////////////////////////////////////////////////////////////////////
  2 mike  1.4  //
  3 karl  1.58 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4            // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5            // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 karl  1.48 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl  1.58 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8            // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl  1.62 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10            // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl  1.72 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12            // EMC Corporation; Symantec Corporation; The Open Group.
 13 mike  1.4  //
 14            // Permission is hereby granted, free of charge, to any person obtaining a copy
 15 chip  1.24 // of this software and associated documentation files (the "Software"), to
 16            // deal in the Software without restriction, including without limitation the
 17            // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18 mike  1.4  // sell copies of the Software, and to permit persons to whom the Software is
 19            // furnished to do so, subject to the following conditions:
 20 kumpf 1.37 // 
 21 chip  1.24 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22 mike  1.4  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23            // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24 chip  1.24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25            // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26            // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27 mike  1.4  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28            // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29            //
 30            //==============================================================================
 31            //
 32            //%/////////////////////////////////////////////////////////////////////////////
 33            
 34            #ifndef Pegasus_Message_h
 35            #define Pegasus_Message_h
 36            
 37 mike  1.6  #include <Pegasus/Common/Config.h>
 38 mike  1.4  #include <iostream>
 39 mike  1.6  #include <cstring>
 40 kumpf 1.39 #include <Pegasus/Common/InternalException.h>
 41 kumpf 1.38 #include <Pegasus/Common/Linkage.h>
 42 w.white 1.68 #include <Pegasus/Common/TimeValue.h>
 43 w.white 1.63 #include <Pegasus/Common/CIMOperationType.h>
 44 kumpf   1.81 #include <Pegasus/Common/Threads.h>
 45 mike    1.76 #include <Pegasus/Common/Linkable.h>
 46 mike    1.4  
 47              PEGASUS_NAMESPACE_BEGIN
 48              
 49 kumpf   1.83 class PEGASUS_COMMON_LINKAGE MessageMask
 50 mike    1.6  {
 51 kumpf   1.83 public:
 52                  // Message type is indicated by the low order 20 bits.  For example:
 53                  // Uint32 messageType = flags & 0x000fffff;
 54                  static Uint32 type_legacy;
 55                  static Uint32 type_cimom;
 56                  static Uint32 type_service;
 57              
 58                  // Message handling is indicated by the high order 12 bits.  For example:
 59                  // Uint32 messageHandling = flags & 0xfff00000;
 60                  static Uint32 ha_request;
 61                  static Uint32 ha_reply;
 62                  static Uint32 ha_async;
 63 mike    1.6  };
 64              
 65 kumpf   1.40 enum HttpMethod
 66              {
 67                  HTTP_METHOD__POST,
 68                  HTTP_METHOD_M_POST
 69              };
 70              
 71 chip    1.24 /** The Message class and derived classes are used to pass messages between
 72 mike    1.4      modules. Messages are passed between modules using the message queues
 73                  (see MessageQueue class). Derived classes may add their own fields.
 74 kumpf   1.78     This base class defines a common type field, which is the type of
 75                  the message.
 76 mike    1.4  */
 77 mike    1.76 class PEGASUS_COMMON_LINKAGE Message : public Linkable
 78 mike    1.4  {
 79 kumpf   1.86 public:
 80              
 81                  Message(
 82                      Uint32 type,
 83                      Uint32 destination = 0,
 84                      Uint32 mask = MessageMask::type_legacy)
 85                      :
 86                      _type(type),
 87                      _mask(mask),
 88                      _httpMethod (HTTP_METHOD__POST),
 89                      _serverStartTimeMicroseconds(0),
 90                      _providerTimeMicroseconds(0),
 91                      _totalServerTimeMicroseconds(0),
 92                      _close_connect(false),
 93                      _last_thread_id(Threads::self()),
 94                      _async(0),
 95                      dest(destination),
 96                      _isComplete(true),
 97                      _index(0)
 98                  {
 99                  }
100 mike    1.4  
101 kumpf   1.86     virtual ~Message();
102 chip    1.24 
103 kumpf   1.86     // NOTE: The compiler default implementation of the copy constructor
104                  // is used for this class.
105              
106                  Boolean getCloseConnect() const { return _close_connect; }
107                  void setCloseConnect(Boolean close_connect)
108                  {
109                      _close_connect = close_connect;
110                  }
111 chip    1.24 
112 kumpf   1.86     Uint32 getType() const { return _type; }
113 kumpf   1.40 
114 kumpf   1.86     void setType(Uint32 type) { _type = type; }
115              
116                  Uint32 getMask() const { return _mask; }
117              
118                  void setMask(Uint32 mask) { _mask = mask; }
119              
120                  HttpMethod getHttpMethod() const { return _httpMethod; }
121              
122                  void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;}
123 kumpf   1.40 
124 karl    1.61 #ifndef PEGASUS_DISABLE_PERFINST
125 kumpf   1.86     //
126                  // Needed for performance measurement
127                  //
128              
129                  Uint64 getServerStartTime() const
130                  {
131                      return _serverStartTimeMicroseconds;
132                  }
133              
134                  void setServerStartTime(Uint64 serverStartTimeMicroseconds)
135                  {
136                       _serverStartTimeMicroseconds = serverStartTimeMicroseconds;
137                  }
138              
139                  void endServer();
140              
141                  Uint64 getProviderTime() const
142                  {
143                      return _providerTimeMicroseconds;
144                  }
145              
146 kumpf   1.86     void setProviderTime(Uint64 providerTimeMicroseconds)
147                  {
148                      _providerTimeMicroseconds = providerTimeMicroseconds;
149                  }
150              
151                  Uint64 getTotalServerTime() const
152                  {
153                      return _totalServerTimeMicroseconds;
154                  }
155              
156                  void setTotalServerTime(Uint64 totalServerTimeMicroseconds)
157                  {
158                      _totalServerTimeMicroseconds = totalServerTimeMicroseconds;
159                  }
160 sage    1.30 
161 sage    1.31 #endif
162 sage    1.30 
163 kumpf   1.86     static CIMOperationType convertMessageTypetoCIMOpType(Uint32 type);
164 w.white 1.63 
165 joyce.j 1.69 #ifdef PEGASUS_DEBUG
166 kumpf   1.86     virtual void print(
167                      PEGASUS_STD(ostream)& os,
168                      Boolean printHeader = true) const;
169 joyce.j 1.69 #endif
170 mike    1.4  
171 kumpf   1.86     Message* get_async()
172                  {
173                      Message *ret = _async;
174                      _async = 0;
175                      return ret;
176                  }
177              
178                  void put_async(Message* msg)
179                  {
180                      _async = msg;
181                  }
182              
183                  // << Tue Jul  1 11:02:49 2003 mdd >> pep_88 and helper for i18n and l10n
184                  Boolean thread_changed()
185                  {
186                      if (!Threads::equal(_last_thread_id, Threads::self()))
187                      {
188                          _last_thread_id = Threads::self();
189                          return true;
190                      }
191              
192 kumpf   1.86         return false;
193                  }
194              
195                  // set the message index indicating what piece (or sequence) this is
196                  // message indexes start at zero
197                  void setIndex(Uint32 index) { _index = index; }
198              
199                  // increment the message index
200                  void incrementIndex() { _index++; }
201              
202                  // set the complete flag indicating if this message piece is the
203                  // last or not
204                  void setComplete(Boolean isComplete)
205                  {
206                      _isComplete = isComplete ? true:false;
207                  }
208              
209                  // get the message index (or sequence number)
210                  Uint32 getIndex() const { return _index; }
211 w.white 1.56 
212 kumpf   1.86     // is this the first piece of the message ?
213                  Boolean isFirst() const { return _index == 0 ? true : false; }
214              
215                  // is this message complete? (i.e the last in a one or more sequence)
216                  Boolean isComplete() const { return _isComplete; }
217              
218              private:
219                  Uint32 _type;
220                  Uint32 _mask;
221                  HttpMethod _httpMethod;
222              
223                  // Needed for performance measurement
224                  Uint64 _serverStartTimeMicroseconds;
225                  Uint64 _providerTimeMicroseconds;
226                  Uint64 _totalServerTimeMicroseconds;
227              
228                  Boolean _close_connect;
229              
230                  // << Tue Jul  1 11:02:35 2003 mdd >> pep_88 and helper for i18n and l10n
231                  ThreadType _last_thread_id;
232              
233 kumpf   1.86 public:
234                  Message *_async;
235                  Uint32 dest;
236              
237              private:
238                  Message& operator=(const Message& msg);
239 kumpf   1.85 
240 kumpf   1.86     Boolean _isComplete;
241                  Uint32 _index;
242 mike    1.4  };
243 mike    1.5  
244 mike    1.6  
245 mike    1.5  enum MessageType
246              {
247                  DUMMY_MESSAGE,
248              
249                  // CIM Message types:
250              
251                  CIM_GET_CLASS_REQUEST_MESSAGE,
252                  CIM_GET_INSTANCE_REQUEST_MESSAGE,
253 mike    1.6      CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
254 mike    1.5      CIM_DELETE_CLASS_REQUEST_MESSAGE,
255                  CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
256                  CIM_CREATE_CLASS_REQUEST_MESSAGE,
257                  CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
258                  CIM_MODIFY_CLASS_REQUEST_MESSAGE,
259                  CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
260 mday    1.32     CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE, //10
261 mike    1.5      CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
262                  CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
263                  CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
264                  CIM_EXEC_QUERY_REQUEST_MESSAGE,
265                  CIM_ASSOCIATORS_REQUEST_MESSAGE,
266                  CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
267                  CIM_REFERENCES_REQUEST_MESSAGE,
268                  CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
269                  CIM_GET_PROPERTY_REQUEST_MESSAGE,
270 mday    1.32     CIM_SET_PROPERTY_REQUEST_MESSAGE, //20
271 mike    1.5      CIM_GET_QUALIFIER_REQUEST_MESSAGE,
272                  CIM_SET_QUALIFIER_REQUEST_MESSAGE,
273                  CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
274                  CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
275                  CIM_INVOKE_METHOD_REQUEST_MESSAGE,
276 kumpf   1.15     CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
277 kumpf   1.73     CIM_HANDLE_INDICATION_REQUEST_MESSAGE,
278 kumpf   1.75     CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
279 kumpf   1.15     CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
280 kumpf   1.75     CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,  // 30
281 chip    1.25     CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
282                  CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
283 kumpf   1.29     CIM_DISABLE_MODULE_REQUEST_MESSAGE,
284                  CIM_ENABLE_MODULE_REQUEST_MESSAGE,
285 carolann.graves 1.64     CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE,
286 kumpf           1.35 
287 kumpf           1.43     CIM_GET_CLASS_RESPONSE_MESSAGE,
288 kumpf           1.73     CIM_GET_INSTANCE_RESPONSE_MESSAGE,
289 kumpf           1.75     CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
290 mike            1.5      CIM_DELETE_CLASS_RESPONSE_MESSAGE,
291 kumpf           1.75     CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,  // 40
292 mike            1.5      CIM_CREATE_CLASS_RESPONSE_MESSAGE,
293                          CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
294                          CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
295                          CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
296 carolann.graves 1.64     CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
297 mike            1.5      CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
298 kumpf           1.73     CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
299 kumpf           1.75     CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
300 mike            1.5      CIM_EXEC_QUERY_RESPONSE_MESSAGE,
301 kumpf           1.75     CIM_ASSOCIATORS_RESPONSE_MESSAGE,  // 50
302 mike            1.5      CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
303                          CIM_REFERENCES_RESPONSE_MESSAGE,
304                          CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
305                          CIM_GET_PROPERTY_RESPONSE_MESSAGE,
306 carolann.graves 1.64     CIM_SET_PROPERTY_RESPONSE_MESSAGE,
307 mike            1.5      CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
308 kumpf           1.73     CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
309 kumpf           1.75     CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
310 mike            1.5      CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
311 kumpf           1.75     CIM_INVOKE_METHOD_RESPONSE_MESSAGE,  // 60
312 kumpf           1.15     CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
313 carolann.graves 1.64     CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,
314 kumpf           1.15     CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
315 kumpf           1.73     CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
316 chip            1.25     CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
317 kumpf           1.75     CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
318 chip            1.25     CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
319 kumpf           1.29     CIM_DISABLE_MODULE_RESPONSE_MESSAGE,
320                          CIM_ENABLE_MODULE_RESPONSE_MESSAGE,
321 kumpf           1.75     CIM_STOP_ALL_PROVIDERS_RESPONSE_MESSAGE,  // 70
322 chip            1.24 
323 mike            1.6      // Monitor-related messages:
324                      
325                          SOCKET_MESSAGE,
326                      
327                          // Connection-oriented messages:
328                      
329                          CLOSE_CONNECTION_MESSAGE,
330                      
331                          // HTTP messages:
332                      
333                          HTTP_MESSAGE,
334 kumpf           1.73     HTTP_ERROR_MESSAGE,
335 kumpf           1.28 
336                          // Exception messages to be passed to a CIM client application:
337                      
338                          CLIENT_EXCEPTION_MESSAGE,
339 mike            1.5  
340 kumpf           1.75     ASYNC_REGISTER_CIM_SERVICE,
341 mday            1.33     ASYNC_DEREGISTER_CIM_SERVICE,
342                          ASYNC_UPDATE_CIM_SERVICE,
343                          ASYNC_IOCTL,
344 kumpf           1.75     ASYNC_CIMSERVICE_START,  // 80
345 mday            1.33     ASYNC_CIMSERVICE_STOP,
346                          ASYNC_CIMSERVICE_PAUSE,
347                          ASYNC_CIMSERVICE_RESUME,
348                      
349 kumpf           1.73     ASYNC_ASYNC_OP_START,
350 mday            1.33     ASYNC_ASYNC_OP_RESULT,
351 kumpf           1.75     ASYNC_ASYNC_LEGACY_OP_START,
352 chip            1.34     ASYNC_ASYNC_LEGACY_OP_RESULT,
353                      
354 mday            1.33     ASYNC_FIND_SERVICE_Q,
355                          ASYNC_FIND_SERVICE_Q_RESULT,
356 kumpf           1.75     ASYNC_ENUMERATE_SERVICE,  // 90
357 mday            1.33     ASYNC_ENUMERATE_SERVICE_RESULT,
358 chip            1.34 
359 mday            1.33     ASYNC_REGISTERED_MODULE,
360                          ASYNC_DEREGISTERED_MODULE,
361 kumpf           1.73     ASYNC_FIND_MODULE_IN_SERVICE,
362 mday            1.33     ASYNC_FIND_MODULE_IN_SERVICE_RESPONSE,
363 chip            1.34 
364 kumpf           1.75     ASYNC_ASYNC_MODULE_OP_START,
365 mday            1.33     ASYNC_ASYNC_MODULE_OP_RESULT,
366                      
367 kumpf           1.53     CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE,
368                          CIM_NOTIFY_PROVIDER_ENABLE_RESPONSE_MESSAGE,
369                      
370 kumpf           1.75     CIM_NOTIFY_PROVIDER_FAIL_REQUEST_MESSAGE,  // 100
371 carolann.graves 1.74     CIM_NOTIFY_PROVIDER_FAIL_RESPONSE_MESSAGE,
372                      
373 kumpf           1.53     CIM_INITIALIZE_PROVIDER_REQUEST_MESSAGE,
374 w.white         1.52     CIM_INITIALIZE_PROVIDER_RESPONSE_MESSAGE,
375                      
376 kumpf           1.53     CIM_INITIALIZE_PROVIDER_AGENT_REQUEST_MESSAGE,
377                          CIM_INITIALIZE_PROVIDER_AGENT_RESPONSE_MESSAGE,
378 kumpf           1.47 
379 kumpf           1.54     CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE,
380                          CIM_NOTIFY_CONFIG_CHANGE_RESPONSE_MESSAGE,
381                      
382 carolann.graves 1.64     CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE,
383                          CIM_SUBSCRIPTION_INIT_COMPLETE_RESPONSE_MESSAGE,
384                      
385 mike            1.5      NUMBER_OF_MESSAGES
386                      };
387                      
388                      PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
389 mike            1.6  
390                      /** This class implements a stack of queue-ids. Many messages must keep a
391                          stack of queue-ids of queues which they must be returned to. This provides
392                          a light efficient stack for this purpose.
393                      */
394 karl            1.60 class PEGASUS_COMMON_LINKAGE QueueIdStack
395 mike            1.6  {
396                      public:
397                      
398 chip            1.24     QueueIdStack() : _size(0)
399                          {
400 mike            1.6      }
401                      
402 karl            1.59     QueueIdStack(const QueueIdStack& x);
403 mike            1.6  
404 karl            1.59     PEGASUS_EXPLICIT QueueIdStack(Uint32 x);
405 mike            1.6  
406 karl            1.59     PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2);
407 mike            1.6  
408 chip            1.24     ~QueueIdStack()
409                          {
410 mike            1.6      }
411                      
412 karl            1.59     QueueIdStack& operator=(const QueueIdStack& x);
413 mike            1.6  
414 chip            1.24     Uint32 size() const
415                          {
416 kumpf           1.86         return _size;
417 mike            1.6      }
418                      
419 chip            1.24     Boolean isEmpty() const
420                          {
421 kumpf           1.86         return _size == 0;
422 mike            1.6      }
423                      
424 chip            1.24     void push(Uint32 x)
425 mike            1.6      {
426 karl            1.59 #ifdef PEGASUS_DEBUG
427 kumpf           1.86         if (_size == MAX_SIZE)
428                                  throw StackOverflow();
429 karl            1.59 #endif
430 kumpf           1.86         _items[_size++] = x;
431 mike            1.6      }
432                      
433                          Uint32& top()
434                          {
435 karl            1.59 #ifdef PEGASUS_DEBUG
436 kumpf           1.86         if (_size == 0)
437                                  throw StackUnderflow();
438 karl            1.59 #endif
439 kumpf           1.86         return _items[_size-1];
440 mike            1.6      }
441                      
442 chip            1.24     Uint32 top() const
443 mike            1.6      {
444 kumpf           1.86         return ((QueueIdStack*)this)->top();
445 mike            1.6      }
446                      
447 chip            1.24     void pop()
448 mike            1.6      {
449 karl            1.59 #ifdef PEGASUS_DEBUG
450 kumpf           1.86         if (_size == 0)
451                                  throw StackUnderflow();
452 karl            1.59 #endif
453 kumpf           1.86         _size--;
454 mike            1.6      }
455                      
456                          /** Make a copy of this stack and then pop the top element. */
457 karl            1.59     QueueIdStack copyAndPop() const;
458 mike            1.6  
459                      private:
460                      
461                          // Copy the given stack but then pop the top element:
462 karl            1.59     QueueIdStack(const QueueIdStack& x, int);
463 mike            1.6  
464                          enum { MAX_SIZE = 5 };
465                          Uint32 _items[MAX_SIZE];
466                          Uint32 _size;
467                      };
468 mike            1.4  
469                      PEGASUS_NAMESPACE_END
470                      
471                      #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2