1 #ifndef __creaImageIOTreeHandler_h_INCLUDED__
2 #define __creaImageIOTreeHandler_h_INCLUDED__
4 #include <creaImageIOTree.h>
10 //=======================================================================
11 /// Abstract class which 'handles' a Tree structure
15 ///====================================================================
19 virtual ~TreeHandler() {}
20 ///====================================================================
22 ///====================================================================
23 /// Returns the Tree handled
24 tree::Tree& GetTree() { return mTree; }
25 /// Returns the Tree handled (const)
26 const tree::Tree& GetTree() const { return mTree; }
27 ///====================================================================
29 ///====================================================================
31 /// Is the 'source' readable ?
32 virtual bool IsReadable() { return false; }
33 /// Is the 'source' writable ?
34 virtual bool IsWritable() { return false; }
35 ///====================================================================
38 ///====================================================================
39 /// INITIALIZATION / FINALIZATION
40 ///====================================================================
42 ///====================================================================
43 /// Opens an existing 'source'
44 /// Default mode is read only
45 /// If IsWritable and writable==true then opens in read/write mode
46 virtual bool Open(bool writable = false) { return false; }
47 /// Closes the 'source'
48 virtual bool Close() { return false; }
49 /// Creates a new 'source'
50 /// Default mode is read only
51 /// If IsWritable and writable==true then opens in read/write mode
52 virtual bool Create(bool writable = false) { return false; }
53 /// Destroys the 'source'
54 virtual bool Destroy() { return false; }
55 ///====================================================================
58 ///====================================================================
60 ///====================================================================
63 ///====================================================================
64 /// Returns the number of children of the Node *WITHOUT LOADING THEM*
65 /// REM : The Tree itself is a Node and asking for its number of
66 /// children returns the number of children of level 1.
67 virtual unsigned int GetNumberOfChildren(tree::Node* n) { return 0; }
68 ///====================================================================
70 ///====================================================================
71 /// Recursively loads the children of node 'parent' until maxlevel
73 /// If parent == NULL or parent == tree then starts with the 'children' of
75 /// Returns the total number of children loaded.
76 virtual int LoadChildren(tree::Node* parent, int maxlevel)
78 ///====================================================================
80 ///====================================================================
81 /// Unloads the Node and its descendants
82 /// WITHOUT altering the source, e.g. the database
83 virtual void UnLoad(tree::Node* n) { return; }
84 ///====================================================================
87 ///====================================================================
88 /// WRITE METHODS : WORK ONLY IN WRITE MODE
89 ///====================================================================
90 /// Adds a branch in the tree with the attributes provided
91 /// returns the Level in the tree where the branch was connected
92 /// (-1 for error, 0 for top level, etc. )
93 /// Of course the branch is loaded on exit
95 ( const std::map<std::string,std::string>& attr ) { return -1; }
96 /// Removes the node and its descendants
97 bool Remove(tree::Node*) { return false; }
98 ///====================================================================
106 // EO class TreeHandler
107 //=======================================================================
110 } // EO namespace creaImageIO