]> Creatis software - creaImageIO.git/blob - src2/creaImageIOSynchron.h
Added Settings dialog, customize configuration options and the listener on an externa...
[creaImageIO.git] / src2 / creaImageIOSynchron.h
1 #ifndef __creaImageIOSynchron_h_INCLUDED__
2 #define __creaImageIOSynchron_h_INCLUDED__
3
4 #include <string>
5 #include <map>
6 #include <iostream>
7 #include <vector>
8 #include "CppSQLite3.h"
9
10 namespace creaImageIO
11 {
12         using namespace std;
13    //================================================================================================================
14     class AddList
15     {
16       public :
17               std::string key;
18               std::string path;
19               std::string recursive;
20               std::string nbFiles;
21               AddList(CppSQLite3Query& res):
22                           key(res.getStringField(0)), 
23                           path(res.getStringField(1)),
24                           recursive(res.getStringField(2)),
25                           nbFiles(res.getStringField(3))
26               {}
27     };
28    //================================================================================================================
29
30    //================================================================================================================
31         class RemoveList
32     {
33       public :
34               std::string key;
35               std::string path;
36               std::string remove;
37               std::string time;
38              
39               RemoveList(CppSQLite3Query& res):
40                           key(res.getStringField(1)), 
41                           path(res.getStringField(2)),
42                           remove(res.getStringField(3)),
43                           time(res.getStringField(4))
44                           {}
45     };
46    //================================================================================================================
47   
48    //================================================================================================================
49     class Synchronizer
50     {
51       public:
52               Synchronizer(const std::string& path);
53               virtual ~Synchronizer();
54                           void Initialize();
55                           void InsertAddOp(const std::string& path, 
56                                                         const std::string& recursive,
57                                                         const std::string& nChildren, 
58                                                         const std::string& refdb);
59                           void InsertIgnoreFile(const std::string& addKey,
60                                                         const std::string& path, 
61                                                         const std::string& remove,
62                                                         const std::string& time,
63                                                         const std::string& refdb);
64                           void RemoveEntry(const std::string i_table, const std::string i_key);
65                           void RemoveEntries(const std::string i_table, 
66                                                                                         const std::string i_attribute, 
67                                                                                         const std::string i_operand, 
68                                                                                         const std::string i_key);
69                           void GetFileList(std::vector<AddList>& files , const std::string& refdb);
70                           void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
71                           std::string GetAttribute(const std::string& attribute, 
72                                                                                 const std::string& table, 
73                                                                                 const std::string& searchParam,
74                                                                                 const std::string& searchValue,
75                                                                                 const std::string& refdb);
76                           void SetAttribute(const std::string& attribute, 
77                                                                                 const std::string& table, 
78                                                                                 const std::string& value,
79                                                                                 const std::string& searchParam,
80                                                                                 const std::string& searchValue, 
81                                                                                 const std::string& refdb);
82               std::vector<AddList>  mAddList;
83               std::vector<RemoveList>  mIgnoreList;
84       private :
85              
86               /// The DB
87               CppSQLite3DB* mDB;
88               std::string pathDB;
89               void CreateDB();
90               void UpdateAddList(const std::string& refdb);
91               void CleanList(const std::string& refdb);
92                           void CleanName(std::string& str) const;
93         
94                       std::vector<std::string> GetIgnoreList(const std::string &i_key);
95
96     };
97    //================================================================================================================
98
99        
100
101 // EOF
102 #endif
103