X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FcreaImageIOGimmick.cpp;h=5c7b07fd4fb9e36f366c64b8fef7176e69c73b34;hb=refs%2Ftags%2FCREATOOLS.2-0-3;hp=5edb4edf78c10bea8be01ef81b41de915b8ab733;hpb=3a22e19184c369b130d4caa992a8e98e50c7a0ee;p=creaImageIO.git diff --git a/src/creaImageIOGimmick.cpp b/src/creaImageIOGimmick.cpp index 5edb4ed..5c7b07f 100644 --- a/src/creaImageIOGimmick.cpp +++ b/src/creaImageIOGimmick.cpp @@ -1,15 +1,15 @@ #include - #include #include #include + //#include "io.h" #ifndef PATH_MAX // If not defined yet : do it # define PATH_MAX 2048 #endif #include -#include + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -62,14 +62,14 @@ namespace creaImageIO CreateUserSettingsDirectory(); // Sets the current directory to the home dir mCurrentDirectory = GetHomeDirectory(); - mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"Shared/gimmick/"); + mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"share/gimmick/"); mSettings = new Settings(mCurrentDirectory); std::string dbpath = GetLocalDatabasePath(); // Create or open local database - std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/" + mLocalDescpName; + std::string dpath= mCurrentDirectory + "/.gimmick/share/gimmick/" + mLocalDescpName; boost::algorithm::replace_all( dpath, INVALID_FILE_SEPARATOR , @@ -202,7 +202,7 @@ namespace creaImageIO if (mLocalDatabasePath.size()==0) { mLocalDatabasePath = GetUserSettingsDirectory(); - mLocalDatabasePath += "Shared/gimmick/"; + mLocalDatabasePath += "share/gimmick/"; mLocalDatabasePath += mLocalDBName; mLocalDatabasePath +=".sqlite3"; boost::algorithm::replace_all( mLocalDatabasePath, @@ -257,7 +257,7 @@ namespace creaImageIO boost::algorithm::replace_all( setDir, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - setDir+="Shared/"; + setDir+="share/"; boost::filesystem::create_directory( setDir ); setDir+="gimmick/"; boost::filesystem::create_directory( setDir ); @@ -277,7 +277,7 @@ namespace creaImageIO // The following stuff works on Linux, NOT CHECKED on Windows // JPR #if defined(_WIN32) - path+="/bin/Shared/gimmick/"; + path+="/bin/share/gimmick/"; #endif #if defined (LINUX) @@ -424,6 +424,32 @@ path+= mLocalDescpName; } //======================================================================== + //======================================================================== + // get attributes values from database for a given file from database + //======================================================================== + void Gimmick::GetAttributes(const std::string filename, std::map &i_res, OutputAttr i_attr) + { + if (i_attr.inside.size() > 0) + { + std::map map_attr; + TreeHandler * handler=GetTreeHandler(i_attr.db); + handler->getAllAttributes(filename, map_attr); + if(i_attr.inside.front() == "ALL") // we take all values + { + std::map::iterator it = map_attr.begin(); + for(; it != map_attr.end(); it++) + i_res[it->first] = it->second; + } + else + { + std::vector::iterator it = i_attr.inside.begin(); + for(; it != i_attr.inside.end(); it++) + i_res[(*it)] = map_attr[(*it)]; + } + } + } + + //======================================================================== void Gimmick::UpdateSetting(const std::string& name, const std::string& value) @@ -488,4 +514,29 @@ path+= mLocalDescpName; addDB(name, it_path->c_str()); } } + + +/////////////////////////////////////////////////////////////////////////////// +// Fill attributes structure with attributes present in database (inside vector +// and not present (outside) +/////////////////////////////////////////////////////////////////////////////// +void Gimmick::fillVectInfos(std::vector i_attr, OutputAttr &infos) +{ + //test if a tag is present in Database descriptor + TreeHandler * handler=GetTreeHandler(infos.db); + mImageAdder.SetTreeHandler(handler); + std::vector::const_iterator it = i_attr.begin(); + for (;it != i_attr.end(); it++) + { + if( mImageAdder.isAttributeExist((*it)) != "" ) // in DB + { + infos.inside.push_back((*it)); + } + else + { + infos.outside.push_back((*it)); // Need to scan again the files + } + } } + +} \ No newline at end of file