creaImageIO_lib
creaImageIOTreeHandlerImageAdder.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 #ifndef __creaImageIOTreeHandlerImageAdder_h_INCLUDED__
29 #define __creaImageIOTreeHandlerImageAdder_h_INCLUDED__
30 
31 #include <creaImageIOTreeHandler.h>
32 #include <creaImageIOSynchron.h>
33 #include <creaImageIOImageReader.h>
34 //#include <creaImageIOImageWriter.h>
35 
36 // Signal/slot mechanism for progress events
37 #include <boost/signal.hpp>
38 #include <boost/bind.hpp>
39 #if defined(USE_GDCM2)
41 #endif
42 
43 namespace creaImageIO
44 {
49  //=======================================================================
51 
53  {
54 
55  public:
56  //====================================================================
62  void SetTreeHandler(TreeHandler* tree) { mTreeHandler = tree;}
63 
67  void SetCurrentDatabase(std::string cur){mCurrentDB=cur;}
68  //====================================================================
69 
70  //====================================================================
73  class Progress
74  {
75  public:
76  Progress() { Reset(); }
77  ~Progress() {}
78 
79  void Reset()
80  {
81  mStop = false;
86  }
87 
89  int GetNumberScannedDirs() const { return mNumberScannedDirs; }
91  int GetNumberAddedFiles() const { return mNumberAddedFiles; }
92 
97 
98  void SetStop() { mStop = true; }
99  bool GetStop() const { return mStop; }
100 
101  private:
102  bool mStop;
107  };
108  //=============================================
109 
110  //=============================================
111  const Progress& GetProgress() const { return mProgress; }
112  //=============================================
113 
114  //=============================================
115  typedef boost::signal<void (Progress&)> ProgressSignalType;
116  typedef ProgressSignalType::slot_function_type ProgressCallbackType;
117  //=============================================
118 
119  //==================================================================
128  //==================================================================
129 
130  //====================================================================
132  bool IsHandledFile( const std::string& filename);
134  void AddFiles( const std::vector<std::string>& filename );
136  void AddDirectory( const std::string& directory,
137  bool recurse);
138 
139 
140 #if defined(USE_GDCM2)
141  void AddDirectoryRecursorScanner(const std::string &dirpath,
142  bool recursive,const std::string &addKey, DicomImageScanner i_sc, bool b_loaded);
143 #endif
144 
146  void RemoveFile(tree::Node* node);
148  void RemoveFiles(const std::vector<tree::Node*>& nodes);
149 
150  void remove( tree::Node* i_node);
151 
153  std::string Synchronize(bool repair, bool checkAttributes);
155  void CheckSyncDirectory(const std::string &dirpath,
156  bool recursive,
157  bool repair,
158  bool checkAttributes,
159  std::vector<std::string> &i_ignorefiles,
160  std::vector<std::string> & attsModified,
161  std::vector<std::string> & newfiles);
163  void CopyFiles(const std::vector<std::string>& filenames, const std::string directory );
164 
166  void SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images);
168  void FindNode(tree::Node* parent, int level,
169  const std::string& searchParam,
170  const std::string& searchVal,
171  tree::Node*& node);
172 
174  void FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node);
175 
177  void CheckAttributes(bool repair, std::string& file, std::vector<std::string>& attsModified);
179  void DeleteDriveFromMainDB(const std::string& drive);
181  void DeleteDriveFromOtherDB(const std::string& drive);
183  void EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
185  void GetAttributes(const std::vector<std::string>& params,
186  const std::string& filename,
187  std::vector<std::string>& results);
188 
190  const std::string isAttributeExist(const std::string i_attr);
191 
192 
193 
194  //====================================================================
195 
196  private:
197 
201  void AddFile( const std::string& filename );
202 
204  void AddDirectoryRecursor( const std::string& directory,
205  bool recurse,
206  const std::string &addKey);
207 
211  //ImageWriter mWriter;
212  std::string mCurrentDB;
213 
216 
217 
218  };
219  // EO class TreeHandlerImageAdder
220  //=======================================================================
221 
222 
223 
224 
225 
226 } // EO namespace creaImageIO
227 
228 #include <iostream>
229 inline std::ostream& operator << ( std::ostream& o,
231 {
232  o << p.GetNumberScannedFiles() << " files - "
233  << p.GetNumberScannedDirs() << " dirs - "
234  << p.GetNumberHandledFiles() << " handled -"
235  << p.GetNumberAddedFiles() << " added";
236  return o;
237 }
238 
239 // EOF
240 #endif
241