MeVisLabToolboxReference
|
00001 //----------------------------------------------------------------------------- 00002 // **InsertLicense** code 00003 //----------------------------------------------------------------------------- 00005 00010 // values are stored binary internaly, ie. 00011 // there is no implicit conversion taking place. 00012 // data is converted if desired by DCMTree::Tag 00013 //----------------------------------------------------------------------------- 00014 00015 #ifndef CLASS_DCMTREE_VALUE 00016 #define CLASS_DCMTREE_VALUE 00017 00018 #include <vector> 00019 00020 #include <istream> 00021 #include <ostream> 00022 00023 #include "boost/shared_array.hpp" 00024 00025 #include "DCMTree_Lib.h" 00026 #include "DCMTree_Defines.h" 00027 00028 00029 namespace DCMTree 00030 { 00032 class DCMTREE_EXPORT Value:public DCMTree_Serialization::Serializable,public DCMTree_Serialization::Deserializable 00033 { 00034 public: 00035 enum SetDataMode 00036 { 00037 SDM_makeCopy, // copy the data into the value 00038 SDM_takeOwnership // the value takes the ownership of the data 00039 }; 00040 00041 public: 00043 Value(); 00044 00048 Value (const unsigned int &size); 00049 00055 Value (const unsigned int &size,const unsigned char *data); 00056 00061 Value (const Value &other); 00062 00064 virtual ~Value(); 00065 00070 Value &operator =(const Value &other); 00071 00075 bool operator ==(const Value &other) const; 00076 00080 bool operator !=(const Value &other) const; 00081 00085 void purge(); 00086 00090 unsigned int size() const; 00091 00095 const unsigned char *data() const; 00096 00100 unsigned char *data(); 00101 00105 boost::shared_array<unsigned char> sharedData() const; 00106 00110 void setSize (const unsigned int &size); 00111 00116 void setData (const unsigned int &size,const unsigned char *data); 00117 00124 void setData (const unsigned int &size, unsigned char *data, 00125 SetDataMode setDataMode = SDM_makeCopy); 00126 00130 void setData (const std::string &value); 00131 00135 bool isNull() const; 00136 00140 void fromStream (std::istream &in); 00141 00145 void toStream (std::ostream &out) const; 00146 00147 void serializeX (DCMTree_Serialization::Sink &sink) const; 00148 void deserializeX (DCMTree_Serialization::Source &source); 00149 00150 private: 00154 void allocate (const unsigned int &size); 00155 00156 boost::shared_array<unsigned char> _data; 00157 unsigned int _size; 00158 unsigned int _buffersize; 00159 }; 00160 00161 typedef std::vector<Value> ValueVector; 00162 00163 inline std::ostream &operator << (std::ostream &out,const Value &v) 00164 { 00165 v.toStream (out); 00166 return out; 00167 } 00168 00169 inline std::istream &operator >> (std::istream &in,Value &v) 00170 { 00171 v.fromStream (in); 00172 return in; 00173 } 00174 } 00175 00176 #endif 00177 00178