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>
12 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
18 #ifdef TRACKING_MEMORY_LEAKS
20 #pragma warning(disable : 4291)
23 void * operator new( size_t size, int line, const char *file );
24 void * operator new[]( size_t size, int line, const char *file );
25 void operator delete( void *p );
26 void operator delete[]( void *p );
32 #define OMISCID_NEW new( __LINE__, __FILE__ )
34 #else // TRACKING_MEMORY_LEAKS is not defined
36 #define OMISCID_NEW new
44 * \defgroup Controller Controller
50 * \defgroup Model Model
53 * \defgroup GUI Top level graphical user interfaces
56 * \defgroup IO Image I/O classes
59 * \defgroup Tree Attributed tree management
62 * \defgroup Previewer Preview related
69 //=======================================================================
70 /// Central controler of the gimmick application
71 class CREAIMAGEIO_EXPORT Gimmick
80 typedef TreeHandlerImageAdder::Progress AddProgress;
81 typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
83 /// Adds the function f to the list of functions to call
84 /// when addition operations progres.
85 /// f is of type AddProgressCallbackType which is:
86 /// void (*AddProgressCallbackType)(AddProgress&)
87 /// To pass a member function 'f' of an instance 'c' of a class 'C'
88 /// as callback you have to 'bind' it, i.e. call:
89 /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
90 void ConnectAddProgressObserver( AddProgressCallbackType callback )
91 { mImageAdder.ConnectProgressObserver(callback); }
94 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
96 /// Initializes with default values (read/creates databases, etc.)
99 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
100 void Initialize(const std::string& path);
102 /// Finalize (closes databases, etc.)
105 /// Sets level for messages "Gimmick!"
106 static void SetMessageLevel(int level);
107 /// Sets level for debug messages "Gimmick! DEBUG"
108 static void SetDebugMessageLevel(int level);
110 /// Type of map from TreeHandler name to TreeHandler*
111 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
113 /// Returns the TreeHandlerMap (ref)
114 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
115 /// Returns the TreeHandlerMap (const ref)
116 const TreeHandlerMapType& GetTreeHandlerMap() const
117 { return mTreeHandlerMap; }
119 /// Add the files to the given TreeHandler
120 void AddFiles(const std::string& handler,
121 const std::vector<std::string>& filenames);
123 /// Add a dir to the given TreeHandler
124 void AddDir(const std::string& handler, const std::string& path,
127 /// Removes a file from the given TreeHandler
128 void RemoveFile(const std::string& d,
129 tree::Node* filename);
131 ///Deletes the given drive name from the databases
132 void DeleteDrive(const std::string& drive);
135 /// Copies the files into the local directory
136 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
139 ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
140 ///only a warning sign will be issued
141 std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
143 /// Prints the tree handled by the handler
144 void Print(const std::string& handler);
146 ///create a DB from a given descriptor file and for a specific location
147 SQLiteTreeHandler* createDB(const std::string &i_name,
148 const std::string &i_locDesc,
149 const std::string &i_locDB);
151 /// add an existent DB
152 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
154 /// Returns the TreeHandler with a given name
155 TreeHandler* GetTreeHandler(const std::string& name) const;
158 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
160 const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; }
162 ///Returns the given setting value for the given setting parameter
163 void GetSetting(const std::string& name, std::string& value);
165 ///Updates the settings file
166 void UpdateSetting(const std::string& name, const std::string& value);
168 /// add DB from Settings file
169 void addDBSettings();
171 ///Edits the field described by the name and key provided with the value given
172 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
174 /// Returns the attributes in results described in params
175 void GetAttributes(const std::string& d,
176 const std::string& filename,
177 const std::vector<std::string>& params,
178 std::vector<std::string>& results);
181 const std::string& GetHomeDirectory();
182 const std::string& GetUserSettingsDirectory();
183 void CreateUserSettingsDirectory();
184 const std::string& GetLocalDatabasePath();
188 //=============================================
190 SQLiteTreeHandler* mLocalDatabase;
191 TreeHandlerMapType mTreeHandlerMap;
192 Synchronizer* mSynchronizer;
194 std::string mCurrentDirectory;
195 std::string mHomeDirectory;
196 std::string mUserSettingsDirectory;
197 std::string mLocalDatabasePath;
199 TreeHandlerImageAdder mImageAdder;
202 //=======================================================================
205 } // EO namespace creaImageIO