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

  1 mday  1.5.2.9 //%///-*-c++-*-/////////////////////////////////////////////////////////////////
  2 mike  1.4     //
  3 kumpf 1.5.2.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 kumpf 1.5.2.6 // Modified By: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 27 kumpf 1.5.2.8 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company 
 28               //              (carolann_graves@hp.com)
 29 mike  1.4     //
 30               //%/////////////////////////////////////////////////////////////////////////////
 31               
 32               #ifndef Pegasus_Message_h
 33               #define Pegasus_Message_h
 34               
 35 sage  1.5.2.12 #include <Pegasus/Common/Config.h>
 36 mike  1.4      #include <iostream>
 37 mike  1.5.2.5  #include <cstring>
 38                #include <Pegasus/Common/Exception.h>
 39 mday  1.5.2.11 #include <Pegasus/Common/IPC.h>
 40 mike  1.4      
 41                PEGASUS_NAMESPACE_BEGIN
 42                
 43 mike  1.5.2.13 class PEGASUS_COMMON_LINKAGE message_mask 
 44 mday  1.5.2.10 {
 45 mday  1.5.2.15    public:
 46                      static Uint32 type_legacy;
 47                      static Uint32 type_CIMClass;
 48                      static Uint32 type_CIMInstance;
 49                      static Uint32 type_CIMIndication;
 50                      static Uint32 type_CIMQualifier;
 51                      static Uint32 type_CIMSubscription;
 52                      static Uint32 type_socket;
 53                      static Uint32 type_connection;
 54                      static Uint32 type_http;
 55                      static Uint32 type_cimom;
 56                      
 57                      static Uint32 no_delete;
 58                      
 59                      static Uint32 type_request;
 60                      static Uint32 type_reply;
 61                      static Uint32 type_control;
 62 mike  1.5.2.13 
 63 mday  1.5.2.15 // more for documentation than for use 
 64                      inline Uint32 get_classification(Uint32 flags)
 65                      {
 66                	 return (flags & 0x000fffff);
 67                      }
 68                
 69                      inline Uint32 get_handling(Uint32 flags)
 70                      {
 71                	 return( flags & 0xfff00000);
 72                      }
 73 mday  1.5.2.10 };
 74                
 75 mike  1.4      class MessageQueue;
 76                
 77                /** The Message class and derived classes are used to pass messages between 
 78                    modules. Messages are passed between modules using the message queues
 79                    (see MessageQueue class). Derived classes may add their own fields.
 80                    This base class defines two common fields: type, which is the type of
 81                    the message, and key which is a key value whose meaning is defined by
 82                    the derived class. The MessageQueue class provides methods for finding
 83                    messages by both type and key.
 84                
 85                    The Message class also provides previous and next pointers which are
 86                    used to place the messages on a queue by the MessageQueue class.
 87                */
 88 mike  1.5      class PEGASUS_COMMON_LINKAGE Message
 89 mike  1.4      {
 90                public:
 91                
 92 mike  1.5.2.13     Message(
 93                	Uint32 type, 
 94                	Uint32 key = getNextKey(), 
 95                	Uint32 mask = message_mask::type_legacy) 
 96                	: 
 97                	_type(type), 
 98                	_key(key), 
 99                	_mask(mask), 
100                	_next(0), 
101                	_prev(0) 
102                    { 
103 mday  1.5.2.10 
104 mike  1.5.2.13     }
105 mike  1.4      
106                    virtual ~Message(); 
107                
108                    Uint32 getType() const { return _type; }
109                
110                    void setType(Uint32 type) { _type = type; }
111                
112                    Uint32 getKey() const { return _key; }
113                
114                    void setKey(Uint32 key) { _key = key; }
115                
116 mday  1.5.2.14       Uint32 getMask() const 
117                      {
118                	 return _mask;
119                      }
120                      
121                      void setMask(Uint32 mask) 
122                      {
123                	 _mask = mask;
124                      }
125                      
126                
127 mike  1.4          Message* getNext() { return _next; }
128                
129                    const Message* getNext() const { return _next; }
130                
131                    Message* getPrevious() { return _prev; }
132                
133                    const Message* getPrevious() const { return _prev; }
134                
135 mday  1.5.2.11     static Uint32 getNextKey() 
136                      { 
137                	 
138                	 _mut.lock( pegasus_thread_self() ) ; 
139                	 Uint32 ret = _nextKey++;
140                	 _mut.unlock();
141                	 return ret;
142                      }
143                      
144 mike  1.5          virtual void print(PEGASUS_STD(ostream)& os) const;
145 mike  1.4      
146                private:
147 mday  1.5.2.10       Uint32 _type;
148                      Uint32 _key;
149                      Uint32 _mask;
150                      Message* _next;
151                      Message* _prev;
152                      MessageQueue* _owner;
153                      static Uint32 _nextKey;
154 mday  1.5.2.11       static Mutex _mut;
155 mday  1.5.2.10       friend class MessageQueue;
156 mike  1.4      };
157 mday  1.5.2.9  
158                
159                // each component needs to support a set of these messgaes and pass that array
160                // to the dispatcher so the dispatcher can route messages at the first level
161                // i.e., client will not accept request messages.
162                // every message should have a response
163                
164                // dispatcher supports full cim api set (as below)
165                // repository needs to be a peer to the provider manager
166                // 
167                
168                // mkdir _dispatcher
169                // mkdir _providermanager
170                // mkdir _server (http incoming, front end)
171                // mkdir _repositorymanager
172                //       _subscriptionprocessor
173                //       _indicationprocessor
174                //       _configurationmanager 
175                //       _cimom (loads and links everyone, hooks up queues)
176                
177                // fundamental messages:
178 mday  1.5.2.9  
179                // start, stop, pause, resume
180                // handshaking: interrogate (as in windows service api)
181                //              message class support
182                //              message namespace support ???
183 mike  1.5      
184                enum MessageType
185                {
186                    DUMMY_MESSAGE,
187                
188                    // CIM Message types:
189                
190                    CIM_GET_CLASS_REQUEST_MESSAGE,
191                    CIM_GET_INSTANCE_REQUEST_MESSAGE,
192 kumpf 1.5.2.6      CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
193 mike  1.5          CIM_DELETE_CLASS_REQUEST_MESSAGE,
194                    CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
195                    CIM_CREATE_CLASS_REQUEST_MESSAGE,
196                    CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
197                    CIM_MODIFY_CLASS_REQUEST_MESSAGE,
198                    CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
199                    CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE,
200                    CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
201                    CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
202                    CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
203                    CIM_EXEC_QUERY_REQUEST_MESSAGE,
204                    CIM_ASSOCIATORS_REQUEST_MESSAGE,
205                    CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
206                    CIM_REFERENCES_REQUEST_MESSAGE,
207                    CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
208                    CIM_GET_PROPERTY_REQUEST_MESSAGE,
209                    CIM_SET_PROPERTY_REQUEST_MESSAGE,
210                    CIM_GET_QUALIFIER_REQUEST_MESSAGE,
211                    CIM_SET_QUALIFIER_REQUEST_MESSAGE,
212                    CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
213                    CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
214 mike  1.5          CIM_INVOKE_METHOD_REQUEST_MESSAGE,
215 kumpf 1.5.2.8      CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
216                    CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
217                    CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
218 mike  1.5          CIM_GET_CLASS_RESPONSE_MESSAGE,
219                    CIM_GET_INSTANCE_RESPONSE_MESSAGE,
220 kumpf 1.5.2.6      CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
221 mike  1.5          CIM_DELETE_CLASS_RESPONSE_MESSAGE,
222                    CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,
223                    CIM_CREATE_CLASS_RESPONSE_MESSAGE,
224                    CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
225                    CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
226                    CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
227                    CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,
228                    CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
229                    CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
230                    CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
231                    CIM_EXEC_QUERY_RESPONSE_MESSAGE,
232                    CIM_ASSOCIATORS_RESPONSE_MESSAGE,
233                    CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
234                    CIM_REFERENCES_RESPONSE_MESSAGE,
235                    CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
236                    CIM_GET_PROPERTY_RESPONSE_MESSAGE,
237                    CIM_SET_PROPERTY_RESPONSE_MESSAGE,
238                    CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
239                    CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
240                    CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
241                    CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
242 mike  1.5          CIM_INVOKE_METHOD_RESPONSE_MESSAGE,
243 kumpf 1.5.2.8      CIM_ENABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
244                    CIM_MODIFY_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
245                    CIM_DISABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
246 mike  1.5      
247 mike  1.5.2.2      // Monitor-related messages:
248 mike  1.5.2.1  
249                    SOCKET_MESSAGE,
250 mike  1.5.2.2  
251                    // Connection-oriented messages:
252                
253                    CLOSE_CONNECTION_MESSAGE,
254 mike  1.5.2.4  
255                    // HTTP messages:
256                
257 mike  1.5.2.3      HTTP_MESSAGE,
258 mike  1.5.2.1  
259 mike  1.5          NUMBER_OF_MESSAGES
260                };
261                
262                PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
263 mike  1.5.2.5  
264                /** This class implements a stack of queue-ids. Many messages must keep a
265                    stack of queue-ids of queues which they must be returned to. This provides
266                    a light efficient stack for this purpose.
267                */
268                class QueueIdStack
269                {
270                public:
271                
272                    QueueIdStack() : _size(0) 
273                    { 
274                    }
275                
276                    QueueIdStack(const QueueIdStack& x) : _size(x._size) 
277                    {
278                	memcpy(_items, x._items, sizeof(_items));
279                    }
280                
281                    PEGASUS_EXPLICIT QueueIdStack(Uint32 x) : _size(0) 
282                    { 
283                	push(x); 
284 mike  1.5.2.5      }
285                
286                    PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2) : _size(0) 
287                    {
288                	push(x1); 
289                	push(x2); 
290                    }
291                
292                    ~QueueIdStack() 
293                    { 
294                    }
295                
296                    QueueIdStack& operator=(const QueueIdStack& x) 
297                    {
298                	if (this != &x)
299                	{
300                	    memcpy(_items, x._items, sizeof(_items));
301                	    _size = x._size;
302                	}
303                	return *this;
304                    }
305 mike  1.5.2.5  
306                    Uint32 size() const 
307                    { 
308                	return _size; 
309                    }
310                
311                    Boolean isEmpty() const 
312                    { 
313                	return _size == 0; 
314                    }
315                
316                    void push(Uint32 x) 
317                    {
318                	if (_size == MAX_SIZE)
319                	    throw StackOverflow();
320                
321                	_items[_size++] = x;
322                    }
323                
324                    Uint32& top()
325                    {
326 mike  1.5.2.5  	if (_size == 0)
327                	    throw StackUnderflow();
328                
329                	return _items[_size-1];
330                    }
331                
332                    Uint32 top() const 
333                    {
334                	return ((QueueIdStack*)this)->top(); 
335                    }
336                
337                    void pop() 
338                    {
339                	if (_size == 0)
340                	    throw StackUnderflow();
341                
342                	_size--;
343                    }
344                
345                    /** Make a copy of this stack and then pop the top element. */
346                    QueueIdStack copyAndPop() const
347 mike  1.5.2.5      {
348                	return QueueIdStack(*this, 0);
349                    }
350                
351                private:
352                
353                    // Copy the given stack but then pop the top element:
354                    QueueIdStack(const QueueIdStack& x, int) : _size(x._size) 
355                    {
356                	memcpy(_items, x._items, sizeof(_items));
357                	pop();
358                    }
359                
360                    enum { MAX_SIZE = 5 };
361                    Uint32 _items[MAX_SIZE];
362                    Uint32 _size;
363                };
364 mike  1.4      
365                PEGASUS_NAMESPACE_END
366                
367                #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2