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

  1 martin 1.98 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.99 //
  3 martin 1.98 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.99 //
 10 martin 1.98 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.99 //
 17 martin 1.98 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.99 //
 20 martin 1.98 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.99 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.98 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.99 //
 28 martin 1.98 //////////////////////////////////////////////////////////////////////////
 29 mike   1.4  //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_Message_h
 33             #define Pegasus_Message_h
 34             
 35 mike   1.6  #include <Pegasus/Common/Config.h>
 36 mike   1.4  #include <iostream>
 37 mike   1.6  #include <cstring>
 38 kumpf  1.39 #include <Pegasus/Common/InternalException.h>
 39 kumpf  1.38 #include <Pegasus/Common/Linkage.h>
 40 w.white 1.63 #include <Pegasus/Common/CIMOperationType.h>
 41 mike    1.76 #include <Pegasus/Common/Linkable.h>
 42 mike    1.4  
 43              PEGASUS_NAMESPACE_BEGIN
 44              
 45 kumpf   1.83 class PEGASUS_COMMON_LINKAGE MessageMask
 46 mike    1.6  {
 47 kumpf   1.83 public:
 48                  // Message handling is indicated by the high order 12 bits.  For example:
 49                  // Uint32 messageHandling = flags & 0xfff00000;
 50                  static Uint32 ha_request;
 51                  static Uint32 ha_reply;
 52                  static Uint32 ha_async;
 53 mike    1.6  };
 54              
 55 kumpf   1.40 enum HttpMethod
 56              {
 57                  HTTP_METHOD__POST,
 58                  HTTP_METHOD_M_POST
 59              };
 60              
 61 kumpf   1.90 enum MessageType
 62              {
 63                  DUMMY_MESSAGE,
 64              
 65                  // CIM Message types:
 66              
 67                  CIM_GET_CLASS_REQUEST_MESSAGE,
 68                  CIM_GET_INSTANCE_REQUEST_MESSAGE,
 69                  CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
 70                  CIM_DELETE_CLASS_REQUEST_MESSAGE,
 71                  CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
 72                  CIM_CREATE_CLASS_REQUEST_MESSAGE,
 73                  CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
 74                  CIM_MODIFY_CLASS_REQUEST_MESSAGE,
 75                  CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
 76                  CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE, //10
 77                  CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
 78                  CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
 79                  CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
 80                  CIM_EXEC_QUERY_REQUEST_MESSAGE,
 81                  CIM_ASSOCIATORS_REQUEST_MESSAGE,
 82 kumpf   1.90     CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
 83                  CIM_REFERENCES_REQUEST_MESSAGE,
 84                  CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
 85                  CIM_GET_PROPERTY_REQUEST_MESSAGE,
 86                  CIM_SET_PROPERTY_REQUEST_MESSAGE, //20
 87                  CIM_GET_QUALIFIER_REQUEST_MESSAGE,
 88                  CIM_SET_QUALIFIER_REQUEST_MESSAGE,
 89                  CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
 90                  CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
 91                  CIM_INVOKE_METHOD_REQUEST_MESSAGE,
 92                  CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
 93                  CIM_HANDLE_INDICATION_REQUEST_MESSAGE,
 94                  CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
 95                  CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
 96                  CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,  // 30
 97                  CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
 98                  CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
 99                  CIM_DISABLE_MODULE_REQUEST_MESSAGE,
100                  CIM_ENABLE_MODULE_REQUEST_MESSAGE,
101                  CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE,
102              
103 kumpf   1.90     CIM_GET_CLASS_RESPONSE_MESSAGE,
104                  CIM_GET_INSTANCE_RESPONSE_MESSAGE,
105                  CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
106                  CIM_DELETE_CLASS_RESPONSE_MESSAGE,
107                  CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,  // 40
108                  CIM_CREATE_CLASS_RESPONSE_MESSAGE,
109                  CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
110                  CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
111                  CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
112                  CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
113                  CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
114                  CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
115                  CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
116                  CIM_EXEC_QUERY_RESPONSE_MESSAGE,
117                  CIM_ASSOCIATORS_RESPONSE_MESSAGE,  // 50
118                  CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
119                  CIM_REFERENCES_RESPONSE_MESSAGE,
120                  CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
121                  CIM_GET_PROPERTY_RESPONSE_MESSAGE,
122                  CIM_SET_PROPERTY_RESPONSE_MESSAGE,
123                  CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
124 kumpf   1.90     CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
125                  CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
126                  CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
127                  CIM_INVOKE_METHOD_RESPONSE_MESSAGE,  // 60
128                  CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
129                  CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,
130                  CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
131                  CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
132                  CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
133                  CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
134                  CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
135                  CIM_DISABLE_MODULE_RESPONSE_MESSAGE,
136                  CIM_ENABLE_MODULE_RESPONSE_MESSAGE,
137                  CIM_STOP_ALL_PROVIDERS_RESPONSE_MESSAGE,  // 70
138              
139                  // Monitor-related messages:
140              
141                  SOCKET_MESSAGE,
142              
143                  // Connection-oriented messages:
144              
145 kumpf   1.90     CLOSE_CONNECTION_MESSAGE,
146              
147                  // HTTP messages:
148              
149                  HTTP_MESSAGE,
150                  HTTP_ERROR_MESSAGE,
151              
152                  // Exception messages to be passed to a CIM client application:
153              
154                  CLIENT_EXCEPTION_MESSAGE,
155              
156 venkat.puvvada 1.95     ASYNC_IOCLOSE,
157 venkat.puvvada 1.97     ASYNC_CIMSERVICE_START,
158 kumpf          1.90     ASYNC_CIMSERVICE_STOP,
159                     
160                         ASYNC_ASYNC_OP_START,
161 venkat.puvvada 1.97     ASYNC_ASYNC_OP_RESULT, // 80
162 kumpf          1.90     ASYNC_ASYNC_LEGACY_OP_START,
163                         ASYNC_ASYNC_LEGACY_OP_RESULT,
164                     
165                         ASYNC_ASYNC_MODULE_OP_START,
166                         ASYNC_ASYNC_MODULE_OP_RESULT,
167                     
168                         CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE,
169                         CIM_NOTIFY_PROVIDER_ENABLE_RESPONSE_MESSAGE,
170                     
171 venkat.puvvada 1.97     CIM_NOTIFY_PROVIDER_FAIL_REQUEST_MESSAGE,
172 kumpf          1.90     CIM_NOTIFY_PROVIDER_FAIL_RESPONSE_MESSAGE,
173                     
174                         CIM_INITIALIZE_PROVIDER_AGENT_REQUEST_MESSAGE,
175 venkat.puvvada 1.97     CIM_INITIALIZE_PROVIDER_AGENT_RESPONSE_MESSAGE, // 90
176 kumpf          1.90 
177                         CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE,
178                         CIM_NOTIFY_CONFIG_CHANGE_RESPONSE_MESSAGE,
179                     
180                         CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE,
181                         CIM_SUBSCRIPTION_INIT_COMPLETE_RESPONSE_MESSAGE,
182                     
183 venkat.puvvada 1.100     CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE,
184                          CIM_INDICATION_SERVICE_DISABLED_RESPONSE_MESSAGE,
185                      
186 thilo.boehm    1.101     PROVAGT_GET_SCMOCLASS_REQUEST_MESSAGE,
187                          PROVAGT_GET_SCMOCLASS_RESPONSE_MESSAGE,
188                      
189 venkat.puvvada 1.102     CIM_NOTIFY_SUBSCRIPTION_NOT_ACTIVE_REQUEST_MESSAGE,
190                          CIM_NOTIFY_SUBSCRIPTION_NOT_ACTIVE_RESPONSE_MESSAGE,
191                      
192                          CIM_NOTIFY_LISTENER_NOT_ACTIVE_REQUEST_MESSAGE,
193                          CIM_NOTIFY_LISTENER_NOT_ACTIVE_RESPONSE_MESSAGE,
194 anusha.kandepu 1.103   
195                          WSMAN_EXPORT_INDICATION_REQUEST_MESSAGE,
196 anusha.kandepu 1.105     WSMAN_EXPORT_INDICATION_RESPONSE_MESSAGE,
197 kumpf          1.90      NUMBER_OF_MESSAGES
198                      };
199                      
200                      PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(MessageType messageType);
201                      
202                      
203 chip           1.24  /** The Message class and derived classes are used to pass messages between
204 mike           1.4       modules. Messages are passed between modules using the message queues
205                          (see MessageQueue class). Derived classes may add their own fields.
206 kumpf          1.78      This base class defines a common type field, which is the type of
207                          the message.
208 mike           1.4   */
209 mike           1.76  class PEGASUS_COMMON_LINKAGE Message : public Linkable
210 mike           1.4   {
211 kumpf          1.86  public:
212                      
213                          Message(
214 kumpf          1.90          MessageType type,
215 kumpf          1.86          Uint32 destination = 0,
216 venkat.puvvada 1.89          Uint32 mask = 0)
217 kumpf          1.86          :
218 kumpf          1.94          dest(destination),
219 kumpf          1.86          _type(type),
220                              _mask(mask),
221 kumpf          1.94          _httpMethod(HTTP_METHOD__POST),
222                              _httpCloseConnect(false),
223 kumpf          1.86          _isComplete(true),
224 kumpf          1.94          _index(0),
225                              _async(0)
226 kumpf          1.86      {
227                          }
228 mike           1.4   
229 kumpf          1.86      virtual ~Message();
230 chip           1.24  
231 kumpf          1.86      // NOTE: The compiler default implementation of the copy constructor
232                          // is used for this class.
233                      
234 kumpf          1.94      Boolean getCloseConnect() const { return _httpCloseConnect; }
235                          void setCloseConnect(Boolean httpCloseConnect)
236 kumpf          1.86      {
237 kumpf          1.94          _httpCloseConnect = httpCloseConnect;
238 kumpf          1.86      }
239 chip           1.24  
240 kumpf          1.90      MessageType getType() const { return _type; }
241 kumpf          1.40  
242 kumpf          1.86      Uint32 getMask() const { return _mask; }
243                      
244                          void setMask(Uint32 mask) { _mask = mask; }
245                      
246                          HttpMethod getHttpMethod() const { return _httpMethod; }
247                      
248                          void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;}
249 kumpf          1.40  
250 kumpf          1.90      static CIMOperationType convertMessageTypetoCIMOpType(MessageType type);
251 w.white        1.63  
252 lawrence.luo   1.104 
253 kumpf          1.86      virtual void print(
254                              PEGASUS_STD(ostream)& os,
255                              Boolean printHeader = true) const;
256 lawrence.luo   1.104 
257 mike           1.4   
258 kumpf          1.86      Message* get_async()
259                          {
260                              Message *ret = _async;
261                              _async = 0;
262                              return ret;
263                          }
264                      
265                          void put_async(Message* msg)
266                          {
267                              _async = msg;
268                          }
269                      
270                          // set the message index indicating what piece (or sequence) this is
271                          // message indexes start at zero
272                          void setIndex(Uint32 index) { _index = index; }
273                      
274 kumpf          1.94      // get the message index (or sequence number)
275                          Uint32 getIndex() const { return _index; }
276 kumpf          1.86  
277 kumpf          1.94      // is this the first piece of the message ?
278                          Boolean isFirst() const { return _index == 0; }
279                      
280                          // set the complete flag indicating whether this message piece is the last
281 kumpf          1.86      void setComplete(Boolean isComplete)
282                          {
283 kumpf          1.94          _isComplete = isComplete;
284 kumpf          1.86      }
285                      
286                          // is this message complete? (i.e the last in a one or more sequence)
287                          Boolean isComplete() const { return _isComplete; }
288                      
289 kumpf          1.94      Uint32 dest;
290                      
291 kumpf          1.86  private:
292 kumpf          1.94  
293                          Message& operator=(const Message& msg);
294                      
295 kumpf          1.90      MessageType _type;
296 kumpf          1.86      Uint32 _mask;
297 kumpf          1.94  
298 kumpf          1.86      HttpMethod _httpMethod;
299 kumpf          1.94      Boolean _httpCloseConnect;
300 kumpf          1.86  
301 kumpf          1.94      Boolean _isComplete;
302                          Uint32 _index;
303 kumpf          1.86  
304 kumpf          1.92      Message* _async;
305 mike           1.4   };
306 mike           1.5   
307 mike           1.6   
308                      /** This class implements a stack of queue-ids. Many messages must keep a
309                          stack of queue-ids of queues which they must be returned to. This provides
310                          a light efficient stack for this purpose.
311                      */
312 karl           1.60  class PEGASUS_COMMON_LINKAGE QueueIdStack
313 mike           1.6   {
314                      public:
315                      
316 chip           1.24      QueueIdStack() : _size(0)
317                          {
318 mike           1.6       }
319                      
320 karl           1.59      QueueIdStack(const QueueIdStack& x);
321 mike           1.6   
322 kumpf          1.88      explicit QueueIdStack(Uint32 x);
323 mike           1.6   
324 kumpf          1.88      explicit QueueIdStack(Uint32 x1, Uint32 x2);
325 mike           1.6   
326 chip           1.24      ~QueueIdStack()
327                          {
328 mike           1.6       }
329                      
330 karl           1.59      QueueIdStack& operator=(const QueueIdStack& x);
331 mike           1.6   
332 chip           1.24      Uint32 size() const
333                          {
334 kumpf          1.86          return _size;
335 mike           1.6       }
336                      
337 chip           1.24      Boolean isEmpty() const
338                          {
339 kumpf          1.86          return _size == 0;
340 mike           1.6       }
341                      
342 chip           1.24      void push(Uint32 x)
343 mike           1.6       {
344 karl           1.59  #ifdef PEGASUS_DEBUG
345 kumpf          1.86          if (_size == MAX_SIZE)
346                                  throw StackOverflow();
347 karl           1.59  #endif
348 kumpf          1.86          _items[_size++] = x;
349 mike           1.6       }
350                      
351                          Uint32& top()
352                          {
353 karl           1.59  #ifdef PEGASUS_DEBUG
354 kumpf          1.86          if (_size == 0)
355                                  throw StackUnderflow();
356 karl           1.59  #endif
357 kumpf          1.86          return _items[_size-1];
358 mike           1.6       }
359                      
360 chip           1.24      Uint32 top() const
361 mike           1.6       {
362 kumpf          1.86          return ((QueueIdStack*)this)->top();
363 mike           1.6       }
364                      
365 chip           1.24      void pop()
366 mike           1.6       {
367 karl           1.59  #ifdef PEGASUS_DEBUG
368 kumpf          1.86          if (_size == 0)
369                                  throw StackUnderflow();
370 karl           1.59  #endif
371 kumpf          1.86          _size--;
372 mike           1.6       }
373                      
374                          /** Make a copy of this stack and then pop the top element. */
375 karl           1.59      QueueIdStack copyAndPop() const;
376 mike           1.6   
377 mike           1.96      Uint32 operator[](Uint32 i) const { return _items[i]; }
378                      
379 mike           1.6   private:
380                      
381                          // Copy the given stack but then pop the top element:
382 karl           1.59      QueueIdStack(const QueueIdStack& x, int);
383 mike           1.6   
384                          enum { MAX_SIZE = 5 };
385                          Uint32 _items[MAX_SIZE];
386                          Uint32 _size;
387                      };
388 mike           1.4   
389                      PEGASUS_NAMESPACE_END
390                      
391                      #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2