]> Creatis software - creaImageIO.git/blob - src/creaImageIOSynchronizer.h
fa3ae37abe9b3b20a4e1e5c72d48f623ffd2ef10
[creaImageIO.git] / src / creaImageIOSynchronizer.h
1 #ifndef __creaImageIOSynchronizer_h_INCLUDED__
2 #define __creaImageIOSynchronizer_h_INCLUDED__
3
4 #include <creaImageIOSQLiteTreeHandler.h>
5 #include <creaImageIOImageReader.h>
6
7 namespace creaImageIO
8 {
9
10 //=======================================================================
11 /// Synchronizes a given database with disk
12 class Synchronizer
13   {
14   public:
15       /// Ctor
16       Synchronizer(TreeHandler* th);
17       /// Dtor
18       ~Synchronizer();
19           ///Sets the tree handler to use in order to synchronize with a given database
20           void SetTreeHandler(TreeHandler * handler){mHandler=handler;}
21           ///Synchronizes the database in the current tree handler with disk by doing the passed action. If it is true,
22           ///the database will be updated, otherwise a warning message will be returned.
23           std::string Synchronize(bool update);
24           ///Checks if the file given as a parameter exists in the drive
25           bool FileExists(std::string file);
26           ///Checks if the attributes of the node given as a parameter matchwith it correspondent file in disk 
27           ///NB: This method doesn't check the existence of the file, so FileExists should be called before.
28           void AttributesMatch(bool update, std::string file, std::stringstream& mess);
29
30
31   private:
32           ///The tree handler
33           TreeHandler* mHandler;
34           ///The image reader
35           ImageReader mReader;
36           ///Synchronizes the given file, doing the action required and returning the result on the string supplied
37           void SynchronizeFile(bool update, std::string file, std::stringstream& message);
38
39   };
40 } // EO namespace creaImageIO
41
42 // EOF
43 #endif