(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 lawrence.luo 1.107 #ifdef PEGASUS_ENABLE_PROTOCOL_WEB
 60                        ,HTTP_METHOD_GET,
 61                        HTTP_METHOD_HEAD
 62                    #endif /* PEGASUS_ENABLE_PROTOCOL_WEB */
 63 kumpf        1.40  };
 64                    
 65 kumpf        1.90  enum MessageType
 66                    {
 67                        DUMMY_MESSAGE,
 68                    
 69                        // CIM Message types:
 70                    
 71                        CIM_GET_CLASS_REQUEST_MESSAGE,
 72                        CIM_GET_INSTANCE_REQUEST_MESSAGE,
 73                        CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
 74                        CIM_DELETE_CLASS_REQUEST_MESSAGE,
 75                        CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
 76                        CIM_CREATE_CLASS_REQUEST_MESSAGE,
 77                        CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
 78                        CIM_MODIFY_CLASS_REQUEST_MESSAGE,
 79                        CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
 80                        CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE, //10
 81                        CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
 82                        CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
 83                        CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
 84                        CIM_EXEC_QUERY_REQUEST_MESSAGE,
 85                        CIM_ASSOCIATORS_REQUEST_MESSAGE,
 86 kumpf        1.90      CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
 87                        CIM_REFERENCES_REQUEST_MESSAGE,
 88                        CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
 89                        CIM_GET_PROPERTY_REQUEST_MESSAGE,
 90                        CIM_SET_PROPERTY_REQUEST_MESSAGE, //20
 91                        CIM_GET_QUALIFIER_REQUEST_MESSAGE,
 92                        CIM_SET_QUALIFIER_REQUEST_MESSAGE,
 93                        CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
 94                        CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
 95                        CIM_INVOKE_METHOD_REQUEST_MESSAGE,
 96                        CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
 97                        CIM_HANDLE_INDICATION_REQUEST_MESSAGE,
 98                        CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
 99                        CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
100                        CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,  // 30
101                        CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
102                        CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
103                        CIM_DISABLE_MODULE_REQUEST_MESSAGE,
104                        CIM_ENABLE_MODULE_REQUEST_MESSAGE,
105                        CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE,
106                    
107 kumpf        1.90      CIM_GET_CLASS_RESPONSE_MESSAGE,
108                        CIM_GET_INSTANCE_RESPONSE_MESSAGE,
109                        CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
110                        CIM_DELETE_CLASS_RESPONSE_MESSAGE,
111                        CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,  // 40
112                        CIM_CREATE_CLASS_RESPONSE_MESSAGE,
113                        CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
114                        CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
115                        CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
116                        CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
117                        CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
118                        CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
119                        CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
120                        CIM_EXEC_QUERY_RESPONSE_MESSAGE,
121                        CIM_ASSOCIATORS_RESPONSE_MESSAGE,  // 50
122                        CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
123                        CIM_REFERENCES_RESPONSE_MESSAGE,
124                        CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
125                        CIM_GET_PROPERTY_RESPONSE_MESSAGE,
126                        CIM_SET_PROPERTY_RESPONSE_MESSAGE,
127                        CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
128 kumpf        1.90      CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
129                        CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
130                        CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
131                        CIM_INVOKE_METHOD_RESPONSE_MESSAGE,  // 60
132                        CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
133                        CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,
134                        CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
135                        CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
136                        CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
137                        CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
138                        CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
139                        CIM_DISABLE_MODULE_RESPONSE_MESSAGE,
140                        CIM_ENABLE_MODULE_RESPONSE_MESSAGE,
141                        CIM_STOP_ALL_PROVIDERS_RESPONSE_MESSAGE,  // 70
142                    
143                        // Monitor-related messages:
144                    
145                        SOCKET_MESSAGE,
146                    
147                        // Connection-oriented messages:
148                    
149 kumpf        1.90      CLOSE_CONNECTION_MESSAGE,
150                    
151                        // HTTP messages:
152                    
153                        HTTP_MESSAGE,
154                        HTTP_ERROR_MESSAGE,
155                    
156                        // Exception messages to be passed to a CIM client application:
157                    
158                        CLIENT_EXCEPTION_MESSAGE,
159                    
160 venkat.puvvada 1.95      ASYNC_IOCLOSE,
161 venkat.puvvada 1.97      ASYNC_CIMSERVICE_START,
162 kumpf          1.90      ASYNC_CIMSERVICE_STOP,
163                      
164                          ASYNC_ASYNC_OP_START,
165 venkat.puvvada 1.97      ASYNC_ASYNC_OP_RESULT, // 80
166 kumpf          1.90      ASYNC_ASYNC_LEGACY_OP_START,
167                          ASYNC_ASYNC_LEGACY_OP_RESULT,
168                      
169                          ASYNC_ASYNC_MODULE_OP_START,
170                          ASYNC_ASYNC_MODULE_OP_RESULT,
171                      
172                          CIM_NOTIFY_PROVIDER_ENABLE_REQUEST_MESSAGE,
173                          CIM_NOTIFY_PROVIDER_ENABLE_RESPONSE_MESSAGE,
174                      
175 venkat.puvvada 1.97      CIM_NOTIFY_PROVIDER_FAIL_REQUEST_MESSAGE,
176 kumpf          1.90      CIM_NOTIFY_PROVIDER_FAIL_RESPONSE_MESSAGE,
177                      
178                          CIM_INITIALIZE_PROVIDER_AGENT_REQUEST_MESSAGE,
179 venkat.puvvada 1.97      CIM_INITIALIZE_PROVIDER_AGENT_RESPONSE_MESSAGE, // 90
180 kumpf          1.90  
181                          CIM_NOTIFY_CONFIG_CHANGE_REQUEST_MESSAGE,
182                          CIM_NOTIFY_CONFIG_CHANGE_RESPONSE_MESSAGE,
183                      
184                          CIM_SUBSCRIPTION_INIT_COMPLETE_REQUEST_MESSAGE,
185                          CIM_SUBSCRIPTION_INIT_COMPLETE_RESPONSE_MESSAGE,
186                      
187 venkat.puvvada 1.100     CIM_INDICATION_SERVICE_DISABLED_REQUEST_MESSAGE,
188                          CIM_INDICATION_SERVICE_DISABLED_RESPONSE_MESSAGE,
189                      
190 thilo.boehm    1.101     PROVAGT_GET_SCMOCLASS_REQUEST_MESSAGE,
191                          PROVAGT_GET_SCMOCLASS_RESPONSE_MESSAGE,
192                      
193 venkat.puvvada 1.102     CIM_NOTIFY_SUBSCRIPTION_NOT_ACTIVE_REQUEST_MESSAGE,
194                          CIM_NOTIFY_SUBSCRIPTION_NOT_ACTIVE_RESPONSE_MESSAGE,
195                      
196                          CIM_NOTIFY_LISTENER_NOT_ACTIVE_REQUEST_MESSAGE,
197                          CIM_NOTIFY_LISTENER_NOT_ACTIVE_RESPONSE_MESSAGE,
198 karl           1.106 
199 anusha.kandepu 1.103     WSMAN_EXPORT_INDICATION_REQUEST_MESSAGE,
200 anusha.kandepu 1.105     WSMAN_EXPORT_INDICATION_RESPONSE_MESSAGE,
201 kumpf          1.90      NUMBER_OF_MESSAGES
202                      };
203                      
204                      PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(MessageType messageType);
205                      
206                      
207 chip           1.24  /** The Message class and derived classes are used to pass messages between
208 mike           1.4       modules. Messages are passed between modules using the message queues
209                          (see MessageQueue class). Derived classes may add their own fields.
210 kumpf          1.78      This base class defines a common type field, which is the type of
211                          the message.
212 mike           1.4   */
213 mike           1.76  class PEGASUS_COMMON_LINKAGE Message : public Linkable
214 mike           1.4   {
215 kumpf          1.86  public:
216                      
217                          Message(
218 kumpf          1.90          MessageType type,
219 kumpf          1.86          Uint32 destination = 0,
220 venkat.puvvada 1.89          Uint32 mask = 0)
221 kumpf          1.86          :
222 kumpf          1.94          dest(destination),
223 kumpf          1.86          _type(type),
224                              _mask(mask),
225 kumpf          1.94          _httpMethod(HTTP_METHOD__POST),
226                              _httpCloseConnect(false),
227 kumpf          1.86          _isComplete(true),
228 kumpf          1.94          _index(0),
229                              _async(0)
230 kumpf          1.86      {
231                          }
232 mike           1.4   
233 kumpf          1.86      virtual ~Message();
234 chip           1.24  
235 kumpf          1.86      // NOTE: The compiler default implementation of the copy constructor
236                          // is used for this class.
237                      
238 kumpf          1.94      Boolean getCloseConnect() const { return _httpCloseConnect; }
239                          void setCloseConnect(Boolean httpCloseConnect)
240 kumpf          1.86      {
241 kumpf          1.94          _httpCloseConnect = httpCloseConnect;
242 kumpf          1.86      }
243 chip           1.24  
244 kumpf          1.90      MessageType getType() const { return _type; }
245 kumpf          1.40  
246 kumpf          1.86      Uint32 getMask() const { return _mask; }
247                      
248                          void setMask(Uint32 mask) { _mask = mask; }
249                      
250                          HttpMethod getHttpMethod() const { return _httpMethod; }
251                      
252                          void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;}
253 kumpf          1.40  
254 kumpf          1.90      static CIMOperationType convertMessageTypetoCIMOpType(MessageType type);
255 w.white        1.63  
256 lawrence.luo   1.104 
257 kumpf          1.86      virtual void print(
258                              PEGASUS_STD(ostream)& os,
259                              Boolean printHeader = true) const;
260 lawrence.luo   1.104 
261 mike           1.4   
262 kumpf          1.86      Message* get_async()
263                          {
264                              Message *ret = _async;
265                              _async = 0;
266                              return ret;
267                          }
268                      
269                          void put_async(Message* msg)
270                          {
271                              _async = msg;
272                          }
273                      
274                          // set the message index indicating what piece (or sequence) this is
275                          // message indexes start at zero
276                          void setIndex(Uint32 index) { _index = index; }
277                      
278 kumpf          1.94      // get the message index (or sequence number)
279                          Uint32 getIndex() const { return _index; }
280 kumpf          1.86  
281 kumpf          1.94      // is this the first piece of the message ?
282                          Boolean isFirst() const { return _index == 0; }
283                      
284                          // set the complete flag indicating whether this message piece is the last
285 kumpf          1.86      void setComplete(Boolean isComplete)
286                          {
287 kumpf          1.94          _isComplete = isComplete;
288 kumpf          1.86      }
289                      
290                          // is this message complete? (i.e the last in a one or more sequence)
291                          Boolean isComplete() const { return _isComplete; }
292                      
293 kumpf          1.94      Uint32 dest;
294                      
295 kumpf          1.86  private:
296 kumpf          1.94  
297                          Message& operator=(const Message& msg);
298                      
299 kumpf          1.90      MessageType _type;
300 kumpf          1.86      Uint32 _mask;
301 kumpf          1.94  
302 kumpf          1.86      HttpMethod _httpMethod;
303 kumpf          1.94      Boolean _httpCloseConnect;
304 kumpf          1.86  
305 kumpf          1.94      Boolean _isComplete;
306                          Uint32 _index;
307 kumpf          1.86  
308 kumpf          1.92      Message* _async;
309 mike           1.4   };
310 mike           1.5   
311 mike           1.6   
312                      /** This class implements a stack of queue-ids. Many messages must keep a
313                          stack of queue-ids of queues which they must be returned to. This provides
314                          a light efficient stack for this purpose.
315                      */
316 karl           1.60  class PEGASUS_COMMON_LINKAGE QueueIdStack
317 mike           1.6   {
318                      public:
319                      
320 chip           1.24      QueueIdStack() : _size(0)
321                          {
322 mike           1.6       }
323                      
324 karl           1.59      QueueIdStack(const QueueIdStack& x);
325 mike           1.6   
326 kumpf          1.88      explicit QueueIdStack(Uint32 x);
327 mike           1.6   
328 kumpf          1.88      explicit QueueIdStack(Uint32 x1, Uint32 x2);
329 mike           1.6   
330 chip           1.24      ~QueueIdStack()
331                          {
332 mike           1.6       }
333                      
334 karl           1.59      QueueIdStack& operator=(const QueueIdStack& x);
335 mike           1.6   
336 chip           1.24      Uint32 size() const
337                          {
338 kumpf          1.86          return _size;
339 mike           1.6       }
340                      
341 chip           1.24      Boolean isEmpty() const
342                          {
343 kumpf          1.86          return _size == 0;
344 mike           1.6       }
345                      
346 chip           1.24      void push(Uint32 x)
347 mike           1.6       {
348 karl           1.59  #ifdef PEGASUS_DEBUG
349 kumpf          1.86          if (_size == MAX_SIZE)
350                                  throw StackOverflow();
351 karl           1.59  #endif
352 kumpf          1.86          _items[_size++] = x;
353 mike           1.6       }
354                      
355                          Uint32& top()
356                          {
357 karl           1.59  #ifdef PEGASUS_DEBUG
358 kumpf          1.86          if (_size == 0)
359                                  throw StackUnderflow();
360 karl           1.59  #endif
361 kumpf          1.86          return _items[_size-1];
362 mike           1.6       }
363                      
364 chip           1.24      Uint32 top() const
365 mike           1.6       {
366 kumpf          1.86          return ((QueueIdStack*)this)->top();
367 mike           1.6       }
368                      
369 chip           1.24      void pop()
370 mike           1.6       {
371 karl           1.59  #ifdef PEGASUS_DEBUG
372 kumpf          1.86          if (_size == 0)
373                                  throw StackUnderflow();
374 karl           1.59  #endif
375 kumpf          1.86          _size--;
376 mike           1.6       }
377                      
378                          /** Make a copy of this stack and then pop the top element. */
379 karl           1.59      QueueIdStack copyAndPop() const;
380 mike           1.6   
381 mike           1.96      Uint32 operator[](Uint32 i) const { return _items[i]; }
382                      
383 mike           1.6   private:
384                      
385                          // Copy the given stack but then pop the top element:
386 karl           1.59      QueueIdStack(const QueueIdStack& x, int);
387 mike           1.6   
388                          enum { MAX_SIZE = 5 };
389                          Uint32 _items[MAX_SIZE];
390                          Uint32 _size;
391                      };
392 mike           1.4   
393                      PEGASUS_NAMESPACE_END
394                      
395                      #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2