util/MessageUnit.h

Go to the documentation of this file.
00001 /*-----------------------------------------------------------------------------
00002 Name:      MessageUnit.h
00003 Project:   xmlBlaster.org
00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
00005 Comment:   Holding a message
00006 -----------------------------------------------------------------------------*/
00007 
00008 #ifndef _UTIL_MESSAGEUNIT_H
00009 #define _UTIL_MESSAGEUNIT_H
00010  
00011 #include <string>
00012 #include <vector>
00013 #include <client/qos/PublishQos.h>
00014 #include <client/key/PublishKey.h>
00015 #include <util/qos/QosData.h>
00016 #include <util/key/KeyData.h>
00017 
00018 
00019 
00020 
00021 namespace org { namespace xmlBlaster { namespace util {
00022    
00032 class Dll_Export MessageUnit 
00033 {
00034 
00035    private:
00036       std::string me() {
00037          return "MessageUnit";
00038       }
00039 
00040       org::xmlBlaster::util::key::KeyDataRef key_;
00041 
00042       //std::vector<unsigned char> contentVec_;
00043       unsigned long len_;
00044       unsigned char *content_;
00045 
00046       org::xmlBlaster::util::qos::QosDataRef qos_;
00047 
00049       mutable size_t immutableSizeInBytes_;
00050 
00051    public:
00055       MessageUnit(const org::xmlBlaster::util::key::KeyData &key,
00056                   unsigned long len,
00057                   const unsigned char * content, 
00058                   const org::xmlBlaster::util::qos::QosData &qos);
00059 
00063       MessageUnit(const org::xmlBlaster::util::key::KeyData &key,
00064                   const std::string &content, 
00065                   const org::xmlBlaster::util::qos::QosData &qos);
00066 
00070       MessageUnit(const org::xmlBlaster::client::key::PublishKey& xmlKey,
00071                   const std::string &content, 
00072                   org::xmlBlaster::client::qos::PublishQos& publishQos);
00073 
00077       MessageUnit(const org::xmlBlaster::util::key::KeyData &xmlKey,
00078                   const std::vector<unsigned char> &contentVec, 
00079                   const org::xmlBlaster::util::qos::QosData &qos);
00080 
00084       MessageUnit(const org::xmlBlaster::client::key::PublishKey &xmlKey,
00085                   const std::vector<unsigned char> &contentVec, 
00086                   org::xmlBlaster::client::qos::PublishQos& publishQos);
00087 
00093       MessageUnit(const MessageUnit& rhs);
00094 
00100       MessageUnit& operator=(const MessageUnit& rhs);
00101 
00105       virtual ~MessageUnit();
00106 
00110       const org::xmlBlaster::util::key::KeyDataRef getKeyRef() const;
00111 
00116       const org::xmlBlaster::util::key::KeyData& getKey() const;
00117 
00123       std::vector<unsigned char> getContentVec() const;
00124 
00129       const unsigned char *getContent() const {
00130          return content_;
00131       }
00132 
00136       unsigned long getContentLen() const {
00137          return len_;
00138       }
00139 
00143       std::string getContentStr() const;
00144 
00148       const org::xmlBlaster::util::qos::QosDataRef getQosRef() const;
00149 
00154       const org::xmlBlaster::util::qos::QosData& getQos() const;
00155 
00159       size_t getSizeInBytes() const;
00160 
00167       std::string toXml(const std::string &extraOffset="") const;
00168 };
00169 }}} // namespace
00170 
00171 #endif