X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=src2%2FcreaImageIOSynchron.cpp;h=06785fe8e94bc32d55335409f95fea662b040920;hb=66b7c66deb6102bd632daf96fe298b1d5764b7cc;hp=9ec4bae4d3fcf4b7b68469d0f88debe0158c16ec;hpb=7ae1412df3d682f639683e751f46a3f07be16d0b;p=creaImageIO.git diff --git a/src2/creaImageIOSynchron.cpp b/src2/creaImageIOSynchron.cpp index 9ec4bae..06785fe 100644 --- a/src2/creaImageIOSynchron.cpp +++ b/src2/creaImageIOSynchron.cpp @@ -1,8 +1,9 @@ #include #include #include +#include +//namespace fs = boost::filesystem; -namespace fs = boost::filesystem; //===================================================================== @@ -11,7 +12,7 @@ namespace creaImageIO { //===================================================================== - #define QUERYSYNCDB(QUER,RES) \ + #define QUERYSYNCDB(QUER,RES) \ try \ { \ RES = mDB->execQuery(QUER.c_str()); \ @@ -23,7 +24,7 @@ namespace creaImageIO << e.errorMessage() ); \ } //===================================================================== - #define UPDATESYNCDB(UP) \ + #define UPDATESYNCDB(UP) \ try \ { \ mDB->execDML(UP.c_str()); \ @@ -52,7 +53,7 @@ namespace creaImageIO //===================================================================== void Synchronizer::Initialize() { - if (!fs::exists(pathDB)) + if (!boost::filesystem::exists(pathDB)) { CreateDB(); } @@ -72,7 +73,7 @@ namespace creaImageIO } } // get the ADD operations List - UpdateAddList(); + //UpdateAddList(pathDB); } //===================================================================== @@ -87,6 +88,7 @@ namespace creaImageIO command += ",\nPATH text"; command += ",\nRECURSIVE boolean"; command += ",\nFILES_ADDED int"; + command += ",\nREFERENCEDDB text"; command += "\n)"; UPDATESYNCDB(command); @@ -117,9 +119,9 @@ namespace creaImageIO } //===================================================================== - void Synchronizer::GetFileList(std::vector & list) + void Synchronizer::GetFileList(std::vector & list, const std::string& refdb) { - CleanList(); + CleanList(refdb); list=mAddList; } @@ -130,9 +132,9 @@ namespace creaImageIO } //===================================================================== - void Synchronizer::UpdateAddList() + void Synchronizer::UpdateAddList(const std::string& refdb) { - std::string query = "SELECT * FROM ADD_OPS"; + std::string query = "SELECT * FROM ADD_OPS WHERE REFERENCEDDB = '"+refdb+"';"; CppSQLite3Query res; QUERYSYNCDB(query, res); while (!res.eof()) @@ -145,7 +147,7 @@ namespace creaImageIO ///////////////////////////////////////////////////////////////////////////////////////////////// // remove an entry of the DB - //@param i_table : table where do the remove + //@param i_table : table where to do the remove // @param i_key : the add_key reference (one entry to remove for ADD_OP table, many for IGNORED_FILES table //@result : - ///////////////////////////////////////////////////////////////////////////////////////////////// @@ -155,14 +157,33 @@ namespace creaImageIO UPDATESYNCDB(query); } + ///////////////////////////////////////////////////////////////////////////////////////////////// + // remove several entries of the DB + // @param i_table : table where to do the remove + // @param i_attribute: attribute to match + // @param i_operand : operand to use + // @param i_val : the reference + //@result : - + ///////////////////////////////////////////////////////////////////////////////////////////////// + void Synchronizer::RemoveEntries(const std::string i_table, + const std::string i_attribute, + const std::string i_operand, + const std::string i_val) + { + std::stringstream query; + query<<"DELETE FROM "<::iterator it_add = mAddList.begin(); for(;it_add i_names; + std::string query = "SELECT PATH, REMOVE FROM IGNORED_FILES"; + CppSQLite3Query res; + QUERYSYNCDB(query, res); + while (!res.eof()) + { + std::string file(res.getStringField(0)); + std::string ignore(res.getStringField(1)); + mList[file] = ignore == "0"? true : false; + res.nextRow(); + } + + } + + bool Synchronizer::isIndexed(const std::string filename) + { + bool valid = true; + std::string name(filename); + boost::algorithm::replace_all( name,"\\" , "/"); + std::map ::iterator it_list = mList.begin(); + for(;it_list != mList.end(); it_list++) + { + if(it_list->first == name) + { + valid = false; + break; + } + } + return valid; + } +} \ No newline at end of file