1 #ifndef __creaImageIOGimmick_h_INCLUDED__
2 #define __creaImageIOGimmick_h_INCLUDED__
4 #include <creaImageIOSQLiteTreeHandler.h>
5 #include <creaImageIOTreeHandlerImageAdder.h>
6 #include <creaImageIOSynchron.h>
7 #include <creaImageIOSettings.h>
11 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
18 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
24 #ifdef TRACKING_MEMORY_LEAKS
26 #pragma warning(disable : 4291)
29 void * operator new( size_t size, int line, const char *file );
30 void * operator new[]( size_t size, int line, const char *file );
31 void operator delete( void *p );
32 void operator delete[]( void *p );
38 #define OMISCID_NEW new( __LINE__, __FILE__ )
40 #else // TRACKING_MEMORY_LEAKS is not defined
42 #define OMISCID_NEW new
50 * \defgroup Controller Controller
56 * \defgroup Model Model
59 * \defgroup GUI Top level graphical user interfaces
62 * \defgroup IO Image I/O classes
65 * \defgroup Tree Attributed tree management
68 * \defgroup Previewer Preview related
75 //=======================================================================
76 /// Central controler of the gimmick application
77 class CREAIMAGEIO_EXPORT Gimmick
86 typedef TreeHandlerImageAdder::Progress AddProgress;
87 typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
89 /// Adds the function f to the list of functions to call
90 /// when addition operations progres.
91 /// f is of type AddProgressCallbackType which is:
92 /// void (*AddProgressCallbackType)(AddProgress&)
93 /// To pass a member function 'f' of an instance 'c' of a class 'C'
94 /// as callback you have to 'bind' it, i.e. call:
95 /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
96 void ConnectAddProgressObserver( AddProgressCallbackType callback )
97 { mImageAdder.ConnectProgressObserver(callback); }
100 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
102 /// Initializes with default values (read/creates databases, etc.)
105 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
106 void Initialize(const std::string& namedescp, const std::string namedb = "Local Database");
108 /// Finalize (closes databases, etc.)
111 /// Sets level for messages "Gimmick!"
112 static void SetMessageLevel(int level);
113 /// Sets level for debug messages "Gimmick! DEBUG"
114 static void SetDebugMessageLevel(int level);
116 /// Type of map from TreeHandler name to TreeHandler*
117 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
119 /// Returns the TreeHandlerMap (ref)
120 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
121 /// Returns the TreeHandlerMap (const ref)
122 const TreeHandlerMapType& GetTreeHandlerMap() const
123 { return mTreeHandlerMap; }
125 /// Add the files to the given TreeHandler
126 void AddFiles(const std::string& handler,
127 const std::vector<std::string>& filenames);
129 /// Add a dir to the given TreeHandler
130 void AddDir(const std::string& handler, const std::string& path,
133 /// Removes a file from the given TreeHandler
134 void RemoveFile(const std::string& d,
135 tree::Node* filename);
137 ///Deletes the given drive name from the databases
138 void DeleteDrive(const std::string& drive);
141 /// Copies the files into the local directory
142 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
145 ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
146 ///only a warning sign will be issued
147 std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
149 /// Prints the tree handled by the handler
150 void Print(const std::string& handler);
152 ///create a DB from a given descriptor file and for a specific location
153 SQLiteTreeHandler* createDB(const std::string &i_name,
154 const std::string &i_locDesc,
155 const std::string &i_locDB);
157 /// add an existent DB
158 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
160 /// Returns the TreeHandler with a given name
161 TreeHandler* GetTreeHandler(const std::string& name) const;
164 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
166 const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; }
168 ///Returns the given setting value for the given setting parameter
169 void GetSetting(const std::string& name, std::string& value);
171 ///Updates the settings file
172 void UpdateSetting(const std::string& name, const std::string& value);
174 /// add DB from Settings file
175 void addDBSettings();
177 ///Edits the field described by the name and key provided with the value given
178 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
180 /// Returns the attributes in results described in params
181 void GetAttributes(const std::string& d,
182 const std::string& filename,
183 const std::vector<std::string>& params,
184 std::vector<std::string>& results);
187 const std::string& GetHomeDirectory();
188 const std::string& GetUserSettingsDirectory();
189 void CreateUserSettingsDirectory();
190 const std::string& GetLocalDatabasePath();
194 //=============================================
196 SQLiteTreeHandler* mLocalDatabase;
197 TreeHandlerMapType mTreeHandlerMap;
198 Synchronizer* mSynchronizer;
200 std::string mCurrentDirectory;
201 std::string mHomeDirectory;
202 std::string mUserSettingsDirectory;
203 std::string mLocalDatabasePath;
205 TreeHandlerImageAdder mImageAdder;
206 std::string mLocalDBName;
207 std::string mLocalDescpName;
210 //=======================================================================
213 } // EO namespace creaImageIO