MessageList.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005 Palmsource, Inc.
00003  * 
00004  * This software is licensed as described in the file LICENSE, which
00005  * you should have received as part of this distribution. The terms
00006  * are also available at http://www.openbinder.org/license.html.
00007  * 
00008  * This software consists of voluntary contributions made by many
00009  * individuals. For the exact contribution history, see the revision
00010  * history and logs, available at http://www.openbinder.org
00011  */
00012 
00013 #ifndef _SUPPORT_MESSAGELIST_H
00014 #define _SUPPORT_MESSAGELIST_H
00015 
00021 #include <support/ITextStream.h>
00022 #include <support/SupportDefs.h>
00023 
00024 #if _SUPPORTS_NAMESPACE
00025 namespace palmos {
00026 namespace support {
00027 #endif
00028 
00033 class SMessage;
00034 
00035 enum {
00036     B_ANY_WHAT = 0
00037 };
00038 
00039 /*----------------------------------------------------------------------*/
00040 
00042 class SMessageList 
00043 {
00044 public:
00047 
00048                         SMessageList();
00049                         ~SMessageList();
00050 
00052 
00054         SMessageList&   Adopt(SMessageList& other);
00055 
00057 
00058     
00063 
00065 
00068         void            EnqueueMessage(SMessage* msg);
00069 
00071 
00082         SMessage*       EnqueueMessageRemoveDups(   const SMessage& msg, nsecs_t time,
00083                                                     SValue* outPrevData, SMessageList* outRemoved);
00084 
00086 
00106         SMessage*       EnqueueUniqueMessage(   const SMessage& msg, nsecs_t time,
00107                                                 SValue* outPrevData, SMessageList* outRemoved);
00108 
00110 
00113         SMessage*       DequeueMessage(uint32_t what = B_ANY_WHAT, bool *more = NULL);
00114 
00116 
00118         nsecs_t         OldestMessage(int32_t* out_priority) const;
00119 
00121 
00125 
00127         const SMessage* Head() const;
00129         const SMessage* Tail() const;
00131         const SMessage* Next(const SMessage* current) const;
00133         const SMessage* Previous(const SMessage* current) const;
00134 
00136 
00140 
00142         void            AddHead(SMessage* message);
00144         void            AddTail(SMessage* message);
00146 
00148         void            InsertBefore(SMessage* message, const SMessage* position);
00150 
00152         void            InsertAfter(SMessage* message, const SMessage* position);
00153 
00155         
00159 
00161         SMessage*       RemoveHead();
00163         SMessage*       RemoveTail();
00165         SMessage*       Remove(const SMessage* message);
00166 
00168 
00172 
00174 
00176         int32_t         CountMessages(uint32_t what = B_ANY_WHAT) const;
00178         bool            IsEmpty() const;
00180         void            MakeEmpty();
00181 
00183         
00184 /*----- Private or reserved -----------------------------------------*/
00185 
00186 private:
00187                         SMessageList(const SMessageList &);
00188         SMessageList&   operator=(const SMessageList &);
00189 
00190         SMessage        *fHead;
00191         SMessage        *fTail;
00192         int32_t         fCount;
00193         uint32_t        _reserved[2];
00194 };
00195 
00196 _IMPEXP_SUPPORT const sptr<ITextOutput>& operator<<(const sptr<ITextOutput>& io, const SMessageList& list);
00197 
00198 /*-------------------------------------------------------------*/
00199 /*-------------------------------------------------------------*/
00200 
00203 #if _SUPPORTS_NAMESPACE
00204 } } // namespace palmos::support
00205 #endif
00206 
00207 #endif /* _SUPPORT_MESSAGELIST_H */