X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOTreeNode.h;h=5b221de611009e0ef07009df3e944730d1fde3d1;hb=refs%2Ftags%2FEED.02Oct2009;hp=d69051bbe89cdfadb65ac25060231e841fd5cc25;hpb=f08880c40f6304be640c7f8702bbbe96f8d50b40;p=creaImageIO.git diff --git a/src2/creaImageIOTreeNode.h b/src2/creaImageIOTreeNode.h index d69051b..5b221de 100644 --- a/src2/creaImageIOTreeNode.h +++ b/src2/creaImageIOTreeNode.h @@ -3,16 +3,18 @@ #include #include +#include #include #include + namespace creaImageIO { namespace tree { /** - * \ingroup Model + * \ingroup Tree */ //===================================================================== /// Forward declaration of Tree @@ -20,7 +22,7 @@ namespace creaImageIO //===================================================================== //===================================================================== - /// Abstract class to store user data on a tree node + /// Abstract class to store user data on a Tree node struct NodeData { NodeData() {} @@ -30,7 +32,7 @@ namespace creaImageIO //===================================================================== - /// Node of an attributed tree structure + /// Node of an attributed Tree structure class Node { public: @@ -81,25 +83,33 @@ namespace creaImageIO const ChildrenListType& GetChildrenList() const { return mChildren; } /// Remove the given children from the children list - void RemoveChildrenFromList(Node*); - + int RemoveChildrenFromList(Node*); + + /// Get the Attributes Map AttributeMapType& GetAttributeMap() { return mAttributeMap; } + + /// Get the Attributes Map const AttributeMapType& GetAttributeMap() const { return mAttributeMap; } + + /// Get the Attribute for a specific key const std::string& GetAttribute(const std::string& k) const; - const std::string& GetCleanAttribute(const std::string& k) const; - const std::string& UnsafeGetAttribute(const std::string& k) const - { return mAttributeMap.find(k)->second; } + + /// Get the Attribute for a specific key without OS dependance (not implemented) + // TODO : backslash OS uniformity + const std::string& GetCleanAttribute(const std::string& k) const; + + /// Set an Attribute for a specific key void SetAttribute(const std::string& k, const std::string& v); + + /// Set an Attribute for a specific key(unsafe mode) void UnsafeSetAttribute(const std::string& k, const std::string& v) { mAttributeMap[k] = v; } - const AttributeDescriptor& GetAttributeDescriptor(const std::string& k) - const; - // { return GetTypeDescription().GetFieldDescription(k); } - - - /// Returns true iff the KEY attributes of the node match those of the map provided + /// Get Descriptor for an Attribute + const AttributeDescriptor& GetAttributeDescriptor(const std::string& k)const; + + /// Returns true if the KEY attributes of the node match those of the map provided bool Matches( const AttributeMapType& ) const; /// Returns the node data casted into the type T @@ -107,20 +117,17 @@ namespace creaImageIO { if (mData!=0) return dynamic_cast(mData); return 0; } /// Sets the node data. Deletes existing data if any. - void SetData(NodeData* d) { if (mData) delete mData; mData = d; } + void SetData(boost::shared_ptr d) { mData = d; }//{ if (mData) delete mData; mData = d; } /// Sorts the children of the node void SortChildren(const LexicographicalComparator&); - + /// Print the node virtual void Print() const; + + /// Get the Label of the node std::string GetLabel() const; - /* - int ImageGetRows() const; - int ImageGetColumns() const; - int ImageGetFrames() const; - const std::string& ImageGetFullFileName() const { return UnsafeGetAttribute("FullFileName"); } - */ + private: /// The parent of the node @@ -130,7 +137,7 @@ namespace creaImageIO /// The map of attributes AttributeMapType mAttributeMap; /// User data - NodeData* mData; + boost::shared_ptr mData; /// Are the children loaded ? bool mChildrenLoaded; /// The number of children