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); }
62 const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
64 /// Initializes with default values (read/creates databases, etc.)
67 /// Initializes with the local database descriptor in the path given (read/creates databases, etc.)
68 void Initialize(const std::string& path);
70 /// Finalize (closes databases, etc.)
73 /// Sets level for messages "Gimmick!"
74 static void SetMessageLevel(int level);
75 /// Sets level for debug messages "Gimmick! DEBUG"
76 static void SetDebugMessageLevel(int level);
78 /// Type of map from TreeHandler name to TreeHandler*
79 typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
81 /// Returns the TreeHandlerMap (ref)
82 TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
83 /// Returns the TreeHandlerMap (const ref)
84 const TreeHandlerMapType& GetTreeHandlerMap() const
85 { 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;
126 SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
128 const SQLiteTreeHandler* GetLocalDatabase() const
129 { return mLocalDatabase; }
131 ///Returns the given setting value for the given setting parameter
132 void GetSetting(const std::string& name, std::string& value);
134 ///Updates the settings file
135 void UpdateSetting(const std::string& name, const std::string& value);
137 /// add DB from Settings file
138 void addDBSettings();
140 ///Edits the field described by the name and key provided with the value given
141 void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
143 /// Returns the attributes in results described in params
144 void GetAttributes(const std::string& d,
145 const std::string& filename,
146 const std::vector<std::string>& params,
147 std::vector<std::string>& results);
150 const std::string& GetHomeDirectory();
151 const std::string& GetUserSettingsDirectory();
152 void CreateUserSettingsDirectory();
153 const std::string& GetLocalDatabasePath();
157 //=============================================
159 SQLiteTreeHandler* mLocalDatabase;
160 TreeHandlerMapType mTreeHandlerMap;
161 Synchronizer* mSynchronizer;
163 std::string mCurrentDirectory;
164 std::string mHomeDirectory;
165 std::string mUserSettingsDirectory;
166 std::string mLocalDatabasePath;
168 TreeHandlerImageAdder mImageAdder;
171 //=======================================================================
174 } // EO namespace creaImageIO