X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOGimmick.cpp;h=5ec96f8120c5c0e1bcb8f4fb69d7a9015fdfbcec;hb=da80530068246081505e9649523d10e8da8e6acd;hp=7d7cca091431421cd4d909a9ed58910207f2c1e9;hpb=3e44acb4a0963c9fb97d135820048fda3cf9ebd9;p=creaImageIO.git diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 7d7cca0..5ec96f8 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -9,6 +9,11 @@ # define PATH_MAX 2048 #endif +#ifdef _RELWITHDEBINFO +#define new DEBUG_NEW +#endif + + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -22,6 +27,8 @@ namespace creaImageIO RegisterGimmickMessageTypes(); mSettings=0; mSynchronizer=0; + mLocalDescpName = "localdatabase_Descriptor.dscp"; + mLocalDBName = "Local database"; } //============================================================== @@ -42,15 +49,17 @@ namespace creaImageIO //============================================================== //============================================================== - void Gimmick::Initialize(const std::string& path) + void Gimmick::Initialize(const std::string i_namedescp, const std::string i_namedb) { + mLocalDescpName = i_namedescp; + mLocalDBName = i_namedb; Initialize(); } //============================================================== void Gimmick::Initialize() { - std::string i_nameDB = "Local database"; + std::string i_nameDB = mLocalDBName; // Create the UserSettings dir if does not exist CreateUserSettingsDirectory(); // Sets the current directory to the home dir @@ -61,7 +70,7 @@ namespace creaImageIO std::string dbpath = GetLocalDatabasePath(); // Create or open local database - std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/localdatabase_Descriptor.dscp"; + std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/" + mLocalDescpName; boost::algorithm::replace_all( dpath, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); @@ -133,14 +142,16 @@ namespace creaImageIO //============================================================== void Gimmick::Finalize() { - - // delete SQLiteTreeHandler Object - for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin(); - it!= mTreeHandlerMap.end(); - ++it) - { - delete it->second; - } + if(mTreeHandlerMap.size() >0) + { + // delete SQLiteTreeHandler Object + for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin(); + it!= mTreeHandlerMap.end(); + ++it) + { + delete it->second; + } + } } //============================================================== @@ -225,7 +236,7 @@ namespace creaImageIO boost::filesystem::create_directory( setDir ); setDir+="gimmick/"; boost::filesystem::create_directory( setDir ); - setDir+="localdatabase_Descriptor.dscp"; + setDir+=mLocalDescpName; if(!boost::filesystem::is_regular(setDir)) { @@ -242,9 +253,11 @@ namespace creaImageIO // The following stuff works on Linux, NOT CHECKED on Windows // JPR #if defined(_WIN32) - path+="/bin/Shared/gimmick/localdatabase_Descriptor.dscp"; + path+="/bin/Shared/gimmick/"; + path+=mLocalDescpName; #else - path+="/Shared/gimmick/localdatabase_Descriptor.dscp"; + path+="/Shared/gimmick/"; + path+= mLocalDescpName; #endif std::cout <<"From: " << path <