creaImageIOTreeNode.h

Go to the documentation of this file.
00001 #ifndef __creaImageIOTreeNode_h_INCLUDED__
00002 #define __creaImageIOTreeNode_h_INCLUDED__
00003 
00004 #include <creaImageIOTreeDescriptor.h>
00005 #include <creaImageIOTreeComparators.h>
00006 #include <vector>
00007 #include <map>
00008 
00009 namespace creaImageIO
00010 {
00011 
00012   namespace tree
00013   {
00017     //=====================================================================
00019     class Tree;
00020     //=====================================================================  
00021     
00022     //=====================================================================
00024     struct NodeData
00025     { 
00026       NodeData() {}
00027       virtual ~NodeData() {}
00028     };
00029     //=====================================================================
00030 
00031 
00032     //=====================================================================
00034     class Node
00035     {
00036     public:
00037       typedef std::map<std::string,std::string> AttributeMapType;
00038 
00039 
00041       Node(Node* parent);
00043       Node(Node* parent, const AttributeMapType& );
00045       virtual ~Node();
00046 
00048       void InitializeAttributeMap();
00049  
00051       const LevelDescriptor& GetLevelDescriptor() const;
00052 
00053 
00055       virtual Tree* GetTree() { return mParent->GetTree(); }
00057       virtual const Tree* GetTree() const { return mParent->GetTree(); }
00059       virtual int GetLevel() const { return mParent->GetLevel()+1; }
00060 
00062       Node* GetParent() const { return mParent; }
00063 
00068       unsigned int GetNumberOfChildren() const { return mChildren.size(); }
00069 
00071       bool GetChildrenLoaded() const { return mChildrenLoaded; }
00072 
00074       void SetChildrenLoaded(bool l) { mChildrenLoaded = l; }
00075 
00077       typedef std::vector<Node*> ChildrenListType;
00079       ChildrenListType& GetChildrenList() { return mChildren; }
00081       const ChildrenListType& GetChildrenList() const { return mChildren; }
00082 
00084       int RemoveChildrenFromList(Node*);
00085 
00086 
00087       AttributeMapType& GetAttributeMap() { return mAttributeMap; }
00088       const AttributeMapType& GetAttributeMap() const { return mAttributeMap; }
00089       const std::string& GetAttribute(const std::string& k) const;
00090       const std::string& GetCleanAttribute(const std::string& k) const;
00091       const std::string& UnsafeGetAttribute(const std::string& k) const
00092       { return mAttributeMap.find(k)->second; }
00093       void SetAttribute(const std::string& k, const std::string& v);
00094       void UnsafeSetAttribute(const std::string& k, const std::string& v)
00095       { mAttributeMap[k] = v; }
00096     
00097       const AttributeDescriptor& GetAttributeDescriptor(const std::string& k)const;
00098       //      { return GetTypeDescription().GetFieldDescription(k); }
00099 
00100 
00102       bool Matches( const AttributeMapType& ) const;
00103 
00105       template<class T> T GetData() const 
00106       { if (mData!=0) return dynamic_cast<T>(mData); return 0; }
00107 
00109       void SetData(NodeData* d) { if (mData) delete mData; mData = d; }
00110 
00112       void SortChildren(const LexicographicalComparator&);
00113 
00114       virtual void Print() const;
00115       std::string GetLabel() const;
00116       /*
00117         int ImageGetRows() const;
00118         int ImageGetColumns() const;
00119         int ImageGetFrames() const;
00120         const std::string& ImageGetFullFileName() const { return UnsafeGetAttribute("FullFileName"); }
00121       */
00122 
00123     private:
00125       Node* mParent;
00127       ChildrenListType mChildren;
00129       AttributeMapType mAttributeMap;
00131       NodeData* mData;
00133       bool mChildrenLoaded;
00135       // int mNumberOfChildren;
00136 
00137     }; // class Node
00138     //=====================================================================
00139 
00140   } // namespace tree
00141 
00142 
00143 } // namespace creaImageIO
00144 
00145 
00146 
00147 #endif // #ifndef __creaImageIOTreeNode_h_INCLUDED__

Generated on Mon Jun 22 10:49:30 2009 for CreaImageIO by  doxygen 1.5.3