1 #ifndef __creaImageIOSynchron_h_INCLUDED__
2 #define __creaImageIOSynchron_h_INCLUDED__
8 #include "CppSQLite3.h"
13 //================================================================================================================
14 ///Represents the list of currently added files
18 ///Key to be added into the database
20 ///Path of the directory
22 /// Defines if the operation was recursive or not
23 std::string recursive;
24 ///Number of added files
27 AddList(CppSQLite3Query& res):
28 key(res.getStringField(0)),
29 path(res.getStringField(1)),
30 recursive(res.getStringField(2)),
31 nbFiles(res.getStringField(3))
34 //================================================================================================================
36 //================================================================================================================
37 ///Represents the list of currently removed files
41 ///Key to be added into the database
43 ///Path of the remove file
45 ///Defines if the file was removed or not
47 ///Time of the last change of the file
50 RemoveList(CppSQLite3Query& res):
51 key(res.getStringField(1)),
52 path(res.getStringField(2)),
53 remove(res.getStringField(3)),
54 time(res.getStringField(4))
57 //================================================================================================================
59 //================================================================================================================
60 ///In charge of the synchronization of the database and the disk state.
65 Synchronizer(const std::string& path);
67 virtual ~Synchronizer();
68 ///Initializes the database
70 ///Inserts an add operation to the database
71 void InsertAddOp(const std::string& path,
72 const std::string& recursive,
73 const std::string& nChildren,
74 const std::string& refdb);
75 ///Inserts a file to be ignored
76 void InsertIgnoreFile(const std::string& addKey,
77 const std::string& path,
78 const std::string& remove,
79 const std::string& time,
80 const std::string& refdb);
81 ///Removes an entry that matches the given parameter
82 void RemoveEntry(const std::string i_table, const std::string i_key);
83 ///Removes several entries
84 void RemoveEntries(const std::string i_table,
85 const std::string i_attribute,
86 const std::string i_operand,
87 const std::string i_key);
88 ///Gets the list of AddFiles
89 void GetFileList(std::vector<AddList>& files , const std::string& refdb);
90 ///Gets the list of ignored files
91 void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
92 ///Gets the attribute that matches the parameters
93 std::string GetAttribute(const std::string& attribute,
94 const std::string& table,
95 const std::string& searchParam,
96 const std::string& searchValue,
97 const std::string& refdb);
98 ///Sets an attribute to an entry that matches the given parameters
99 void SetAttribute(const std::string& attribute,
100 const std::string& table,
101 const std::string& value,
102 const std::string& searchParam,
103 const std::string& searchValue,
104 const std::string& refdb);
105 // Get the List of indexed files (removed or not)
107 // Test to not if a file is indexed on db or not
108 bool isIndexed(const std::string filename);
109 // List of all indexed files
110 std::map <std::string, bool> mList;
111 ///The current AddList
112 std::vector<AddList> mAddList;
113 ///The current RemoveList
114 std::vector<RemoveList> mIgnoreList;
119 ///Path of the current database
121 ///Creates a new database
123 ///Updates the AddList
124 void UpdateAddList(const std::string& refdb);
125 ///Cleans the list in case operations are no longer useful (0 added files)
126 void CleanList(const std::string& refdb);
127 ///Cleans the name (changes slashes and backslashes according to the system)
128 void CleanName(std::string& str) const;
129 ///Gets the ignore list
130 std::vector<std::string> GetIgnoreList(const std::string &i_key);
133 //================================================================================================================