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>
13 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
19 #ifdef TRACKING_MEMORY_LEAKS
21 #pragma warning(disable : 4291)
24 void * operator new( size_t size, int line, const char *file );
25 void * operator new[]( size_t size, int line, const char *file );
26 void operator delete( void *p );
27 void operator delete[]( void *p );
33 #define OMISCID_NEW new( __LINE__, __FILE__ )
35 #else // TRACKING_MEMORY_LEAKS is not defined
37 #define OMISCID_NEW new
45 * \defgroup Controller Controller
51 * \defgroup Model Model
54 * \defgroup GUI Top level graphical user interfaces
57 * \defgroup IO Image I/O classes
60 * \defgroup Tree Attributed tree management
63 * \defgroup Previewer Preview related
70 //=======================================================================
71 /// Central controler of the gimmick application
72 class CREAIMAGEIO_EXPORT Gimmick
81 typedef TreeHandlerImageAdder::Progress AddProgress;
82 typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
84 /// Adds the function f to the list of functions to call
85 /// when addition operations progres.
86 /// f is of type AddProgressCallbackType which is:
87 /// void (*AddProgressCallbackType)(AddProgress&)
88 /// To pass a member function 'f' of an instance 'c' of a class 'C'
89 /// as callback you have to 'bind' it, i.e. call:
90 /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
91 void ConnectAddProgressObserver( AddProgressCallbackType callback )
92 { mImageAdder.ConnectProgressObserver(callback); }
95 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
97 /// Initializes with default values (read/creates databases, etc.)
100 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
101 void Initialize(const std::string namedescp, const std::string namedb = "Local Database");
103 /// Finalize (closes databases, etc.)
106 /// Sets level for messages "Gimmick!"
107 static void SetMessageLevel(int level);
108 /// Sets level for debug messages "Gimmick! DEBUG"
109 static void SetDebugMessageLevel(int level);
111 /// Type of map from TreeHandler name to TreeHandler*
112 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
114 /// Returns the TreeHandlerMap (ref)
115 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
116 /// Returns the TreeHandlerMap (const ref)
117 const TreeHandlerMapType& GetTreeHandlerMap() const
118 { return mTreeHandlerMap; }
120 /// Add the files to the given TreeHandler
121 void AddFiles(const std::string& handler,
122 const std::vector<std::string>& filenames);
124 /// Add a dir to the given TreeHandler
125 void AddDir(const std::string& handler, const std::string& path,
128 /// Removes a file from the given TreeHandler
129 void RemoveFile(const std::string& d,
130 tree::Node* filename);
132 ///Deletes the given drive name from the databases
133 void DeleteDrive(const std::string& drive);
136 /// Copies the files into the local directory
137 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
140 ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
141 ///only a warning sign will be issued
142 std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
144 /// Prints the tree handled by the handler
145 void Print(const std::string& handler);
147 ///create a DB from a given descriptor file and for a specific location
148 SQLiteTreeHandler* createDB(const std::string &i_name,
149 const std::string &i_locDesc,
150 const std::string &i_locDB);
152 /// add an existent DB
153 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
155 /// Returns the TreeHandler with a given name
156 TreeHandler* GetTreeHandler(const std::string& name) const;
159 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
161 const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; }
163 ///Returns the given setting value for the given setting parameter
164 void GetSetting(const std::string& name, std::string& value);
166 ///Updates the settings file
167 void UpdateSetting(const std::string& name, const std::string& value);
169 /// add DB from Settings file
170 void addDBSettings();
172 ///Edits the field described by the name and key provided with the value given
173 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
175 /// Returns the attributes in results described in params
176 void GetAttributes(const std::string& d,
177 const std::string& filename,
178 const std::vector<std::string>& params,
179 std::vector<std::string>& results);
182 const std::string& GetHomeDirectory();
183 const std::string& GetUserSettingsDirectory();
184 void CreateUserSettingsDirectory();
185 const std::string& GetLocalDatabasePath();
189 //=============================================
191 SQLiteTreeHandler* mLocalDatabase;
192 TreeHandlerMapType mTreeHandlerMap;
193 Synchronizer* mSynchronizer;
195 std::string mCurrentDirectory;
196 std::string mHomeDirectory;
197 std::string mUserSettingsDirectory;
198 std::string mLocalDatabasePath;
200 TreeHandlerImageAdder mImageAdder;
201 std::string mLocalDBName;
202 std::string mLocalDescpName;
205 //=======================================================================
208 } // EO namespace creaImageIO