]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOTreeHandlerImageAdder.h
move directory
[creaImageIO.git] / src2 / creaImageIOTreeHandlerImageAdder.h
index 4d753d77c74eb72d07e4570f738d77f0344b4b99..41ff0a63969818dc6bf209e925176b37767d1167 100644 (file)
@@ -2,9 +2,10 @@
 #define __creaImageIOTreeHandlerImageAdder_h_INCLUDED__
 
 #include <creaImageIOTreeHandler.h>
+#include <creaImageIOSynchron.h>
 #include <creaImageIOImageReader.h>
-#include <wx/wx.h>
-#include <wx/progdlg.h>
+//#include <creaImageIOImageWriter.h>
+
 // Signal/slot mechanism for progress events
 #include <boost/signal.hpp>
 #include <boost/bind.hpp>
@@ -21,6 +22,7 @@ namespace creaImageIO
 
   class TreeHandlerImageAdder
   {
+         
   public:
     //====================================================================
     /// Ctor
@@ -29,6 +31,11 @@ namespace creaImageIO
     ~TreeHandlerImageAdder();
     /// Sets the TreeHandler
     void SetTreeHandler(TreeHandler* tree) { mTreeHandler = tree;}
+       
+       /// Sets the synchronizer
+       void SetSynchronizer(Synchronizer* s){mSynchronizer=s;}
+       /// Sets the synchronizer
+       void SetCurrentDatabase(std::string cur){mCurrentDB=cur;}
     //====================================================================
 
     //====================================================================
@@ -49,10 +56,10 @@ namespace creaImageIO
        mNumberAddedFiles = 0;
       }
 
-      int GetNumberScannedFiles() { return mNumberScannedFiles; }
-      int GetNumberScannedDirs() { return mNumberScannedDirs; }
-      int GetNumberHandledFiles() { return mNumberHandledFiles; }
-      int GetNumberAddedFiles() { return mNumberAddedFiles; }
+      int GetNumberScannedFiles() const { return mNumberScannedFiles; }
+      int GetNumberScannedDirs() const { return mNumberScannedDirs; }
+      int GetNumberHandledFiles() const { return mNumberHandledFiles; }
+      int GetNumberAddedFiles() const { return mNumberAddedFiles; }
 
       void IncNumberScannedFiles() { mNumberScannedFiles++; }
       void IncNumberScannedDirs() { mNumberScannedDirs++; }
@@ -60,7 +67,7 @@ namespace creaImageIO
       void IncNumberAddedFiles() { mNumberAddedFiles++; }
 
       void SetStop() { mStop = true; }
-      bool GetStop() { return mStop; }
+      bool GetStop() const { return mStop; }
 
     private:
       bool mStop;
@@ -76,7 +83,6 @@ namespace creaImageIO
     //=============================================
 
     //=============================================
-    //    typedef boost::signals::trackable ProgressObserverType;
     typedef boost::signal<void (Progress&)>  ProgressSignalType;
     typedef ProgressSignalType::slot_function_type ProgressCallbackType;
     //=============================================
@@ -99,33 +105,96 @@ namespace creaImageIO
     void AddFiles( const std::vector<std::string>& filename );
     /// (Recursively) adds the files of a directory to the TreeHandler 
     void AddDirectory( const std::string& directory, 
-                      bool recurse );
+                      bool recurse);
+       /// Removes a file from the databases
+       void RemoveFile(tree::Node* node);
+       /// Removes files from the databases
+       void RemoveFiles(const std::vector<tree::Node*>& nodes);
+       /// Synchronizes the DB and disk by repeating the operations the user has done and returns a report
+       std::string Synchronize(bool repair, bool checkAttributes);
+       ///Recursively checks if the directory is synchronized and optionally the state of the attributes
+       void CheckSyncDirectory(const std::string &dirpath, 
+                                                       bool recursive, 
+                                                       bool repair,
+                                                       bool checkAttributes,
+                                                       std::vector<std::string> &i_ignorefiles,
+                                                       std::vector<std::string> & attsModified,
+                                                       std::vector<std::string> & newfiles);
+       ///Copies the files indicated in the vector and updates all databases
+       void CopyFiles(const std::vector<std::string>& filenames, const std::string directory  );
+       
+       ///Saves as the files indicated in the vector in a specific directory
+       void SaveAs(const std::vector<std::string>& filenames, std::vector<vtkImageData *> i_images);
+       ///Finds the node that matches the specified parameters
+       void FindNode(tree::Node* parent, int level, 
+               const std::string& searchParam, 
+               const std::string& searchVal, 
+               tree::Node*& node);
+
+       ///Finds the nodes that partially match the searchVal
+       void FindNodePartial(tree::Node* parent, int level, const std::string& searchParam, const std::string& searchVal, tree::Node*& node);
+       ///Checks the attributes of the database against the ones in disk
+       void CheckAttributes(bool repair, std::string& file, std::vector<std::string>& attsModified);
+       ///Deletes the drive with the given name (use for all databases except maintenance and timestamp)
+       void DeleteDriveFromMainDB(const std::string& drive);
+       ///Deletes the drive with the given name (use for maintenance and timestamp databases)
+       void DeleteDriveFromOtherDB(const std::string& drive);
+       ///Edits the given field and sets the new parameters
+       void EditField(tree::Node* node, const std::string& name, const std::string& key, const std::string& val);
+       ///Returns the demanded attributes for the given file
+       void GetAttributes(const std::vector<std::string>& params, 
+         const std::string& filename, 
+         std::vector<std::string>& results);
+  
+  
+  
     //====================================================================
 
   private:
 
     /// Adds a single file to the TreeHandler 
-    /// **WITHOUT** testing werther it is handled or not 
+    /// **WITHOUT** testing wether it is handled or not 
     /// hence you have to call IsHandledFile before using AddFile!
     void AddFile( const std::string& filename );
 
     /// Recursive method which does the main job for AddDirectory
     void AddDirectoryRecursor( const std::string& directory, 
-                              bool recurse );
-    
+                              bool recurse,
+                          const std::string &addKey);
 
     TreeHandler* mTreeHandler;
+       Synchronizer* mSynchronizer;
     ImageReader mReader;
+       //ImageWriter mWriter;
+       std::string mCurrentDB;
     
     Progress mProgress;
     ProgressSignalType mProgressSignal;
+
+
   };
   // EO class TreeHandlerImageAdder
   //=======================================================================
 
 
+
+
 } // EO namespace creaImageIO
 
+#include <iostream>
+inline std::ostream& operator << ( std::ostream& o, 
+                           const creaImageIO::TreeHandlerImageAdder::Progress& p)
+{
+  o << p.GetNumberScannedFiles() << " files - "
+    << p.GetNumberScannedDirs() << " dirs - "
+    << p.GetNumberHandledFiles() << " handled -"
+    << p.GetNumberAddedFiles() << " added";
+  return o;
+}
+
 // EOF
 #endif