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

  1 mday  1.43.6.1 //%///////////////////-*-c++-*-/////////////////////////////////////////////////
  2 mike  1.4      //
  3 kumpf 1.37     // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
  4 mike  1.6      // 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 kumpf 1.37     // 
 13 chip  1.24     // 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 kumpf 1.27     //              Carol Ann Krug Graves, Hewlett-Packard Company
 28                //                  (carolann_graves@hp.com)
 29                //              Mike Day (mdday@us.ibm.com)
 30                //              Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 31 sage  1.30     //              Arthur Pichlkostner (via Markus: sedgewick_de@yahoo.de)
 32 mike  1.4      //
 33                //%/////////////////////////////////////////////////////////////////////////////
 34                
 35                #ifndef Pegasus_Message_h
 36                #define Pegasus_Message_h
 37                
 38 mike  1.6      #include <Pegasus/Common/Config.h>
 39 mike  1.4      #include <iostream>
 40 mike  1.6      #include <cstring>
 41 kumpf 1.39     #include <Pegasus/Common/InternalException.h>
 42 mike  1.6      #include <Pegasus/Common/IPC.h>
 43 sage  1.30     #include <Pegasus/Common/StatisticalData.h>
 44 mday  1.43.6.4 #include <Pegasus/Common/pegasus_socket.h>
 45 kumpf 1.38     #include <Pegasus/Common/Linkage.h>
 46 mike  1.4      
 47                PEGASUS_NAMESPACE_BEGIN
 48                
 49 mday  1.18     // REVIEW: could class be renamed to MessageMask (coding standard)
 50 mike  1.11     
 51 chip  1.24     class PEGASUS_COMMON_LINKAGE message_mask
 52 mike  1.6      {
 53                   public:
 54 mike  1.11     
 55 mike  1.6            static Uint32 type_legacy;
 56 mday  1.9            static Uint32 type_CIMOperation;
 57                      static Uint32 type_CIMAsyncOperation;
 58                      static Uint32 type_export;
 59                      static Uint32 type_lifetime;
 60 mike  1.6            static Uint32 type_socket;
 61                      static Uint32 type_connection;
 62                      static Uint32 type_http;
 63 kumpf 1.27           static Uint32 type_http_error;
 64 mike  1.6            static Uint32 type_cimom;
 65 mday  1.9            static Uint32 type_control;
 66                      static Uint32 type_service;
 67                      static Uint32 type_broadcast;
 68 kumpf 1.28           static Uint32 type_client_exception;
 69 chip  1.24     
 70 mday  1.9            static Uint32 ha_no_delete;
 71                      static Uint32 ha_request;
 72                      static Uint32 ha_reply;
 73 mday  1.10           static Uint32 ha_synchronous;
 74 mday  1.13           static Uint32 ha_async;
 75 mday  1.22           static Uint32 ha_wait;
 76 chip  1.24     
 77                
 78                      // more for documentation than for use
 79 mike  1.7      
 80 mday  1.9            inline Uint32 get_type(Uint32 flags)
 81 mike  1.6            {
 82                	 return (flags & 0x000fffff);
 83                      }
 84                
 85                      inline Uint32 get_handling(Uint32 flags)
 86                      {
 87                	 return( flags & 0xfff00000);
 88                      }
 89                };
 90                
 91 mday  1.20     class cimom;
 92 mike  1.4      class MessageQueue;
 93 mday  1.19     class MessageQueueService;
 94                class AsyncLegacyOperationStart;
 95                class AsyncLegacyOperationResult;
 96 mike  1.4      
 97 kumpf 1.40     enum HttpMethod
 98                {
 99                    HTTP_METHOD__POST,
100                    HTTP_METHOD_M_POST
101                };
102                
103 chip  1.24     /** The Message class and derived classes are used to pass messages between
104 mike  1.4          modules. Messages are passed between modules using the message queues
105                    (see MessageQueue class). Derived classes may add their own fields.
106                    This base class defines two common fields: type, which is the type of
107                    the message, and key which is a key value whose meaning is defined by
108                    the derived class. The MessageQueue class provides methods for finding
109                    messages by both type and key.
110                
111                    The Message class also provides previous and next pointers which are
112                    used to place the messages on a queue by the MessageQueue class.
113                */
114 mike  1.5      class PEGASUS_COMMON_LINKAGE Message
115 mike  1.4      {
116 mday  1.8         public:
117 mike  1.4      
118 mday  1.8            Message(
119 mday  1.20     	 Uint32 type,
120                	 Uint32 destination = 0,
121 chip  1.24     	 Uint32 key = getNextKey(),
122 mday  1.8      	 Uint32 routing_code = 0,
123 chip  1.24     	 Uint32 mask = message_mask::type_legacy )
124                	 :
125                	 _type(type),
126                	 _key(key),
127                	 _routing_code(routing_code),
128 mday  1.8      	 _mask(mask),
129 mday  1.43.6.1 	_last_thread_id(pegasus_thread_self()),
130 chip  1.24     	 _next(0),
131 mday  1.19     	 _prev(0),
132 mday  1.20     	 _async(0),
133                	 dest(destination)
134 chip  1.24           {
135 mday  1.8      
136                      }
137 mike  1.6      
138 mday  1.32           Message & operator = ( const Message & msg)
139                      {
140                	 if (this != &msg)
141                	 {
142                	    _type = msg._type;
143                	    _key = msg._key;
144                	    _routing_code = msg._routing_code;
145                	    _mask = msg._mask;
146 mday  1.43.6.1 	    _last_thread_id = msg._last_thread_id;
147 mday  1.32     	    _next = _prev = _async = 0;
148                	    dest = msg.dest;
149 kumpf 1.41                 _httpMethod = msg._httpMethod;
150 mday  1.43.6.3 	    _socket = msg._socket;
151                	    
152 mday  1.32     	 }
153                	 return *this;
154                      }
155 chip  1.34     
156 chip  1.24     
157                      virtual ~Message();
158 mike  1.4      
159 mday  1.8            Uint32 getType() const { return _type; }
160 mike  1.4      
161 mday  1.8            void setType(Uint32 type) { _type = type; }
162 mike  1.4      
163 mday  1.8            Uint32 getKey() const { return _key; }
164 mike  1.4      
165 mday  1.8            void setKey(Uint32 key) { _key = key; }
166 mike  1.4      
167 mday  1.8            Uint32 getRouting() const { return _routing_code; }
168                      void setRouting(Uint32 routing) { _routing_code = routing; }
169 mike  1.4      
170 mday  1.8            Uint32 getMask() const { return _mask; }
171 chip  1.24     
172 mday  1.8            void setMask(Uint32 mask) { _mask = mask; }
173 chip  1.24     
174 kumpf 1.40           HttpMethod getHttpMethod() const { return _httpMethod; }
175                
176                      void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;}
177                
178 sage  1.31     #ifdef PEGASUS_HAS_PERFINST
179 sage  1.30     //
180                // Needed for performance measurement
181                //
182                
183                      void startServer();
184                
185                      void endServer();
186                
187                      void startProvider();
188                
189                      void endProvider();
190                
191                      timeval getStartServerTime() const { return _timeServerStart; }
192                
193                      void setStartServerTime(timeval timeServerStart)
194                      {
195                           _timeServerStart = timeServerStart;
196                      }
197                
198                      timeval getStartProviderTime() const { return _timeProviderStart; }
199                
200 sage  1.30           void setStartProviderTime(timeval timeProviderStart)
201                      {
202                          _timeProviderStart = timeProviderStart;
203                      }
204                
205                      timeval getEndServerTime() const { return _timeServerEnd; }
206                
207                      void setEndServerTime (timeval timeServerEnd)
208                      {
209                          _timeServerEnd = timeServerEnd;
210                      }
211                
212                      timeval getEndProviderTime() const { return _timeProviderEnd; }
213                
214                      void setEndProviderTime(timeval timeProviderEnd)
215                      {
216                          _timeProviderEnd = timeProviderEnd;
217                      }
218                
219                      Uint32 getTotalTime() { return _totalTime; }
220                //
221 sage  1.31     #endif
222 sage  1.30     
223 mday  1.8            Message* getNext() { return _next; }
224 mike  1.4      
225 mday  1.8            const Message* getNext() const { return _next; }
226 mike  1.4      
227 mday  1.8            Message* getPrevious() { return _prev; }
228 mike  1.4      
229 mday  1.8            const Message* getPrevious() const { return _prev; }
230 mike  1.4      
231 chip  1.24           static Uint32 getNextKey()
232                      {
233                	
234                	 _mut.lock( pegasus_thread_self() ) ;
235 mike  1.6      	 Uint32 ret = _nextKey++;
236                	 _mut.unlock();
237                	 return ret;
238                      }
239 chip  1.24     
240 mike  1.36           virtual void print(
241                	  PEGASUS_STD(ostream)& os, 
242                	  Boolean printHeader = true) const;
243 mike  1.4      
244 chip  1.24           // << Thu Dec 27 10:46:04 2001 mdd >> for use with DQueue container
245                      // as used by AsyncOpNode
246 kumpf 1.23           Boolean operator == (const void *msg )
247 mday  1.13           {
248 mday  1.16     	 if (reinterpret_cast<void *>(this) == msg )
249 mday  1.13     	    return true;
250                	 return false;
251                      }
252 chip  1.24     
253 mday  1.22           Message *get_async(void)
254                      {
255                	 Message *ret = _async;
256                	 _async = 0;
257                	 return ret;
258 chip  1.24     	
259 mday  1.22           }
260 chip  1.24     
261 mday  1.22           void put_async(Message * msg)
262                      {
263                	 _async = msg;
264                      }
265 chip  1.24     
266 mday  1.43.6.1       // << Tue Jul  1 11:02:49 2003 mdd >> pep_88 and helper for i18n and l10n
267                      Boolean thread_changed(void)
268                      {
269                	 if(_last_thread_id != pegasus_thread_self())
270                	 {
271                	    _last_thread_id = pegasus_thread_self();
272                	    return true;
273                	 }
274                
275                	 return false;
276                      }
277                      
278                      // << Tue Jul  1 13:41:02 2003 mdd >> pep_88 - 
279                      // assist in synchronizing responses with requests
280                
281                      void synch_response(Message *req)
282                      {
283                	 _key = req->_key;
284                	 _routing_code = req->_routing_code;
285 mday  1.43.6.3 	 _socket = req->_socket;
286 mday  1.43.6.1       }
287                      
288 chip  1.24     
289 mday  1.8         private:
290 mike  1.6            Uint32 _type;
291                      Uint32 _key;
292 mday  1.8            Uint32 _routing_code;
293 mike  1.6            Uint32 _mask;
294 kumpf 1.40           HttpMethod _httpMethod;
295 sage  1.30     // Needed for performance measurement
296                      timeval _timeServerStart;
297                      timeval _timeServerEnd;
298                      timeval _timeProviderStart;
299                      timeval _timeProviderEnd;
300                      Uint64 _totalTime;
301                //
302 mday  1.43.6.1 
303                      // << Tue Jul  1 11:02:35 2003 mdd >> pep_88 and helper for i18n and l10n
304                      PEGASUS_THREAD_TYPE _last_thread_id;
305                      
306 mike  1.6            Message* _next;
307                      Message* _prev;
308 mday  1.32     
309 mday  1.19        protected:
310 mday  1.32     
311                   public:
312 mday  1.19           Message *_async;
313 mday  1.20           Uint32 dest;
314 mday  1.19        private:
315 mike  1.6            MessageQueue* _owner;
316                      static Uint32 _nextKey;
317                      static Mutex _mut;
318 mday  1.43.6.2 
319                
320                      pegasus_socket _socket;
321                
322 mday  1.20           friend class cimom;
323 mike  1.6            friend class MessageQueue;
324 mday  1.19           friend class MessageQueueService;
325                      friend class AsyncLegacyOperationStart;
326                      friend class AsyncLegacyOperationResult;
327 chip  1.24     
328 mike  1.4      };
329 mike  1.5      
330 mike  1.6      
331 mike  1.5      enum MessageType
332                {
333                    DUMMY_MESSAGE,
334                
335                    // CIM Message types:
336                
337                    CIM_GET_CLASS_REQUEST_MESSAGE,
338                    CIM_GET_INSTANCE_REQUEST_MESSAGE,
339 mike  1.6          CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
340 mike  1.5          CIM_DELETE_CLASS_REQUEST_MESSAGE,
341                    CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
342                    CIM_CREATE_CLASS_REQUEST_MESSAGE,
343                    CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
344                    CIM_MODIFY_CLASS_REQUEST_MESSAGE,
345                    CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
346 mday  1.32         CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE, //10
347 mike  1.5          CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
348                    CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
349                    CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
350                    CIM_EXEC_QUERY_REQUEST_MESSAGE,
351                    CIM_ASSOCIATORS_REQUEST_MESSAGE,
352                    CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
353                    CIM_REFERENCES_REQUEST_MESSAGE,
354                    CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
355                    CIM_GET_PROPERTY_REQUEST_MESSAGE,
356 mday  1.32         CIM_SET_PROPERTY_REQUEST_MESSAGE, //20
357 mike  1.5          CIM_GET_QUALIFIER_REQUEST_MESSAGE,
358                    CIM_SET_QUALIFIER_REQUEST_MESSAGE,
359                    CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
360                    CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
361                    CIM_INVOKE_METHOD_REQUEST_MESSAGE,
362 mike  1.6          CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
363                    CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
364                    CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
365 kumpf 1.15         CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
366 mday  1.32         CIM_HANDLE_INDICATION_REQUEST_MESSAGE, // 30
367 kumpf 1.15         CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
368                    CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
369 chip  1.25     
370                    // new
371 chip  1.26         CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE,
372                    CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE,
373 chip  1.25         CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,
374                    CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
375                    CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
376                
377 kumpf 1.29         // new
378                    CIM_DISABLE_MODULE_REQUEST_MESSAGE,
379                    CIM_ENABLE_MODULE_REQUEST_MESSAGE,
380                
381 kumpf 1.43         CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE,  // 40
382 kumpf 1.35     
383 kumpf 1.43         CIM_GET_CLASS_RESPONSE_MESSAGE,
384 mike  1.5          CIM_GET_INSTANCE_RESPONSE_MESSAGE,
385 kumpf 1.43         CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
386 mike  1.5          CIM_DELETE_CLASS_RESPONSE_MESSAGE,
387                    CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,
388                    CIM_CREATE_CLASS_RESPONSE_MESSAGE,
389                    CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
390                    CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
391                    CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
392 kumpf 1.43         CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,  // 50
393 mike  1.5          CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
394                    CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
395                    CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
396                    CIM_EXEC_QUERY_RESPONSE_MESSAGE,
397                    CIM_ASSOCIATORS_RESPONSE_MESSAGE,
398                    CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
399                    CIM_REFERENCES_RESPONSE_MESSAGE,
400                    CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
401                    CIM_GET_PROPERTY_RESPONSE_MESSAGE,
402 kumpf 1.43         CIM_SET_PROPERTY_RESPONSE_MESSAGE,  // 60
403 mike  1.5          CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
404                    CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
405                    CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
406                    CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
407                    CIM_INVOKE_METHOD_RESPONSE_MESSAGE,
408 mike  1.6          CIM_ENABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
409                    CIM_MODIFY_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
410                    CIM_DISABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
411 kumpf 1.15         CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
412 kumpf 1.43         CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,  // 70
413 kumpf 1.15         CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
414 kumpf 1.17         CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
415 mike  1.6      
416 chip  1.25         // new
417 chip  1.26         CIM_ENABLE_INDICATIONS_RESPONSE_MESSAGE,
418                    CIM_DISABLE_INDICATIONS_RESPONSE_MESSAGE,
419 chip  1.25         CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
420                    CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
421                    CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
422 kumpf 1.29     
423                    // new
424                    CIM_DISABLE_MODULE_RESPONSE_MESSAGE,
425                    CIM_ENABLE_MODULE_RESPONSE_MESSAGE,
426 kumpf 1.35     
427 kumpf 1.43         CIM_STOP_ALL_PROVIDERS_RESPONSE_MESSAGE,  // 80
428 chip  1.24     
429 mike  1.6          // Monitor-related messages:
430                
431                    SOCKET_MESSAGE,
432                
433                    // Connection-oriented messages:
434                
435                    CLOSE_CONNECTION_MESSAGE,
436                
437                    // HTTP messages:
438                
439                    HTTP_MESSAGE,
440 kumpf 1.27         HTTP_ERROR_MESSAGE,
441 kumpf 1.28     
442                    // Exception messages to be passed to a CIM client application:
443                
444                    CLIENT_EXCEPTION_MESSAGE,
445 mike  1.5      
446 mday  1.33         ASYNC_REGISTER_CIM_SERVICE,
447                    ASYNC_DEREGISTER_CIM_SERVICE,
448                    ASYNC_UPDATE_CIM_SERVICE,
449                    ASYNC_IOCTL,
450 kumpf 1.43         ASYNC_CIMSERVICE_START,  // 90
451 mday  1.33         ASYNC_CIMSERVICE_STOP,
452                    ASYNC_CIMSERVICE_PAUSE,
453                    ASYNC_CIMSERVICE_RESUME,
454                
455                    ASYNC_ASYNC_OP_START,
456                    ASYNC_ASYNC_OP_RESULT,
457                    ASYNC_ASYNC_LEGACY_OP_START,
458 chip  1.34         ASYNC_ASYNC_LEGACY_OP_RESULT,
459                
460 mday  1.33         ASYNC_FIND_SERVICE_Q,
461                    ASYNC_FIND_SERVICE_Q_RESULT,
462 kumpf 1.43         ASYNC_ENUMERATE_SERVICE,  // 100
463 mday  1.33         ASYNC_ENUMERATE_SERVICE_RESULT,
464 chip  1.34     
465 mday  1.33         ASYNC_REGISTERED_MODULE,
466                    ASYNC_DEREGISTERED_MODULE,
467                    ASYNC_FIND_MODULE_IN_SERVICE,
468                    ASYNC_FIND_MODULE_IN_SERVICE_RESPONSE,
469 chip  1.34     
470 mday  1.33         ASYNC_ASYNC_MODULE_OP_START,
471                    ASYNC_ASYNC_MODULE_OP_RESULT,
472 mday  1.42         // for indication consumers
473                
474                    CIM_CONSUME_INDICATION_REQUEST_MESSAGE,
475                    CIM_CONSUME_INDICATION_RESPONSE_MESSAGE,
476 mday  1.33     
477 mike  1.5          NUMBER_OF_MESSAGES
478                };
479                
480                PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
481 mike  1.6      
482                /** This class implements a stack of queue-ids. Many messages must keep a
483                    stack of queue-ids of queues which they must be returned to. This provides
484                    a light efficient stack for this purpose.
485                */
486                class QueueIdStack
487                {
488                public:
489                
490 chip  1.24         QueueIdStack() : _size(0)
491                    {
492 mike  1.6          }
493                
494 chip  1.24         QueueIdStack(const QueueIdStack& x) : _size(x._size)
495 mike  1.6          {
496                	memcpy(_items, x._items, sizeof(_items));
497                    }
498                
499 chip  1.24         PEGASUS_EXPLICIT QueueIdStack(Uint32 x) : _size(0)
500                    {
501                	push(x);
502 mike  1.6          }
503                
504 chip  1.24         PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2) : _size(0)
505 mike  1.6          {
506 chip  1.24     	push(x1);
507                	push(x2);
508 mike  1.6          }
509                
510 chip  1.24         ~QueueIdStack()
511                    {
512 mike  1.6          }
513                
514 chip  1.24         QueueIdStack& operator=(const QueueIdStack& x)
515 mike  1.6          {
516                	if (this != &x)
517                	{
518                	    memcpy(_items, x._items, sizeof(_items));
519                	    _size = x._size;
520                	}
521                	return *this;
522                    }
523                
524 chip  1.24         Uint32 size() const
525                    {
526                	return _size;
527 mike  1.6          }
528                
529 chip  1.24         Boolean isEmpty() const
530                    {
531                	return _size == 0;
532 mike  1.6          }
533                
534 chip  1.24         void push(Uint32 x)
535 mike  1.6          {
536                	if (_size == MAX_SIZE)
537                	    throw StackOverflow();
538                
539                	_items[_size++] = x;
540                    }
541                
542                    Uint32& top()
543                    {
544                	if (_size == 0)
545                	    throw StackUnderflow();
546                
547                	return _items[_size-1];
548                    }
549                
550 chip  1.24         Uint32 top() const
551 mike  1.6          {
552 chip  1.24     	return ((QueueIdStack*)this)->top();
553 mike  1.6          }
554                
555 chip  1.24         void pop()
556 mike  1.6          {
557                	if (_size == 0)
558                	    throw StackUnderflow();
559                
560                	_size--;
561                    }
562                
563                    /** Make a copy of this stack and then pop the top element. */
564                    QueueIdStack copyAndPop() const
565                    {
566                	return QueueIdStack(*this, 0);
567                    }
568                
569                private:
570                
571                    // Copy the given stack but then pop the top element:
572 chip  1.24         QueueIdStack(const QueueIdStack& x, int) : _size(x._size)
573 mike  1.6          {
574                	memcpy(_items, x._items, sizeof(_items));
575                	pop();
576                    }
577                
578                    enum { MAX_SIZE = 5 };
579                    Uint32 _items[MAX_SIZE];
580                    Uint32 _size;
581                };
582 mike  1.4      
583                PEGASUS_NAMESPACE_END
584                
585                #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2