]> Creatis software - creaImageIO.git/blobdiff - src2/creaImageIOSynchron.cpp
replace boost::filesystem::is_regular_file() by boost::filesystem::is_regular()
[creaImageIO.git] / src2 / creaImageIOSynchron.cpp
index 136c29e7fcd190756e4edb5eeb226b132c50d355..74e9e98ced8fc532e9c0843a593098db249dce02 100644 (file)
@@ -11,7 +11,7 @@ namespace creaImageIO
 {
 
        //=====================================================================
-       #define QUERYSYNCDB(QUER,RES)                                           \
+       #define QUERYSYNCDB(QUER,RES)                                   \
     try                                                                        \
       {                                                                        \
        RES = mDB->execQuery(QUER.c_str());                             \
@@ -23,7 +23,7 @@ namespace creaImageIO
                   << e.errorMessage() );                               \
     }                                                                                                                                     
        //=====================================================================
-       #define UPDATESYNCDB(UP)                                                        \
+       #define UPDATESYNCDB(UP)                                        \
   try                                                                  \
     {                                                                  \
       mDB->execDML(UP.c_str());                                                \
@@ -146,7 +146,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 : -
     /////////////////////////////////////////////////////////////////////////////////////////////////
@@ -156,6 +156,24 @@ 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 "<<i_table<<" WHERE "<<i_attribute<<" "<<i_operand<<" '"<<i_val<<"'";
+        UPDATESYNCDB(query.str());
+       }
+
     /////////////////////////////////////////////////////////////////////////////////////////////////
     // clean DataBase if an operation has no child anymore
        // @param refdb: the database segement to clean
@@ -293,10 +311,10 @@ namespace creaImageIO
     // @result : required attribute
     /////////////////////////////////////////////////////////////////////////////////////////////////
     std::string Synchronizer::GetAttribute(const std::string& attribute, 
-                                                                               const std::string& table, 
-                                                                               const std::string& searchParam,
-                                                                               const std::string& searchValue, 
-                                                                               const std::string& refdb)
+                                       const std::string& table, 
+                                       const std::string& searchParam,
+                                       const std::string& searchValue, 
+                                       const std::string& refdb)
     {
         std::stringstream query;
                std::string result;
@@ -331,11 +349,11 @@ namespace creaImageIO
     // @result : attribute value changed
     /////////////////////////////////////////////////////////////////////////////////////////////////
     void Synchronizer::SetAttribute(const std::string& attribute, 
-                                                                               const std::string& table, 
-                                                                               const std::string& value,
-                                                                               const std::string& searchParam,
-                                                                               const std::string& searchValue,
-                                                                               const std::string& refdb)
+                               const std::string& table, 
+                               const std::string& value,
+                               const std::string& searchParam,
+                               const std::string& searchValue,
+                               const std::string& refdb)
     {
                std::string val=value.c_str();
                std::string sVal=searchValue.c_str();
@@ -359,4 +377,5 @@ namespace creaImageIO
                sql += "';";
                UPDATESYNCDB(sql);
     }
-} 
\ No newline at end of file
+}
+