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 * \defgroup Controller Controller
18 * \defgroup Model Model
21 * \defgroup GUI Top level graphical user interfaces
24 * \defgroup IO Image I/O classes
27 * \defgroup Tree Attributed tree management
30 * \defgroup Previewer Preview related
37 //=======================================================================
38 /// Central controler of the gimmick application
39 class CREAIMAGEIO_EXPORT Gimmick
48 typedef TreeHandlerImageAdder::Progress AddProgress;
49 typedef TreeHandlerImageAdder::ProgressCallbackType AddProgressCallbackType;
51 /// Adds the function f to the list of functions to call
52 /// when addition operations progres.
53 /// f is of type AddProgressCallbackType which is:
54 /// void (*AddProgressCallbackType)(AddProgress&)
55 /// To pass a member function 'f' of an instance 'c' of a class 'C'
56 /// as callback you have to 'bind' it, i.e. call:
57 /// ConnectAddProgressObserver ( boost::bind( &C::f , c, _1 ) );
58 void ConnectAddProgressObserver( AddProgressCallbackType callback )
59 { mImageAdder.ConnectProgressObserver(callback); }
63 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
65 /// Initializes with default values (read/creates databases, etc.)
68 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
69 void Initialize(const std::string& path);
71 /// Finalize (closes databases, etc.)
74 /// Sets level for messages "Gimmick!"
75 static void SetMessageLevel(int level);
76 /// Sets level for debug messages "Gimmick! DEBUG"
77 static void SetDebugMessageLevel(int level);
79 /// Type of map from TreeHandler name to TreeHandler*
80 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
82 /// Returns the TreeHandlerMap (ref)
83 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
84 /// Returns the TreeHandlerMap (const ref)
85 const TreeHandlerMapType& GetTreeHandlerMap() const
86 { return mTreeHandlerMap; }
89 /// Add the files to the given TreeHandler
90 void AddFiles(const std::string& handler,
91 const std::vector<std::string>& filenames);
93 /// Add a dir to the given TreeHandler
94 void AddDir(const std::string& handler, const std::string& path,
97 /// Removes a file from the given TreeHandler
98 void RemoveFile(const std::string& d,
99 tree::Node* filename);
101 ///Deletes the given drive name from the databases
102 void DeleteDrive(const std::string& drive);
105 /// Copies the files into the local directory
106 void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
109 ///Synchronizes the loaded data with the database d. If repair is true the database will be updated, otherwise
110 ///only a warning sign will be issued
111 std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
113 /// Prints the tree handled by the handler
114 void Print(const std::string& handler);
116 ///create a DB from a given descriptor file and for a specific location
117 SQLiteTreeHandler *createDB(const std::string &i_name,
118 const std::string &i_locDesc,
119 const std::string &i_locDB);
121 /// add an existent DB
122 void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
124 /// Returns the TreeHandler with a given name
125 TreeHandler* GetTreeHandler(const std::string& name) 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);
145 /// Returns the attributes in results described in params
146 void GetAttributes(const std::string& d,
147 const std::string& filename,
148 const std::vector<std::string>& params,
149 std::vector<std::string>& results);
152 const std::string& GetHomeDirectory();
153 const std::string& GetUserSettingsDirectory();
154 void CreateUserSettingsDirectory();
155 const std::string& GetLocalDatabasePath();
159 //=============================================
161 SQLiteTreeHandler* mLocalDatabase;
162 TreeHandlerMapType mTreeHandlerMap;
163 Synchronizer* mSynchronizer;
165 std::string mCurrentDirectory;
166 std::string mHomeDirectory;
167 std::string mUserSettingsDirectory;
168 std::string mLocalDatabasePath;
170 TreeHandlerImageAdder mImageAdder;
173 //=======================================================================
176 } // EO namespace creaImageIO