]> Creatis software - creaImageIO.git/blob - src2/creaImageIOSynchron.h
7e4bc3693ccb58f150d9a44f078941fd46745ffc
[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 GetFileList(std::vector<AddList>& files , const std::string& refdb);
66                           void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
67                           std::string GetAttribute(const std::string& attribute, 
68                                                                                 const std::string& table, 
69                                                                                 const std::string& searchParam,
70                                                                                 const std::string& searchValue,
71                                                                                 const std::string& refdb);
72                           void SetAttribute(const std::string& attribute, 
73                                                                                 const std::string& table, 
74                                                                                 const std::string& value,
75                                                                                 const std::string& searchParam,
76                                                                                 const std::string& searchValue, 
77                                                                                 const std::string& refdb);
78               std::vector<AddList>  mAddList;
79               std::vector<RemoveList>  mIgnoreList;
80       private :
81              
82               /// The DB
83               CppSQLite3DB* mDB;
84               std::string pathDB;
85               void CreateDB();
86               void UpdateAddList(const std::string& refdb);
87               void CleanList(const std::string& refdb);
88                           void CleanName(std::string& str) const;
89         
90                       std::vector<std::string> GetIgnoreList(const std::string &i_key);
91
92     };
93    //================================================================================================================
94
95        
96
97 // EOF
98 #endif
99