(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.2 #include <Pegasus/Common/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.32     	 }
151                	 return *this;
152                      }
153 chip  1.34     
154 chip  1.24     
155                      virtual ~Message();
156 mike  1.4      
157 mday  1.8            Uint32 getType() const { return _type; }
158 mike  1.4      
159 mday  1.8            void setType(Uint32 type) { _type = type; }
160 mike  1.4      
161 mday  1.8            Uint32 getKey() const { return _key; }
162 mike  1.4      
163 mday  1.8            void setKey(Uint32 key) { _key = key; }
164 mike  1.4      
165 mday  1.8            Uint32 getRouting() const { return _routing_code; }
166                      void setRouting(Uint32 routing) { _routing_code = routing; }
167 mike  1.4      
168 mday  1.8            Uint32 getMask() const { return _mask; }
169 chip  1.24     
170 mday  1.8            void setMask(Uint32 mask) { _mask = mask; }
171 chip  1.24     
172 kumpf 1.40           HttpMethod getHttpMethod() const { return _httpMethod; }
173                
174                      void setHttpMethod(HttpMethod httpMethod) {_httpMethod = httpMethod;}
175                
176 sage  1.31     #ifdef PEGASUS_HAS_PERFINST
177 sage  1.30     //
178                // Needed for performance measurement
179                //
180                
181                      void startServer();
182                
183                      void endServer();
184                
185                      void startProvider();
186                
187                      void endProvider();
188                
189                      timeval getStartServerTime() const { return _timeServerStart; }
190                
191                      void setStartServerTime(timeval timeServerStart)
192                      {
193                           _timeServerStart = timeServerStart;
194                      }
195                
196                      timeval getStartProviderTime() const { return _timeProviderStart; }
197                
198 sage  1.30           void setStartProviderTime(timeval timeProviderStart)
199                      {
200                          _timeProviderStart = timeProviderStart;
201                      }
202                
203                      timeval getEndServerTime() const { return _timeServerEnd; }
204                
205                      void setEndServerTime (timeval timeServerEnd)
206                      {
207                          _timeServerEnd = timeServerEnd;
208                      }
209                
210                      timeval getEndProviderTime() const { return _timeProviderEnd; }
211                
212                      void setEndProviderTime(timeval timeProviderEnd)
213                      {
214                          _timeProviderEnd = timeProviderEnd;
215                      }
216                
217                      Uint32 getTotalTime() { return _totalTime; }
218                //
219 sage  1.31     #endif
220 sage  1.30     
221 mday  1.8            Message* getNext() { return _next; }
222 mike  1.4      
223 mday  1.8            const Message* getNext() const { return _next; }
224 mike  1.4      
225 mday  1.8            Message* getPrevious() { return _prev; }
226 mike  1.4      
227 mday  1.8            const Message* getPrevious() const { return _prev; }
228 mike  1.4      
229 chip  1.24           static Uint32 getNextKey()
230                      {
231                	
232                	 _mut.lock( pegasus_thread_self() ) ;
233 mike  1.6      	 Uint32 ret = _nextKey++;
234                	 _mut.unlock();
235                	 return ret;
236                      }
237 chip  1.24     
238 mike  1.36           virtual void print(
239                	  PEGASUS_STD(ostream)& os, 
240                	  Boolean printHeader = true) const;
241 mike  1.4      
242 chip  1.24           // << Thu Dec 27 10:46:04 2001 mdd >> for use with DQueue container
243                      // as used by AsyncOpNode
244 kumpf 1.23           Boolean operator == (const void *msg )
245 mday  1.13           {
246 mday  1.16     	 if (reinterpret_cast<void *>(this) == msg )
247 mday  1.13     	    return true;
248                	 return false;
249                      }
250 chip  1.24     
251 mday  1.22           Message *get_async(void)
252                      {
253                	 Message *ret = _async;
254                	 _async = 0;
255                	 return ret;
256 chip  1.24     	
257 mday  1.22           }
258 chip  1.24     
259 mday  1.22           void put_async(Message * msg)
260                      {
261                	 _async = msg;
262                      }
263 chip  1.24     
264 mday  1.43.6.1       // << Tue Jul  1 11:02:49 2003 mdd >> pep_88 and helper for i18n and l10n
265                      Boolean thread_changed(void)
266                      {
267                	 if(_last_thread_id != pegasus_thread_self())
268                	 {
269                	    _last_thread_id = pegasus_thread_self();
270                	    return true;
271                	 }
272                
273                	 return false;
274                      }
275                      
276                      // << Tue Jul  1 13:41:02 2003 mdd >> pep_88 - 
277                      // assist in synchronizing responses with requests
278                
279                      void synch_response(Message *req)
280                      {
281                	 _key = req->_key;
282                	 _routing_code = req->_routing_code;
283                      }
284                      
285 chip  1.24     
286 mday  1.8         private:
287 mike  1.6            Uint32 _type;
288                      Uint32 _key;
289 mday  1.8            Uint32 _routing_code;
290 mike  1.6            Uint32 _mask;
291 kumpf 1.40           HttpMethod _httpMethod;
292 sage  1.30     // Needed for performance measurement
293                      timeval _timeServerStart;
294                      timeval _timeServerEnd;
295                      timeval _timeProviderStart;
296                      timeval _timeProviderEnd;
297                      Uint64 _totalTime;
298                //
299 mday  1.43.6.1 
300                      // << Tue Jul  1 11:02:35 2003 mdd >> pep_88 and helper for i18n and l10n
301                      PEGASUS_THREAD_TYPE _last_thread_id;
302                      
303 mike  1.6            Message* _next;
304                      Message* _prev;
305 mday  1.32     
306 mday  1.19        protected:
307 mday  1.32     
308                   public:
309 mday  1.19           Message *_async;
310 mday  1.20           Uint32 dest;
311 mday  1.19        private:
312 mike  1.6            MessageQueue* _owner;
313                      static Uint32 _nextKey;
314                      static Mutex _mut;
315 mday  1.43.6.2 
316                
317                      pegasus_socket _socket;
318                
319 mday  1.20           friend class cimom;
320 mike  1.6            friend class MessageQueue;
321 mday  1.19           friend class MessageQueueService;
322                      friend class AsyncLegacyOperationStart;
323                      friend class AsyncLegacyOperationResult;
324 chip  1.24     
325 mike  1.4      };
326 mike  1.5      
327 mike  1.6      
328 mike  1.5      enum MessageType
329                {
330                    DUMMY_MESSAGE,
331                
332                    // CIM Message types:
333                
334                    CIM_GET_CLASS_REQUEST_MESSAGE,
335                    CIM_GET_INSTANCE_REQUEST_MESSAGE,
336 mike  1.6          CIM_EXPORT_INDICATION_REQUEST_MESSAGE,
337 mike  1.5          CIM_DELETE_CLASS_REQUEST_MESSAGE,
338                    CIM_DELETE_INSTANCE_REQUEST_MESSAGE,
339                    CIM_CREATE_CLASS_REQUEST_MESSAGE,
340                    CIM_CREATE_INSTANCE_REQUEST_MESSAGE,
341                    CIM_MODIFY_CLASS_REQUEST_MESSAGE,
342                    CIM_MODIFY_INSTANCE_REQUEST_MESSAGE,
343 mday  1.32         CIM_ENUMERATE_CLASSES_REQUEST_MESSAGE, //10
344 mike  1.5          CIM_ENUMERATE_CLASS_NAMES_REQUEST_MESSAGE,
345                    CIM_ENUMERATE_INSTANCES_REQUEST_MESSAGE,
346                    CIM_ENUMERATE_INSTANCE_NAMES_REQUEST_MESSAGE,
347                    CIM_EXEC_QUERY_REQUEST_MESSAGE,
348                    CIM_ASSOCIATORS_REQUEST_MESSAGE,
349                    CIM_ASSOCIATOR_NAMES_REQUEST_MESSAGE,
350                    CIM_REFERENCES_REQUEST_MESSAGE,
351                    CIM_REFERENCE_NAMES_REQUEST_MESSAGE,
352                    CIM_GET_PROPERTY_REQUEST_MESSAGE,
353 mday  1.32         CIM_SET_PROPERTY_REQUEST_MESSAGE, //20
354 mike  1.5          CIM_GET_QUALIFIER_REQUEST_MESSAGE,
355                    CIM_SET_QUALIFIER_REQUEST_MESSAGE,
356                    CIM_DELETE_QUALIFIER_REQUEST_MESSAGE,
357                    CIM_ENUMERATE_QUALIFIERS_REQUEST_MESSAGE,
358                    CIM_INVOKE_METHOD_REQUEST_MESSAGE,
359 mike  1.6          CIM_ENABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
360                    CIM_MODIFY_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
361                    CIM_DISABLE_INDICATION_SUBSCRIPTION_REQUEST_MESSAGE,
362 kumpf 1.15         CIM_PROCESS_INDICATION_REQUEST_MESSAGE,
363 mday  1.32         CIM_HANDLE_INDICATION_REQUEST_MESSAGE, // 30
364 kumpf 1.15         CIM_NOTIFY_PROVIDER_REGISTRATION_REQUEST_MESSAGE,
365                    CIM_NOTIFY_PROVIDER_TERMINATION_REQUEST_MESSAGE,
366 chip  1.25     
367                    // new
368 chip  1.26         CIM_ENABLE_INDICATIONS_REQUEST_MESSAGE,
369                    CIM_DISABLE_INDICATIONS_REQUEST_MESSAGE,
370 chip  1.25         CIM_CREATE_SUBSCRIPTION_REQUEST_MESSAGE,
371                    CIM_MODIFY_SUBSCRIPTION_REQUEST_MESSAGE,
372                    CIM_DELETE_SUBSCRIPTION_REQUEST_MESSAGE,
373                
374 kumpf 1.29         // new
375                    CIM_DISABLE_MODULE_REQUEST_MESSAGE,
376                    CIM_ENABLE_MODULE_REQUEST_MESSAGE,
377                
378 kumpf 1.43         CIM_STOP_ALL_PROVIDERS_REQUEST_MESSAGE,  // 40
379 kumpf 1.35     
380 kumpf 1.43         CIM_GET_CLASS_RESPONSE_MESSAGE,
381 mike  1.5          CIM_GET_INSTANCE_RESPONSE_MESSAGE,
382 kumpf 1.43         CIM_EXPORT_INDICATION_RESPONSE_MESSAGE,
383 mike  1.5          CIM_DELETE_CLASS_RESPONSE_MESSAGE,
384                    CIM_DELETE_INSTANCE_RESPONSE_MESSAGE,
385                    CIM_CREATE_CLASS_RESPONSE_MESSAGE,
386                    CIM_CREATE_INSTANCE_RESPONSE_MESSAGE,
387                    CIM_MODIFY_CLASS_RESPONSE_MESSAGE,
388                    CIM_MODIFY_INSTANCE_RESPONSE_MESSAGE,
389 kumpf 1.43         CIM_ENUMERATE_CLASSES_RESPONSE_MESSAGE,  // 50
390 mike  1.5          CIM_ENUMERATE_CLASS_NAMES_RESPONSE_MESSAGE,
391                    CIM_ENUMERATE_INSTANCES_RESPONSE_MESSAGE,
392                    CIM_ENUMERATE_INSTANCE_NAMES_RESPONSE_MESSAGE,
393                    CIM_EXEC_QUERY_RESPONSE_MESSAGE,
394                    CIM_ASSOCIATORS_RESPONSE_MESSAGE,
395                    CIM_ASSOCIATOR_NAMES_RESPONSE_MESSAGE,
396                    CIM_REFERENCES_RESPONSE_MESSAGE,
397                    CIM_REFERENCE_NAMES_RESPONSE_MESSAGE,
398                    CIM_GET_PROPERTY_RESPONSE_MESSAGE,
399 kumpf 1.43         CIM_SET_PROPERTY_RESPONSE_MESSAGE,  // 60
400 mike  1.5          CIM_GET_QUALIFIER_RESPONSE_MESSAGE,
401                    CIM_SET_QUALIFIER_RESPONSE_MESSAGE,
402                    CIM_DELETE_QUALIFIER_RESPONSE_MESSAGE,
403                    CIM_ENUMERATE_QUALIFIERS_RESPONSE_MESSAGE,
404                    CIM_INVOKE_METHOD_RESPONSE_MESSAGE,
405 mike  1.6          CIM_ENABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
406                    CIM_MODIFY_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
407                    CIM_DISABLE_INDICATION_SUBSCRIPTION_RESPONSE_MESSAGE,
408 kumpf 1.15         CIM_PROCESS_INDICATION_RESPONSE_MESSAGE,
409 kumpf 1.43         CIM_NOTIFY_PROVIDER_REGISTRATION_RESPONSE_MESSAGE,  // 70
410 kumpf 1.15         CIM_NOTIFY_PROVIDER_TERMINATION_RESPONSE_MESSAGE,
411 kumpf 1.17         CIM_HANDLE_INDICATION_RESPONSE_MESSAGE,
412 mike  1.6      
413 chip  1.25         // new
414 chip  1.26         CIM_ENABLE_INDICATIONS_RESPONSE_MESSAGE,
415                    CIM_DISABLE_INDICATIONS_RESPONSE_MESSAGE,
416 chip  1.25         CIM_CREATE_SUBSCRIPTION_RESPONSE_MESSAGE,
417                    CIM_MODIFY_SUBSCRIPTION_RESPONSE_MESSAGE,
418                    CIM_DELETE_SUBSCRIPTION_RESPONSE_MESSAGE,
419 kumpf 1.29     
420                    // new
421                    CIM_DISABLE_MODULE_RESPONSE_MESSAGE,
422                    CIM_ENABLE_MODULE_RESPONSE_MESSAGE,
423 kumpf 1.35     
424 kumpf 1.43         CIM_STOP_ALL_PROVIDERS_RESPONSE_MESSAGE,  // 80
425 chip  1.24     
426 mike  1.6          // Monitor-related messages:
427                
428                    SOCKET_MESSAGE,
429                
430                    // Connection-oriented messages:
431                
432                    CLOSE_CONNECTION_MESSAGE,
433                
434                    // HTTP messages:
435                
436                    HTTP_MESSAGE,
437 kumpf 1.27         HTTP_ERROR_MESSAGE,
438 kumpf 1.28     
439                    // Exception messages to be passed to a CIM client application:
440                
441                    CLIENT_EXCEPTION_MESSAGE,
442 mike  1.5      
443 mday  1.33         ASYNC_REGISTER_CIM_SERVICE,
444                    ASYNC_DEREGISTER_CIM_SERVICE,
445                    ASYNC_UPDATE_CIM_SERVICE,
446                    ASYNC_IOCTL,
447 kumpf 1.43         ASYNC_CIMSERVICE_START,  // 90
448 mday  1.33         ASYNC_CIMSERVICE_STOP,
449                    ASYNC_CIMSERVICE_PAUSE,
450                    ASYNC_CIMSERVICE_RESUME,
451                
452                    ASYNC_ASYNC_OP_START,
453                    ASYNC_ASYNC_OP_RESULT,
454                    ASYNC_ASYNC_LEGACY_OP_START,
455 chip  1.34         ASYNC_ASYNC_LEGACY_OP_RESULT,
456                
457 mday  1.33         ASYNC_FIND_SERVICE_Q,
458                    ASYNC_FIND_SERVICE_Q_RESULT,
459 kumpf 1.43         ASYNC_ENUMERATE_SERVICE,  // 100
460 mday  1.33         ASYNC_ENUMERATE_SERVICE_RESULT,
461 chip  1.34     
462 mday  1.33         ASYNC_REGISTERED_MODULE,
463                    ASYNC_DEREGISTERED_MODULE,
464                    ASYNC_FIND_MODULE_IN_SERVICE,
465                    ASYNC_FIND_MODULE_IN_SERVICE_RESPONSE,
466 chip  1.34     
467 mday  1.33         ASYNC_ASYNC_MODULE_OP_START,
468                    ASYNC_ASYNC_MODULE_OP_RESULT,
469 mday  1.42         // for indication consumers
470                
471                    CIM_CONSUME_INDICATION_REQUEST_MESSAGE,
472                    CIM_CONSUME_INDICATION_RESPONSE_MESSAGE,
473 mday  1.33     
474 mike  1.5          NUMBER_OF_MESSAGES
475                };
476                
477                PEGASUS_COMMON_LINKAGE const char* MessageTypeToString(Uint32 messageType);
478 mike  1.6      
479                /** This class implements a stack of queue-ids. Many messages must keep a
480                    stack of queue-ids of queues which they must be returned to. This provides
481                    a light efficient stack for this purpose.
482                */
483                class QueueIdStack
484                {
485                public:
486                
487 chip  1.24         QueueIdStack() : _size(0)
488                    {
489 mike  1.6          }
490                
491 chip  1.24         QueueIdStack(const QueueIdStack& x) : _size(x._size)
492 mike  1.6          {
493                	memcpy(_items, x._items, sizeof(_items));
494                    }
495                
496 chip  1.24         PEGASUS_EXPLICIT QueueIdStack(Uint32 x) : _size(0)
497                    {
498                	push(x);
499 mike  1.6          }
500                
501 chip  1.24         PEGASUS_EXPLICIT QueueIdStack(Uint32 x1, Uint32 x2) : _size(0)
502 mike  1.6          {
503 chip  1.24     	push(x1);
504                	push(x2);
505 mike  1.6          }
506                
507 chip  1.24         ~QueueIdStack()
508                    {
509 mike  1.6          }
510                
511 chip  1.24         QueueIdStack& operator=(const QueueIdStack& x)
512 mike  1.6          {
513                	if (this != &x)
514                	{
515                	    memcpy(_items, x._items, sizeof(_items));
516                	    _size = x._size;
517                	}
518                	return *this;
519                    }
520                
521 chip  1.24         Uint32 size() const
522                    {
523                	return _size;
524 mike  1.6          }
525                
526 chip  1.24         Boolean isEmpty() const
527                    {
528                	return _size == 0;
529 mike  1.6          }
530                
531 chip  1.24         void push(Uint32 x)
532 mike  1.6          {
533                	if (_size == MAX_SIZE)
534                	    throw StackOverflow();
535                
536                	_items[_size++] = x;
537                    }
538                
539                    Uint32& top()
540                    {
541                	if (_size == 0)
542                	    throw StackUnderflow();
543                
544                	return _items[_size-1];
545                    }
546                
547 chip  1.24         Uint32 top() const
548 mike  1.6          {
549 chip  1.24     	return ((QueueIdStack*)this)->top();
550 mike  1.6          }
551                
552 chip  1.24         void pop()
553 mike  1.6          {
554                	if (_size == 0)
555                	    throw StackUnderflow();
556                
557                	_size--;
558                    }
559                
560                    /** Make a copy of this stack and then pop the top element. */
561                    QueueIdStack copyAndPop() const
562                    {
563                	return QueueIdStack(*this, 0);
564                    }
565                
566                private:
567                
568                    // Copy the given stack but then pop the top element:
569 chip  1.24         QueueIdStack(const QueueIdStack& x, int) : _size(x._size)
570 mike  1.6          {
571                	memcpy(_items, x._items, sizeof(_items));
572                	pop();
573                    }
574                
575                    enum { MAX_SIZE = 5 };
576                    Uint32 _items[MAX_SIZE];
577                    Uint32 _size;
578                };
579 mike  1.4      
580                PEGASUS_NAMESPACE_END
581                
582                #endif /* Pegasus_Message_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2