#ifndef __creaImageIODicomNode_h_INCLUDED__ #define __creaImageIODicomNode_h_INCLUDED__ #include #include #include namespace creaImageIO { //===================================================================== /// Forward declaration class DicomDatabase; //===================================================================== //===================================================================== /// struct DicomNodeData { DicomNodeData() {} virtual ~DicomNodeData() {} }; //===================================================================== //===================================================================== class DicomNode { public: /// The identifier of "Database" node types (root of a tree) static const int Database; /// The identifier of "Patient" node types static const int Patient; /// The identifier of "Study" node types static const int Study; /// The identifier of "Series" node types static const int Series; /// The identifier of "Image" node types static const int Image; typedef int Type; /// Ctor DicomNode(Type type, DicomDatabase* db, DicomNode* parent); virtual ~DicomNode(); Type GetType() const { return mType; } const std::string& GetTypeName() const; static const std::string& GetTypeName(const Type&); static const std::string& GetPluralTypeName(const Type&); const DicomNodeTypeDescription& GetTypeDescription() const; DicomDatabase* GetDicomDatabase() const { return mDicomDatabase; } // Tree* GetTree() const; DicomNode* GetParent() const { return mParent; } bool ChildrenLoaded() const { return mChildrenLoaded; } void SetChildrenLoaded(bool l) { mChildrenLoaded = l; } /// returns the number of children of the node. /// Warning : a non null number of children does not mean that they /// are loaded ! int GetNumberOfChildren(); typedef std::vector ChildrenListType; ChildrenListType& GetChildrenList() { return mChildren; } const ChildrenListType& GetChildrenList() const { return mChildren; } void RemoveChildrenFromList(DicomNode*); typedef std::map FieldValueMapType; FieldValueMapType& GetFieldValueMap() { return mFieldValueMap; } const FieldValueMapType& GetFieldValueMap() const { return mFieldValueMap; } const Field::Value& GetFieldValue(const Field::Key& k) const; const Field::Value& GetCleanFieldValue(const Field::Key& k) const; const Field::Value& UnsafeGetFieldValue(const Field::Key& k) const { return mFieldValueMap.find(k)->second; } void SetFieldValue(const Field::Key& k, const Field::Value& v); void UnsafeSetFieldValue(const Field::Key& k, const Field::Value& v) { mFieldValueMap[k] = v; } const Field::Description& GetFieldDescription(const Field::Key& k) const { return GetTypeDescription().GetFieldDescription(k); } virtual void Print() const; std::string GetLabel() const; template T GetData() const { if (mData!=0) return dynamic_cast(mData); return 0; } void SetData(DicomNodeData* d) { if (mData) delete mData; mData = d; } void SortChildren(const LexicographicalDicomNodeComparator&); protected: DicomDatabase* mDicomDatabase; private: Type mType; DicomNode* mParent; ChildrenListType mChildren; FieldValueMapType mFieldValueMap; DicomNodeData* mData; bool mChildrenLoaded; int mNumberOfChildren; }; // class DicomNode //===================================================================== } // namespace creaImageIO #endif // #ifndef __creaImageIODicomNode_h_INCLUDED__