X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOTreeAttributeDescriptor.h;h=ad4d7bfe601fe38922f3fb3b10fae6e97b482cb4;hb=cc5a912f64e8de1f90d9ef0956633515a46d31ae;hp=cc78838797e437fc2193ec36ad388aeef20a79f9;hpb=cbf693fa62cd51f4ca5c881838bbb609edc447b0;p=creaImageIO.git diff --git a/src2/creaImageIOTreeAttributeDescriptor.h b/src2/creaImageIOTreeAttributeDescriptor.h index cc78838..ad4d7bf 100644 --- a/src2/creaImageIOTreeAttributeDescriptor.h +++ b/src2/creaImageIOTreeAttributeDescriptor.h @@ -9,33 +9,58 @@ namespace creaImageIO namespace tree { + /** + * \ingroup Tree + */ //===================================================================== - /// Descriptor of an attribute of a node of a tree (name, dicom group/element) + /// Descriptor of an attribute of a node of a Tree (name, dicom group/element) class AttributeDescriptor { public: /// Flags /// The attribute is hidden (not visible to user) - static const unsigned int HIDDEN; - /// The attribute enters in unique identifier constitution (KEY) - static const unsigned int KEY; + static const unsigned int PRIVATE; + /// The attribute enters in unique identifier constitution + static const unsigned int IDENTIFIER; /// The attribute enters in label constitution (for printing) static const unsigned int LABEL; + /// Types + /// The attribute is of numeric type + static const int NUMBER=1; + /// The attribute is of string type + static const int STRING=2; + /// The attribute's type is unknown + static const int UNKNOWN=0; + /// Default ctor AttributeDescriptor() : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0) { } - // Ctor with key and flags - // If the key is of the form "0020|000E" - // (Two hex short separated by a pipe at 5th position) - // it is interpreted as a Dicom Tag - // The user name is retreived from dicom dictionnary - // and the group and elem are filled - // Else the name is set to the key + /// Ctor with all explicitely + AttributeDescriptor(const std::string& key, + const std::string& name, + unsigned short group, + unsigned short element, + unsigned int flags) + : mKey(key), mName(name), mGroup(group), mElement(element), + mFlags(flags) + { + } + + // Ctor with key, name and flags AttributeDescriptor(const std::string& key, + const std::string& name, unsigned int flags = 0); + // Ctor with dicom group, elem and flags + // The key is built as 'Dgroup_elem' + // The user name is retreived from dicom dictionnary + AttributeDescriptor(unsigned short group, + unsigned short element, + unsigned int flags = 0); + /// Returns the key of the attribute + const std::string& GetKey() const { return mKey; } /// Returns the name of the attribute const std::string& GetName() const { return mName; } /// Returns the DICOM group code of the attribute @@ -44,7 +69,21 @@ namespace creaImageIO unsigned short GetElement() const { return mElement; } /// Returns the flags of the attribute unsigned int GetFlags() const { return mFlags; } - + + /// Extracts group and element from a key of the form "Dgroup_elem" + static void GetDicomGroupElementFromKey(const std::string& key, + unsigned short& group, + unsigned short& elem); + /// Cleans the name: + /// Replace simple quote by double quotes + /// Cut string at NULL chars + void CleanName(std::string& str) const; + ///Decodes the type of attribute into the existing ones + void DecodeType(unsigned int& type) const; + + bool isDateEntry() const; + bool isTimeEntry() const; + private: std::string mKey; std::string mName; @@ -62,16 +101,7 @@ namespace creaImageIO } // EO namespace creaImageIO -/* -//===================================================================== -inline std::ostream& operator<<(std::ostream& s, -const creaImageIO::tree::AttributeDescriptor& d) -{ -s << "[" << d.key << ":" << d.name << "]"; -return s; -} -//===================================================================== -*/ + #endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__