1 #ifndef __creaImageIODicomNode_h_INCLUDED__
2 #define __creaImageIODicomNode_h_INCLUDED__
4 #include <creaImageIODicomNodeTypeDescription.h>
5 #include <creaImageIODicomNodeComparators.h>
11 //=====================================================================
12 /// Forward declaration
14 //=====================================================================
16 //=====================================================================
21 virtual ~DicomNodeData() {}
23 //=====================================================================
26 //=====================================================================
31 /// The identifier of "Database" node types (root of a tree)
32 static const int Database;
33 /// The identifier of "Patient" node types
34 static const int Patient;
35 /// The identifier of "Study" node types
36 static const int Study;
37 /// The identifier of "Series" node types
38 static const int Series;
39 /// The identifier of "Image" node types
40 static const int Image;
45 DicomNode(Type type, DicomDatabase* db, DicomNode* parent);
49 Type GetType() const { return mType; }
50 const std::string& GetTypeName() const;
52 static const std::string& GetTypeName(const Type&);
53 static const std::string& GetPluralTypeName(const Type&);
55 const DicomNodeTypeDescription& GetTypeDescription() const;
57 DicomDatabase* GetDicomDatabase() const { return mDicomDatabase; }
58 // Tree* GetTree() const;
59 DicomNode* GetParent() const { return mParent; }
61 bool ChildrenLoaded() const { return mChildrenLoaded; }
62 void SetChildrenLoaded(bool l) { mChildrenLoaded = l; }
64 /// returns the number of children of the node.
65 /// Warning : a non null number of children does not mean that they
67 int GetNumberOfChildren();
70 typedef std::vector<DicomNode*> ChildrenListType;
71 ChildrenListType& GetChildrenList() { return mChildren; }
72 const ChildrenListType& GetChildrenList() const { return mChildren; }
73 void RemoveChildrenFromList(DicomNode*);
75 typedef std::map<Field::Key,Field::Value> FieldValueMapType;
76 FieldValueMapType& GetFieldValueMap() { return mFieldValueMap; }
77 const FieldValueMapType& GetFieldValueMap() const { return mFieldValueMap; }
78 const Field::Value& GetFieldValue(const Field::Key& k) const;
79 const Field::Value& GetCleanFieldValue(const Field::Key& k) const;
80 const Field::Value& UnsafeGetFieldValue(const Field::Key& k) const
81 { return mFieldValueMap.find(k)->second; }
82 void SetFieldValue(const Field::Key& k, const Field::Value& v);
83 void UnsafeSetFieldValue(const Field::Key& k, const Field::Value& v)
84 { mFieldValueMap[k] = v; }
86 const Field::Description& GetFieldDescription(const Field::Key& k) const
87 { return GetTypeDescription().GetFieldDescription(k); }
90 virtual void Print() const;
91 std::string GetLabel() const;
93 template<class T> T GetData() const
94 { if (mData!=0) return dynamic_cast<T>(mData); return 0; }
96 void SetData(DicomNodeData* d) { if (mData) delete mData; mData = d; }
98 void SortChildren(const LexicographicalDicomNodeComparator&);
101 int ImageGetRows() const;
102 int ImageGetColumns() const;
103 int ImageGetFrames() const;
104 const std::string& ImageGetFullFileName() const { return UnsafeGetFieldValue("FullFileName"); }
107 DicomDatabase* mDicomDatabase;
112 ChildrenListType mChildren;
113 FieldValueMapType mFieldValueMap;
114 DicomNodeData* mData;
115 bool mChildrenLoaded;
116 int mNumberOfChildren;
118 }; // class DicomNode
119 //=====================================================================
124 } // namespace creaImageIO
128 #endif // #ifndef __creaImageIODicomNode_h_INCLUDED__