1 #ifndef __creaImageIOTreeHandler_h_INCLUDED__
2 #define __creaImageIOTreeHandler_h_INCLUDED__
4 #include <creaImageIOTree.h>
12 //=======================================================================
13 /// Abstract class which 'handles' a Tree structure
17 ///====================================================================
21 virtual ~TreeHandler() {}
22 ///====================================================================
24 ///====================================================================
25 /// Returns the Tree handled
26 tree::Tree& GetTree() { return mTree; }
27 /// Returns the Tree handled (const)
28 const tree::Tree& GetTree() const { return mTree; }
29 ///====================================================================
31 ///====================================================================
33 /// Is the 'source' readable ?
34 virtual bool IsReadable() { return false; }
35 /// Is the 'source' writable ?
36 virtual bool IsWritable() { return false; }
37 ///====================================================================
40 ///====================================================================
41 /// INITIALIZATION / FINALIZATION
42 ///====================================================================
44 ///====================================================================
45 /// Opens an existing 'source'
46 /// Default mode is read only
47 /// If IsWritable and writable==true then opens in read/write mode
48 virtual bool Open(bool writable = false) { return false; }
49 /// Closes the 'source'
50 virtual bool Close() { return false; }
51 /// Creates a new 'source'
52 /// Default mode is read only
53 /// If IsWritable and writable==true then opens in read/write mode
54 virtual bool Create(bool writable = false) { return false; }
55 /// Destroys the 'source'
56 virtual bool Destroy() { return false; }
57 ///====================================================================
60 ///====================================================================
62 ///====================================================================
65 ///====================================================================
66 /// Returns the number of children of the Node *WITHOUT LOADING THEM*
67 /// REM : The Tree itself is a Node and asking for its number of
68 /// children returns the number of children of level 1.
69 virtual unsigned int GetNumberOfChildren(tree::Node* n) { return 0; }
70 ///====================================================================
72 ///====================================================================
73 /// Recursively loads the children of node 'parent' until maxlevel
75 /// If parent == NULL or parent == tree then starts with the 'children' of
77 /// Returns the total number of children loaded.
78 virtual int LoadChildren(tree::Node* parent, int maxlevel)
80 ///====================================================================
82 ///====================================================================
83 /// Unloads the Node and its descendants
84 /// WITHOUT altering the source, e.g. the database
85 virtual void UnLoad(tree::Node* n) { return; }
86 ///====================================================================
89 ///====================================================================
90 /// WRITE METHODS : WORK ONLY IN WRITE MODE
91 ///====================================================================
92 typedef tree::Node::AttributeMapType AttributeMapType;
93 /// Adds a branch in the tree with the attributes provided
94 /// returns the Level in the tree where the branch was connected
95 /// (-1 for error, 0 for top level, etc. )
96 /// Of course the branch is loaded on exit
97 virtual int AddBranch( const AttributeMapType& ) { return -1; }
98 /// Removes the node and its descendants
99 bool Remove(tree::Node*) { return false; }
100 ///====================================================================
108 // EO class TreeHandler
109 //=======================================================================
112 } // EO namespace creaImageIO