1 #ifndef __creaImageIOGimmick_h_INCLUDED__
2 #define __creaImageIOGimmick_h_INCLUDED__
4 #include <creaImageIOSQLiteTreeHandler.h>
5 #include <creaImageIOTreeHandlerImageAdder.h>
6 #include <creaImageIOTimestampDatabaseHandler.h>
7 #include <creaImageIOSynchron.h>
8 #include <creaImageIOSettings.h>
13 * \defgroup Controller Controller
19 * \defgroup Model Model
22 * \defgroup GUI Top level graphical user interfaces
25 * \defgroup IO Image I/O classes
28 * \defgroup Tree Attributed tree management
31 * \defgroup Previewer Preview related
38 //=======================================================================
39 /// Central controler of the gimmick application
40 class CREAIMAGEIO_EXPORT Gimmick
49 typedef TreeHandlerImageAdder::Progress AddProgress;
50 typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
52 /// Adds the function f to the list of functions to call
53 /// when addition operations progres.
54 /// f is of type AddProgressCallbackType which is:
55 /// void (*AddProgressCallbackType)(AddProgress&)
56 /// To pass a member function 'f' of an instance 'c' of a class 'C'
57 /// as callback you have to 'bind' it, i.e. call:
58 /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
59 void ConnectAddProgressObserver( AddProgressCallbackType callback )
60 { mImageAdder.ConnectProgressObserver(callback); }
64 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
66 /// Initializes with default values (read/creates databases, etc.)
69 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
70 void Initialize(const std::string& path);
72 /// Finalize (closes databases, etc.)
75 /// Sets level for messages "Gimmick!"
76 static void SetMessageLevel(int level);
77 /// Sets level for debug messages "Gimmick! DEBUG"
78 static void SetDebugMessageLevel(int level);
80 /// Type of map from TreeHandler name to TreeHandler*
81 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
83 /// Returns the TreeHandlerMap (ref)
84 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
85 /// Returns the TreeHandlerMap (const ref)
86 const TreeHandlerMapType& GetTreeHandlerMap() const
87 { return mTreeHandlerMap; }
90 /// Add the files to the given TreeHandler
91 void AddFiles(const std::string& handler,
92 const std::vector<std::string>& filenames);
94 /// Add a dir to the given TreeHandler
95 void AddDir(const std::string& handler, const std::string& path,
98 /// Removes a file from the given TreeHandler
99 void RemoveFile(const std::string& d,
100 tree::Node* filename);
102 ///Deletes the given drive name from the databases
103 void DeleteDrive(const std::string& drive);
106 /// Copies the files into the local directory
107 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
110 ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
111 ///only a warning sign will be issued
112 std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
114 /// Prints the tree handled by the handler
115 void Print(const std::string& handler);
117 ///create a DB from a given descriptor file and for a specific location
118 SQLiteTreeHandler *createDB(const std::string &i_name,
119 const std::string &i_locDesc,
120 const std::string &i_locDB);
122 /// add an existent DB
123 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
125 /// Returns the TreeHandler with a given name
126 TreeHandler* GetTreeHandler(const std::string& name) const;
128 /// Returns the TimestampDatabase
129 TimestampDatabaseHandler* GetTimestampDatabase() const;
131 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
133 const SQLiteTreeHandler* GetLocalDatabase() const
134 { return mLocalDatabase; }
136 ///Returns the given setting value for the given setting parameter
137 void GetSetting(const std::string& name, std::string& value);
139 ///Updates the settings file
140 void UpdateSetting(const std::string& name, const std::string& value);
142 /// add DB from Settings file
143 void addDBSettings();
145 ///Edits the field described by the name and key provided with the value given
146 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
148 /// Returns the attributes in results described in params
149 void GetAttributes(const std::string& d,
150 const std::string& filename,
151 const std::vector<std::string>& params,
152 std::vector<std::string>& results);
155 const std::string& GetHomeDirectory();
156 const std::string& GetUserSettingsDirectory();
157 void CreateUserSettingsDirectory();
158 const std::string& GetLocalDatabasePath();
159 const std::string& GetTimestampDatabasePath();
162 //=============================================
164 SQLiteTreeHandler* mLocalDatabase;
165 TimestampDatabaseHandler* mTimestampDatabase;
166 TreeHandlerMapType mTreeHandlerMap;
167 Synchronizer* mSynchronizer;
169 std::string mCurrentDirectory;
170 std::string mHomeDirectory;
171 std::string mUserSettingsDirectory;
172 std::string mLocalDatabasePath;
173 std::string mTimestampDatabasePath;
175 TreeHandlerImageAdder mImageAdder;
178 //=======================================================================
181 } // EO namespace creaImageIO