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