MeVisLabToolboxReference
|
00001 //----------------------------------------------------------------------------- 00002 // **InsertLicense** code 00003 //----------------------------------------------------------------------------- 00005 00010 //----------------------------------------------------------------------------- 00011 00012 #ifndef CLASS_DCMTREE_TAG 00013 #define CLASS_DCMTREE_TAG 00014 00015 #include "DCMTree_Lib.h" 00016 #include "DCMTree_TagInfo.h" 00017 #include "DCMTree_Value.h" 00018 #include "DCMTree_Defines.h" 00019 00020 #ifdef _MSC_VER 00021 // 4365: signed/unsigned mismatch 00022 // 4548: expression before comma has no effect; expected expression with side-effect 00023 #pragma warning (push) 00024 #pragma warning (disable : 4365 4548) 00025 #endif 00026 00027 #include <istream> 00028 #include <ostream> 00029 #include <fstream> 00030 00031 #ifdef _MSC_VER 00032 #pragma warning (pop) 00033 #endif 00034 00035 namespace DCMTree 00036 { 00038 class DCMTREE_EXPORT Tag:public DCMTree_Serialization::Serializable,public DCMTree_Serialization::Deserializable 00039 { 00040 public: 00042 Tag(); 00043 00048 Tag(const TagInfo &info); 00049 00051 Tag(const Tag &other); 00052 00056 Tag(const Tag &other, unsigned short slot); 00057 00059 virtual ~Tag(); 00060 00065 Tag &operator=(const Tag &other); 00066 00071 bool operator==( const Tag& other ) const; 00072 bool operator!=( const Tag& other ) const; 00073 00078 bool isEqual( const Tag& other, double tolerance = 0 ) const; 00079 00083 TagPtr copy() const; 00084 00088 const TagInfo &info() const; 00089 00094 const TreePtrVector &sequenceItems() const; 00095 00100 TreePtrVector &sequenceItems(); 00101 00106 boost::uint32_t numberOfSequenceItems() const; 00107 00112 void dropSequenceItems(); 00113 00118 void dropSequenceItem(unsigned idx); 00119 00123 virtual boost::uint32_t numberOfValues() const; 00124 00130 void dropValues(); 00131 00135 bool isEmpty() const; 00136 00140 bool isSequence() const; 00141 00146 bool isNull (unsigned idx) const; 00147 00152 bool isSequenceItemNull (unsigned idx) const; 00153 00158 void setInfo (const TagInfo &info); 00159 00169 void addSequenceItem (const TreePtr &sequence); 00170 00174 TreePtr &addSequenceItem(); 00175 00181 void setSequenceItem (const TreePtr &sequence,unsigned idx=0); 00182 00188 std::string toString (unsigned int idx) const; 00189 00196 std::string toString() const; 00197 00203 void setValue (std::string value,unsigned int idx=0); 00204 00209 void addValue (std::string value); 00210 00216 Date toDate (unsigned int idx=0) const; 00217 00223 void setValue (Date value,unsigned int idx=0); 00224 00229 void addValue (Date value); 00230 00236 Time toTime (unsigned int idx=0) const; 00237 00243 void setValue (Time value,unsigned int idx=0); 00244 00249 void addValue (Time value); 00250 00256 DateTime toDateTime (unsigned int idx=0) const; 00257 00263 void setValue (DateTime value,unsigned int idx=0); 00264 00269 void addValue (DateTime value); 00270 00276 float toFloat (unsigned int idx=0) const; 00277 00283 void setValue (float value,unsigned int idx=0); 00284 00289 void addValue (float value); 00290 00296 double toDouble (unsigned int idx=0) const; 00297 00303 void setValue (double value,unsigned int idx=0); 00304 00309 void addValue (double value); 00310 00316 int toInt (unsigned int idx=0) const; 00317 00323 void setValue (int value,unsigned int idx=0); 00324 00329 void addValue (int value); 00330 00336 unsigned int toUInt (unsigned int idx=0) const; 00337 00343 void setValue (unsigned int value,unsigned int idx=0); 00344 00349 void addValue (unsigned int value); 00350 00356 short int toShort (unsigned int idx=0) const; 00357 00363 void setValue (short int value,unsigned int idx=0); 00364 00369 void addValue (short int value); 00370 00376 unsigned short toUShort (unsigned int idx=0) const; 00377 00383 void setValue (unsigned short int value,unsigned int idx=0); 00384 00389 void addValue (unsigned short int value); 00390 00396 const Value &getValue (unsigned int idx=0) const; 00397 00403 void setValue (const Value &value,unsigned int idx=0); 00404 00409 virtual Value &addValue(); 00410 00415 virtual boost::uint32_t getValueSize (unsigned int idx) const; 00416 00420 virtual boost::uint32_t getValueSize () const; 00421 00427 virtual void fromStream (std::istream &in, bool readName); 00428 00434 virtual void toStream (std::ostream &out, bool writeName) const; 00435 00444 int compare(const Tag& tag, double tolerance = 0.0001) const; 00445 00453 void setVr( Vr vr ); 00454 00455 virtual void serializeX (DCMTree_Serialization::Sink &sink) const; 00456 virtual void deserializeX (DCMTree_Serialization::Source &source); 00457 00458 protected: 00459 TagInfo const & tagInfo() const { return _info; } 00460 00461 private: 00468 int compareNumerical(const Tag& tag, int nMin, double tolerance) const; 00469 00476 int compareBytes(const Tag& tag, int nMin) const; 00477 00481 void typeAndRangeChecking (const VRCType &vrctype,const unsigned int &idx) const; 00482 00486 void typeChecking (const VRCType &vrctype) const; 00487 00491 bool isOfType(const VRCType &vrctype) const; 00492 00496 void rangeChecking (const unsigned int &idx) const; 00497 00501 void sequenceRangeChecking (const unsigned int &idx) const; 00502 00503 TagInfo _info; 00504 ValueVector _values; 00505 TreePtrVector _sequences; 00506 }; 00507 00508 inline std::ostream &operator << (std::ostream &out,const Tag &t) 00509 { 00510 t.toStream (out, false); 00511 return out; 00512 } 00513 00514 inline std::istream &operator >> (std::istream &in,Tag &t) 00515 { 00516 t.fromStream (in, false); 00517 return in; 00518 } 00519 } 00520 00521 #endif 00522 00523 00524