00001 /***************************************************************************** 00002 * Copyright (C) 2011 by Benjamin Hadorn (b_hadorn@bluewin.ch) 00003 ***************************************************************************** 00004 * Project : Zeus Base Library 00005 * Module : AbstractMessage 00006 * Package : Zeus.ZeusBase.Messaging 00007 * Author : Benjamin Hadorn 00008 * Date : 27.12.2011 00009 * System : Zeus-Framework 00010 ***************************************************************************** 00011 * Licence: * 00012 * This library is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU Lesser General Public License as * 00014 * published by the Free Software Foundation; either version * 00015 * 2.1 of the License, or (at your option) any later version. * 00016 * * 00017 * This library is distributed in the hope that it will be useful, * 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00020 * GNU Lesser General Public License for more details. * 00021 * * 00022 * You should have received a copy of the GNU Lesser General Public * 00023 * License along with this library; if not, write to the Free Software * 00024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA * 00025 *****************************************************************************/ 00026 00027 /***************************************************************************** 00028 * Changes: 00029 * 27.12.2011 bha: created zeus 2.0 00030 *****************************************************************************/ 00031 00032 #ifndef AbstractMessageH 00033 #define AbstractMessageH 00034 //--------------------------------------------------------------------------- 00035 00036 #include <zeusbase/Messaging/Interfaces/IMessage.hpp> 00037 #include <zeusbase/System/Serializer.h> 00038 #include <zeusbase/System/StringMap.hpp> 00039 #include <zeusbase/System/SingleLinkedList.hpp> 00040 #include <zeusbase/System/ZObject.h> 00041 00042 BEGIN_NAMESPACE_Zeus 00043 00044 class TCriticalSection; 00045 00046 /****************************************************************************/ 00050 /****************************************************************************/ 00051 zeusbase_class TAbstractMessage : public TZObject, public IMessage 00052 { 00053 public: 00054 //Methods of IMessage 00055 virtual void MQUALIFIER clearBody() = 0; 00056 virtual void MQUALIFIER clearProperties(); 00057 virtual void MQUALIFIER getInterfaceID(InterfaceID& rIID) const = 0; 00058 virtual Uint MQUALIFIER getMessageID() const; 00059 virtual Uint MQUALIFIER getPriority() const; 00060 virtual void MQUALIFIER getSender(TypGUID& rValue) const; 00061 virtual void MQUALIFIER getRecipients(IList<TypGUID>& rlstValue) const; 00062 virtual Retval MQUALIFIER getPropertyValue(const IString& rName, IString& rValue) const; 00063 virtual Uint64 MQUALIFIER getTimeStamp() const; 00064 virtual void MQUALIFIER setMessageID(Uint uiValue); 00065 virtual void MQUALIFIER setPropertyValue(const IString& rName, const IString& rValue); 00066 virtual void MQUALIFIER setPriority(Uint uiValue); 00067 virtual void MQUALIFIER setSender(const TypGUID& rValue); 00068 virtual void MQUALIFIER setRecipient(const TypGUID& rValue); 00069 virtual void MQUALIFIER setRecipients(const IList<TypGUID>& rlstValue); 00070 virtual void MQUALIFIER setTimeStamp(const Uint64& rui64Value); 00071 00072 //Methods of ISerializable 00073 SERIAL_START_ABSTRACTCLASS(TAbstractMessage, L"TAbstractMessage") 00074 SERIAL_UINT32(m_uiID) 00075 SERIAL_UINT32(m_ulPriority) 00076 SERIAL_UINT32(m_uiReserved) 00077 SERIAL_UINT64(m_ui64Timestamp) 00078 SERIAL_STRING_STRINGMAP(m_mapProperties) 00079 SERIAL_GUID(m_SenderID) 00080 SERIAL_GUIDLIST(m_lstRecipients) 00081 SERIAL_END 00082 00083 //Methods of IZUnknown 00084 MEMORY_MANAGER_DECL 00085 00086 protected: 00087 TAbstractMessage(); 00088 virtual ~TAbstractMessage(); 00089 00091 TCriticalSection& m_rLock; 00092 00093 private: 00095 Uint32 m_ulPriority; 00097 Uint64 m_ui64Timestamp; 00099 Uint32 m_uiReserved; 00101 TStringMap<TString> m_mapProperties; 00103 TypGUID m_SenderID; 00105 TSingleLinkedList<TypGUID> m_lstRecipients; 00106 }; 00107 00108 /****************************************************************************/ 00111 /****************************************************************************/ 00112 inline Uint MQUALIFIER TAbstractMessage::getMessageID() const 00113 { 00114 return m_uiID; 00115 } 00116 00117 /****************************************************************************/ 00120 /****************************************************************************/ 00121 inline Uint MQUALIFIER TAbstractMessage::getPriority() const 00122 { 00123 return m_ulPriority; 00124 } 00125 00126 /****************************************************************************/ 00129 /****************************************************************************/ 00130 inline void MQUALIFIER TAbstractMessage::getSender(TypGUID& rValue) const 00131 { 00132 rValue = m_SenderID; 00133 } 00134 00135 /****************************************************************************/ 00138 /****************************************************************************/ 00139 inline void MQUALIFIER TAbstractMessage::getRecipients(IList<TypGUID>& rlstValue) const 00140 { 00141 rlstValue.clear(); 00142 rlstValue.addAll(m_lstRecipients); 00143 } 00144 00145 /****************************************************************************/ 00148 /****************************************************************************/ 00149 inline Uint64 MQUALIFIER TAbstractMessage::getTimeStamp() const 00150 { 00151 return m_ui64Timestamp; 00152 } 00153 00154 /****************************************************************************/ 00157 /****************************************************************************/ 00158 inline void MQUALIFIER TAbstractMessage::setSender(const TypGUID& rValue) 00159 { 00160 m_SenderID = rValue; 00161 } 00162 00163 /****************************************************************************/ 00166 /****************************************************************************/ 00167 inline void MQUALIFIER TAbstractMessage::setRecipient(const TypGUID& rValue) 00168 { 00169 m_lstRecipients.clear(); 00170 m_lstRecipients.add(rValue); 00171 } 00172 00173 /****************************************************************************/ 00176 /****************************************************************************/ 00177 inline void MQUALIFIER TAbstractMessage::setRecipients(const IList<TypGUID>& rlstValue) 00178 { 00179 m_lstRecipients.clear(); 00180 m_lstRecipients.addAll(rlstValue); 00181 } 00182 00183 00184 END_NAMESPACE_Zeus 00185 00186 #endif