Go to the documentation of this file.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
00015 class AddList
00016 {
00017 public :
00019 std::string key;
00021 std::string path;
00023 std::string recursive;
00025 std::string nbFiles;
00027 AddList(CppSQLite3Query& res):
00028 key(res.getStringField(0)),
00029 path(res.getStringField(1)),
00030 recursive(res.getStringField(2)),
00031 nbFiles(res.getStringField(3))
00032 {}
00033 };
00034
00035
00036
00038 class RemoveList
00039 {
00040 public :
00042 std::string key;
00044 std::string path;
00046 std::string remove;
00048 std::string time;
00050 RemoveList(CppSQLite3Query& res):
00051 key(res.getStringField(1)),
00052 path(res.getStringField(2)),
00053 remove(res.getStringField(3)),
00054 time(res.getStringField(4))
00055 {}
00056 };
00057
00058
00059
00061 class Synchronizer
00062 {
00063 public:
00065 Synchronizer(const std::string& path);
00067 virtual ~Synchronizer();
00069 void Initialize();
00071 void InsertAddOp(const std::string& path,
00072 const std::string& recursive,
00073 const std::string& nChildren,
00074 const std::string& refdb);
00076 void InsertIgnoreFile(const std::string& addKey,
00077 const std::string& path,
00078 const std::string& remove,
00079 const std::string& time,
00080 const std::string& refdb);
00082 void RemoveEntry(const std::string i_table, const std::string i_key);
00084 void RemoveEntries(const std::string i_table,
00085 const std::string i_attribute,
00086 const std::string i_operand,
00087 const std::string i_key);
00089 void GetFileList(std::vector<AddList>& files , const std::string& refdb);
00091 void GetIgnoredFiles(const std::string& key, std::vector<std::string> &ignoreList);
00093 std::string GetAttribute(const std::string& attribute,
00094 const std::string& table,
00095 const std::string& searchParam,
00096 const std::string& searchValue,
00097 const std::string& refdb);
00099 void SetAttribute(const std::string& attribute,
00100 const std::string& table,
00101 const std::string& value,
00102 const std::string& searchParam,
00103 const std::string& searchValue,
00104 const std::string& refdb);
00105
00106 void GetList(const std::string i_db);
00107
00108 bool isIndexed(const std::string filename);
00109
00110 std::map <std::string, bool> mList;
00112 std::vector<AddList> mAddList;
00114 std::vector<RemoveList> mIgnoreList;
00115 private :
00116
00118 CppSQLite3DB* mDB;
00120 std::string pathDB;
00122 void CreateDB();
00124 void UpdateAddList(const std::string& refdb);
00126 void CleanList(const std::string& refdb);
00128 void CleanName(std::string& str) const;
00130 std::vector<std::string> GetIgnoreList(const std::string &i_key);
00131 const std::string convert(const std::string &i_word);
00132
00133 };
00134
00135
00136
00137 }
00138
00139 #endif
00140