gdcmDictEntry.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program: GDCM (Grassroots DICOM). A DICOM library
00004   Module:  $URL$
00005 
00006   Copyright (c) 2006-2009 Mathieu Malaterre
00007   All rights reserved.
00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 #ifndef __gdcmDictEntry_h
00016 #define __gdcmDictEntry_h
00017 
00018 #include "gdcmVR.h"
00019 #include "gdcmVM.h"
00020 
00021 #include <string>
00022 #include <iostream>
00023 #include <iomanip>
00024 
00025 namespace gdcm
00026 {
00037 class GDCM_EXPORT DictEntry
00038 {
00039 public:
00040   DictEntry(const char *name = "", VR const &vr = VR::INVALID, VM const &vm = VM::VM0, bool ret = false):Name(name),ValueRepresentation(vr),ValueMultiplicity(vm),Retired(ret),GroupXX(false),ElementXX(false) {
00041     //if(name && *name) Name = name;
00042     //ValueRepresentation = vr;
00043     //ValueMultiplicity = vm;
00044     //Retired = ret;
00045     //GroupXX = false;
00046     //ElementXX = false;
00047   }
00048 #if 0
00049   // FIXME
00050   DictEntry(const char *name, const char *vr, const char *vm) {
00051     if(name) Name = name;
00052     ValueRepresentation = VR::GetVRType(vr);
00053     ValueMultiplicity = VM::GetVMType(vm);
00054     Retired = false;
00055     GroupXX = false;
00056     ElementXX = false;
00057   }
00058 #endif
00059 
00060   friend std::ostream& operator<<(std::ostream& _os, const DictEntry &_val);
00061 
00063   const VR &GetVR() const { return ValueRepresentation; }
00064   void SetVR(const VR & vr) { ValueRepresentation = vr; }
00065 //  bool IsValid() const { return ValueRepresentation != VR::VR_END; }
00066 //    !Name.empty() /*&& ValueRepresentation && ValueMultiplicity*/; }
00067 
00069   const VM &GetVM() const { return ValueMultiplicity; }
00070   void SetVM(VM const & vm) { ValueMultiplicity = vm; }
00071 
00073   const char *GetName() const { return Name.c_str(); }
00074   void SetName(const char* name) { Name = name; }
00075 
00077   const char *GetKeyword() const { return ""; }
00078 
00080   bool GetRetired() const { return Retired; }
00081   void SetRetired(bool retired) { Retired = retired; }
00082 
00083   // <entry group="50xx" element="0005" vr="US" vm="1" retired="true" version="3">
00085   void SetGroupXX(bool v) { GroupXX = v; }
00086 
00087   // <entry group="0020" element="31xx" vr="CS" vm="1-n" retired="true" version="2">
00089   void SetElementXX(bool v) { ElementXX = v; }
00090 
00093   bool IsUnique() const { return ElementXX == false && GroupXX == false; }
00094 
00095 private:
00096   std::string Name;
00097   VR ValueRepresentation;
00098   VM ValueMultiplicity;
00099   bool Retired : 1;
00100   bool GroupXX : 1;
00101   bool ElementXX : 1;
00102 };
00103 
00104 #if 0
00105 class GDCM_EXPORT PrivateDictEntry : public DictEntry
00106 {
00107 public:
00108   PrivateDictEntry(const char *name = "", VR::VRType const &vr = VR::INVALID, VM::VMType const &vm = VM::VM0 , bool ret = false, const char *owner = ""):DictEntry(name,vr,vm,ret),Owner(owner) {}
00109   PrivateDictEntry(const char *name, const char *vr, const char *vm):DictEntry(name,vr,vm) {}
00110 
00111   const char *GetOwner() const { return Owner.c_str(); }
00112   void SetOwner(const char *owner) { Owner = owner; }
00113 
00114 private:
00115   // SIEMENS MED, GEMS_PETD_01 ...
00116   std::string Owner;
00117 };
00118 #endif
00119 
00120 //-----------------------------------------------------------------------------
00121 inline std::ostream& operator<<(std::ostream& os, const DictEntry &val)
00122 {
00123   if( val.Name.empty() )
00124     {
00125     os << "[No name]";
00126     }
00127   else
00128     {
00129     os << val.Name;
00130     }
00131   os << "\t" << val.ValueRepresentation << "\t" << val.ValueMultiplicity;
00132   if( val.Retired )
00133     {
00134     os << "\t(RET)";
00135     }
00136   return os;
00137 }
00138 
00139 } // end namespace gdcm
00140 
00141 #endif //__gdcmDictEntry_h

Generated on Wed Jun 30 13:49:13 2010 for GDCM by doxygen 1.6.3
SourceForge.net Logo