creaImageIO_lib
creaImageIOGimmick.h
Go to the documentation of this file.
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 #
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
16 #
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
21 # liability.
22 #
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
26 */
27 
28 
29 #ifndef __creaImageIOGimmick_h_INCLUDED__
30 #define __creaImageIOGimmick_h_INCLUDED__
31 
34 #include <creaImageIOSynchron.h>
35 #include <creaImageIOSettings.h>
36 
37 
38 
39 
40 #ifdef _DEBUG
41 #include <crtdbg.h>
42 #define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)
43 #else
44 #define DEBUG_NEW new
45 #endif
46 // Only when asked
47 /*
48 #ifdef TRACKING_MEMORY_LEAKS
49 #ifdef WIN32
50 #pragma warning(disable : 4291)
51 #endif
52 
53 void * operator new( size_t size, int line, const char *file );
54 void * operator new[]( size_t size, int line, const char *file );
55 void operator delete( void *p );
56 void operator delete[]( void *p );
57 
58 #ifdef OMISCID_NEW
59 #undef OMISCID_NEW
60 #endif
61 
62 #define OMISCID_NEW new( __LINE__, __FILE__ )
63 
64 #else // TRACKING_MEMORY_LEAKS is not defined
65 
66 #define OMISCID_NEW new
67 
68 #endif*/
69 
70 
71 namespace creaImageIO
72 {
99  //=======================================================================
101 
102 
103 
105  typedef struct
106  {
107  // name of database to get attributes
108  std::string db;
109  // attributes available in this databse
110  std::vector<std::string> inside;
111  // attributes not available in this databse
112  std::vector<std::string> outside;
113  //
114  bool mult;
115  }OutputAttr;
116 
118  {
119  public:
121  Gimmick();
123  ~Gimmick();
124 
128 
136  void ConnectAddProgressObserver( AddProgressCallbackType callback )
137  { mImageAdder.ConnectProgressObserver(callback); }
138 
140  const AddProgress& GetAddProgress() const { return mImageAdder.GetProgress(); }
141 
143  void Initialize();
144 
146  void Initialize(const std::string namedescp, const std::string namedb = "Local Database");
147 
149  void Finalize();
150 
152  static void SetMessageLevel(int level);
154  static void SetDebugMessageLevel(int level);
155 
157  typedef std::map<std::string, TreeHandler*> TreeHandlerMapType;
158 
159  typedef std::map<std::string, TreeHandler*>::const_iterator ItTreeHandlerMap;
160 
162  TreeHandlerMapType& GetTreeHandlerMap() { return mTreeHandlerMap; }
163 
165  const TreeHandlerMapType& GetTreeHandlerMap() const
166  { return mTreeHandlerMap; }
167 
169  void AddFiles(const std::string& handler,
170  const std::vector<std::string>& filenames);
171 
173  void AddDir(const std::string& handler, const std::string& path,
174  bool recurse);
175 
177  void RemoveFile(const std::string& d,
178  tree::Node* filename);
179 
181  void DeleteDrive(const std::string& drive);
182 
183 
185  void CopyFiles(const std::vector<std::string>& filenames, const std::string& d );
186 
187 
190  std::string Synchronize(const std::string& d, bool repair, bool checkAttributes);
191 
193  void Print(const std::string& handler);
194 
196  SQLiteTreeHandler* createDB(const std::string &i_name,
197  const std::string &i_locDesc,
198  const std::string &i_locDB);
199 
201  void addDB(const std::string &i_nameDB, const std::string &i_locationDB);
202 
204  TreeHandler* GetTreeHandler(const std::string& name) const;
205 
207  SQLiteTreeHandler* GetLocalDatabase() { return mLocalDatabase; }
208 
209  const SQLiteTreeHandler* GetLocalDatabase() const { return mLocalDatabase; }
210 
212  void GetSetting(const std::string& name, std::string& value);
213 
215  void UpdateSetting(const std::string& name, const std::string& value);
216 
218  void addDBSettings();
219 
221  void EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val);
222 
224  void GetAttributes(const std::string& d,
225  const std::string& filename,
226  const std::vector<std::string>& params,
227  std::vector<std::string>& results);
228 
230  void GetAttributes(const std::string filename, std::map<std::string, std::string> &i_res, OutputAttr i_attr);
231 
232  const std::string& GetHomeDirectory();
233  const std::string& GetUserSettingsDirectory();
234  void CreateUserSettingsDirectory();
235  const std::string& GetLocalDatabasePath();
236 
238  void fillVectInfos(std::vector<std::string> i_attr, OutputAttr &infos);
239 
241  const std::string getSummary();
242  //=============================================
243  private:
247 
248  std::string mCurrentDirectory;
249  std::string mHomeDirectory;
251  std::string mLocalDatabasePath;
254  std::string mLocalDBName;
255  std::string mLocalDescpName;
256  };
257  // EO class Gimmick
258  //=======================================================================
259 
260 
261 } // EO namespace creaImageIO
262 
263 // EOF
264 #endif
265 
266