]> Creatis software - creaImageIO.git/blob - src2/creaImageIOGimmick.h
Typo
[creaImageIO.git] / src2 / creaImageIOGimmick.h
1 #ifndef __creaImageIOGimmick_h_INCLUDED__
2 #define __creaImageIOGimmick_h_INCLUDED__
3
4 #include <creaImageIOSQLiteTreeHandler.h>
5 #include <creaImageIOTreeHandlerImageAdder.h>
6 #include <creaImageIOSynchron.h>
7 #include <creaImageIOSettings.h>
8
9 namespace creaImageIO
10 {
11         /**
12         * \defgroup Controller Controller
13         */
14         /**
15         * \defgroup View View
16         */
17         /**
18         * \defgroup Model Model
19         */
20         /**
21         * \defgroup GUI Top level graphical user interfaces
22         */
23         /**
24         * \defgroup IO Image I/O classes
25         */
26         /**
27         * \defgroup Tree Attributed tree management
28         */
29         /**
30         * \defgroup Previewer Preview related
31         */
32
33         /**
34         * \ingroup Controller
35         */
36
37   //=======================================================================
38   /// Central controler of the gimmick application
39   class CREAIMAGEIO_EXPORT Gimmick
40   {
41   public:
42     /// Ctor
43     Gimmick();
44     /// Dtor
45     ~Gimmick();
46     
47     ///
48     typedef TreeHandlerImageAdder::Progress AddProgress;
49     typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
50     
51     /// Adds the function f to the list of functions to call 
52     /// when addition operations progres.
53     /// f is of type AddProgressCallbackType which is:
54     /// void (*AddProgressCallbackType)(AddProgress&)
55     /// To pass a member function 'f' of an instance 'c' of a class 'C' 
56     /// as callback you have to 'bind' it, i.e. call:
57     /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
58      void ConnectAddProgressObserver( AddProgressCallbackType callback )
59     { mImageAdder.ConnectProgressObserver(callback); }
60     
61     ///
62     const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
63
64     /// Initializes with default values (read/creates databases, etc.)
65     void Initialize();
66
67         /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
68     void Initialize(const std::string& path);
69     
70     /// Finalize (closes databases, etc.)
71     void Finalize();
72
73     /// Sets level for messages "Gimmick!" 
74     static void SetMessageLevel(int level);
75     /// Sets level for debug messages "Gimmick! DEBUG" 
76     static void SetDebugMessageLevel(int level);
77     
78     /// Type of map from TreeHandler name to TreeHandler*
79     typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
80
81     /// Returns the TreeHandlerMap (ref)
82     TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
83     /// Returns the TreeHandlerMap (const ref)
84     const TreeHandlerMapType& GetTreeHandlerMap() const
85     { return mTreeHandlerMap; }    
86
87     /// Add the files to the given TreeHandler
88     void AddFiles(const std::string& handler,
89                   const std::vector<std::string>& filenames);
90
91     /// Add a dir to the given TreeHandler
92     void AddDir(const std::string& handler, const std::string& path, 
93                 bool recurse);
94
95         /// Removes a file from the given TreeHandler
96         void RemoveFile(const std::string& d, 
97                         tree::Node* filename);
98
99         ///Deletes the given drive name from the databases
100         void DeleteDrive(const std::string& drive);
101   
102
103         /// Copies the files into the local directory
104         void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
105   
106
107         ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise 
108         ///only a warning sign will be issued
109         std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
110
111     /// Prints the tree handled by the handler
112     void Print(const std::string& handler);
113         
114     ///create a DB from a given descriptor file and for a specific location
115     SQLiteTreeHandler *createDB(const std::string &i_name, 
116                                 const std::string &i_locDesc, 
117                                 const std::string &i_locDB);
118
119         /// add an existent DB 
120         void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
121
122     /// Returns the TreeHandler with a given name
123     TreeHandler* GetTreeHandler(const std::string& name) const;
124
125         /// 
126     SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
127
128     const SQLiteTreeHandler* GetLocalDatabase() const 
129     { return mLocalDatabase; }
130
131         ///Returns the given setting value for the given setting parameter
132         void GetSetting(const std::string& name, std::string& value);
133
134         ///Updates the settings file
135         void UpdateSetting(const std::string& name, const std::string& value);
136
137         /// add DB from Settings file
138     void addDBSettings();
139
140         ///Edits the field described by the name and key provided with the value given
141         void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
142
143         /// Returns the attributes in results described in params
144         void GetAttributes(const std::string& d, 
145           const std::string& filename, 
146           const std::vector<std::string>& params, 
147           std::vector<std::string>& results);
148   
149     /// 
150     const std::string& GetHomeDirectory();
151     const std::string& GetUserSettingsDirectory();
152     void CreateUserSettingsDirectory();
153     const std::string& GetLocalDatabasePath();
154         
155
156
157     //=============================================
158   private:
159     SQLiteTreeHandler* mLocalDatabase;
160         TreeHandlerMapType mTreeHandlerMap;
161         Synchronizer* mSynchronizer;
162
163     std::string mCurrentDirectory;
164     std::string mHomeDirectory;
165     std::string mUserSettingsDirectory;
166     std::string mLocalDatabasePath;
167         Settings        *mSettings;
168     TreeHandlerImageAdder mImageAdder;
169   };
170   // EO class Gimmick
171   //=======================================================================
172
173
174 } // EO namespace creaImageIO
175
176 // EOF
177 #endif  
178
179