X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOTreeHandler.h;h=a454116a17ca9559128cc7c6bceec7f0828a6a81;hb=f08880c40f6304be640c7f8702bbbe96f8d50b40;hp=2986ab4acfbd2b8cd4cedff0a3adb79b3726d2e8;hpb=9bcef355910f147e16a71ae068c1dcb99c1686de;p=creaImageIO.git diff --git a/src2/creaImageIOTreeHandler.h b/src2/creaImageIOTreeHandler.h index 2986ab4..a454116 100644 --- a/src2/creaImageIOTreeHandler.h +++ b/src2/creaImageIOTreeHandler.h @@ -6,14 +6,23 @@ namespace creaImageIO { -/** - * \ingroup Model - */ + + //======================================================================= + //class TreeHandlerStatistics; + //======================================================================= + /** + * \ingroup Model + */ //======================================================================= /// Abstract class which 'handles' a Tree structure class TreeHandler { public: + + ///==================================================================== + // typedef TreeHandlerStatistics Statistics; + ///==================================================================== + ///==================================================================== /// Ctor TreeHandler() {} @@ -72,6 +81,7 @@ namespace creaImageIO ///==================================================================== /// Recursively loads the children of node 'parent' until maxlevel /// is reached. + /// If maxlevel <= 0 then loads all the sub-tree rooted at parent /// If parent == NULL or parent == tree then starts with the 'children' of /// the tree itself. /// Returns the total number of children loaded. @@ -96,7 +106,11 @@ namespace creaImageIO /// Of course the branch is loaded on exit virtual int AddBranch( const AttributeMapType& ) { return -1; } /// Removes the node and its descendants - bool Remove(tree::Node*) { return false; } + virtual bool Remove(tree::Node*) { return false; } + /// Sets an attribute of a Node + virtual bool SetAttribute(tree::Node*, + const std::string& key, + const std::string& value) { return false; } ///==================================================================== @@ -107,7 +121,38 @@ namespace creaImageIO }; // EO class TreeHandler //======================================================================= - + /* + //======================================================================= + /// Memorizes statistics on operations done by a tree handler + /// (nodes created, removed, ...) + class TreeHandlerStatistics + { + public: + ///==================================================================== + /// Ctor + TreeHandler(TreeHandler* tree) : mTreeHandler(tree) { Reset(); } + /// Dtor + ~TreeHandler() {} + /// Resets the stats + void Reset(); + /// Prints the stats + void Print(); + + /// + void CreateNode(int level) { mNumberCreatedNode[level]++; } + void DeleteNode(int level) { mNumberDeletedNode[level]++; } + + protected: + TreeHandler* mTreeHandler; + std::vector mNumberCreatedNode; + std::vector mNumberDeletedNode; + + + ///==================================================================== + }; + // EO class TreeHandlerStatistics + //======================================================================= + */ } // EO namespace creaImageIO