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 /// Initialize (read/creates databases, etc.)
69 /// Finalize (closes databases, etc.)
72 /// Sets level for messages "Gimmick!"
73 static void SetMessageLevel(int level);
74 /// Sets level for debug messages "Gimmick! DEBUG"
75 static void SetDebugMessageLevel(int level);
77 /// Type of map from TreeHandler name to TreeHandler*
78 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
80 /// Returns the TreeHandlerMap (ref)
81 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
82 /// Returns the TreeHandlerMap (const ref)
83 const TreeHandlerMapType& GetTreeHandlerMap() const
84 { return mTreeHandlerMap; }
87 /// Add the files to the given TreeHandler
88 void AddFiles(const std::string& handler,
89 const std::vector<std::string>& filenames);
91 /// Add a dir to the given TreeHandler
92 void AddDir(const std::string& handler, const std::string& path,
95 /// Removes a file from the given TreeHandler
96 void RemoveFile(const std::string& d,
97 tree::Node* filename);
99 ///Deletes the given drive name from the databases
100 void DeleteDrive(const std::string& drive);
103 /// Copies the files into the local directory
104 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
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);
111 /// Prints the tree handled by the handler
112 void Print(const std::string& handler);
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);
119 // add an existent DB
120 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
122 /// Returns the TreeHandler with a given name
123 TreeHandler* GetTreeHandler(const std::string& name) const;
125 /// Returns the TimestampDatabase
126 TimestampDatabaseHandler* GetTimestampDatabase() const;
128 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
130 const SQLiteTreeHandler* GetLocalDatabase() const
131 { return mLocalDatabase; }
133 ///Returns the given setting value for the given setting parameter
134 void GetSetting(const std::string& name, std::string& value);
136 ///Updates the settings file
137 void UpdateSetting(const std::string& name, const std::string& value);
139 /// add DB from Settings file
140 void addDBSettings();
142 ///Edits the field described by the name and key provided with the value given
143 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
146 const std::string& GetHomeDirectory();
147 const std::string& GetUserSettingsDirectory();
148 void CreateUserSettingsDirectory();
149 const std::string& GetLocalDatabasePath();
150 const std::string& GetTimestampDatabasePath();
153 //=============================================
155 SQLiteTreeHandler* mLocalDatabase;
156 TimestampDatabaseHandler* mTimestampDatabase;
157 TreeHandlerMapType mTreeHandlerMap;
158 Synchronizer* mSynchronizer;
160 std::string mCurrentDirectory;
161 std::string mHomeDirectory;
162 std::string mUserSettingsDirectory;
163 std::string mLocalDatabasePath;
164 std::string mTimestampDatabasePath;
166 TreeHandlerImageAdder mImageAdder;
169 //=======================================================================
172 } // EO namespace creaImageIO