00001 #ifndef __creaImageIOSynchron_h_INCLUDED__
00002 #define __creaImageIOSynchron_h_INCLUDED__
00003
00004 #include <string>
00005 #include <map>
00006 #include <iostream>
00007 #include <vector>
00008 #include "CppSQLite3.h"
00009
00010 namespace creaImageIO
00011 {
00012 using namespace std;
00013
00014 class AddList
00015 {
00016 public :
00017 std::string key;
00018 std::string path;
00019 std::string recursive;
00020 std::string nbFiles;
00021 AddList(CppSQLite3Query& res):
00022 key(res.getStringField(0)),
00023 path(res.getStringField(1)),
00024 recursive(res.getStringField(2)),
00025 nbFiles(res.getStringField(3))
00026 {}
00027 };
00028
00029
00030
00031 class RemoveList
00032 {
00033 public :
00034 std::string key;
00035 std::string path;
00036 std::string remove;
00037 std::string time;
00038
00039 RemoveList(CppSQLite3Query& res):
00040 key(res.getStringField(1)),
00041 path(res.getStringField(2)),
00042 remove(res.getStringField(3)),
00043 time(res.getStringField(4))
00044 {}
00045 };
00046
00047
00048
00049 class Synchronizer
00050 {
00051 public:
00052 Synchronizer(const std::string& path);
00053 virtual ~Synchronizer();
00054 void Initialize();
00055 void InsertAddOp(const std::string& path,
00056 const std::string& recursive,
00057 const std::string& nChildren,
00058 const std::string& refdb);
00059 void InsertIgnoreFile(const std::string& addKey,
00060 const std::string& path,
00061 const std::string& remove,
00062 const std::string& time,
00063 const std::string& refdb);
00064 void RemoveEntry(const std::string i_table, const std::string i_key);
00065 void RemoveEntries(const std::string i_table,
00066 const std::string i_attribute,
00067 const std::string i_operand,
00068 const std::string i_key);
00069 void GetFileList(std::vector<AddList>& files , const std::string& refdb);
00070 void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
00071 std::string GetAttribute(const std::string& attribute,
00072 const std::string& table,
00073 const std::string& searchParam,
00074 const std::string& searchValue,
00075 const std::string& refdb);
00076 void SetAttribute(const std::string& attribute,
00077 const std::string& table,
00078 const std::string& value,
00079 const std::string& searchParam,
00080 const std::string& searchValue,
00081 const std::string& refdb);
00082 std::vector<AddList> mAddList;
00083 std::vector<RemoveList> mIgnoreList;
00084 private :
00085
00087 CppSQLite3DB* mDB;
00088 std::string pathDB;
00089 void CreateDB();
00090 void UpdateAddList(const std::string& refdb);
00091 void CleanList(const std::string& refdb);
00092 void CleanName(std::string& str) const;
00093
00094 std::vector<std::string> GetIgnoreList(const std::string &i_key);
00095
00096 };
00097
00098
00099
00100 }
00101
00102 #endif
00103