]> Creatis software - creaImageIO.git/blobdiff - src/creaImageIOTreeAttributeDescriptor.h
move directory
[creaImageIO.git] / src / creaImageIOTreeAttributeDescriptor.h
diff --git a/src/creaImageIOTreeAttributeDescriptor.h b/src/creaImageIOTreeAttributeDescriptor.h
new file mode 100644 (file)
index 0000000..1ae86dd
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
+#define __creaImageIOTreeAttributeDescriptor_h_INCLUDED__
+
+#include <string>
+//#include <iostream>
+
+namespace creaImageIO
+{
+
+  namespace tree
+  {
+         /**
+       * \ingroup Tree
+       */
+    //=====================================================================
+    /// 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 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;
+          /// The attribute can be edited
+      static const unsigned int EDITABLE;
+
+         /// 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 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
+      unsigned short GetGroup() const { return mGroup; }
+      /// Returns the DICOM element code of the attribute
+      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;
+
+         /// Determines if Attribute is a date
+         bool isDateEntry() const;
+
+         /// Determines if Attribute is a time
+         bool isTimeEntry() const;
+
+    private:
+      std::string mKey;
+      std::string mName;
+      unsigned short mGroup;
+      unsigned short mElement;
+      unsigned int mFlags;
+    };
+    // EO class AttributeDescriptor
+    //=====================================================================
+
+   
+
+  } // EO namespace tree
+
+} // EO namespace creaImageIO
+
+
+
+
+
+#endif // #ifndef __creaImageIOTreeAttributeDescriptor_h_INCLUDED__