X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOGimmick.cpp;h=a13809b7a8a1c885ff35590e88c6074976b4f386;hb=e4a54c9026a2a0c17e3be0b5915c34688a9385ad;hp=738256c0f477a27e5b864d5083c80e01212e37b2;hpb=82dd8a0b39def790c0b344236c7c05795889ddf6;p=creaImageIO.git diff --git a/src2/creaImageIOGimmick.cpp b/src2/creaImageIOGimmick.cpp index 738256c..a13809b 100644 --- a/src2/creaImageIOGimmick.cpp +++ b/src2/creaImageIOGimmick.cpp @@ -10,8 +10,6 @@ namespace creaImageIO { - - //============================================================== Gimmick::Gimmick() : mImageAdder(0) @@ -23,18 +21,17 @@ namespace creaImageIO //============================================================== - //============================================================== Gimmick::~Gimmick() { if(mSettings!=0) { - mSettings->writeSettingsFile(); - delete mSettings; + mSettings->writeSettingsFile(); + delete mSettings; } - if(mSynchronizer!=0) + if(mSynchronizer!=0) { - delete mSynchronizer; + delete mSynchronizer; } } //============================================================== @@ -53,35 +50,32 @@ namespace creaImageIO CreateUserSettingsDirectory(); // Sets the current directory to the home dir mCurrentDirectory = GetHomeDirectory(); - mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"Shared/gimmick/"); + mSynchronizer= new Synchronizer(GetUserSettingsDirectory()+"Shared/gimmick/"); - mSettings = new Settings(mCurrentDirectory); + mSettings = new Settings(mCurrentDirectory); - - std::string dbpath = GetLocalDatabasePath(); + std::string dbpath = GetLocalDatabasePath(); // Create or open local database - std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/localdatabase_Descriptor.dscp"; - boost::algorithm::replace_all( dpath, - INVALID_FILE_SEPARATOR , - VALID_FILE_SEPARATOR); - mLocalDatabase = createDB(i_nameDB, dpath, dbpath); + std::string dpath= mCurrentDirectory + "/.gimmick/Shared/gimmick/localdatabase_Descriptor.dscp"; + boost::algorithm::replace_all( dpath, + INVALID_FILE_SEPARATOR , + VALID_FILE_SEPARATOR); + mLocalDatabase = createDB(i_nameDB, dpath, dbpath); // Add it to the TreeHandlerMap mTreeHandlerMap[i_nameDB] = mLocalDatabase; - //Add additional DB from user Settings - addDBSettings(); - - + //Add additional DB from user Settings + addDBSettings(); } /////////////////////////////////////////////////////////////////////// - // add DB to TreeHandler Map // - // @param i_name : DB name // - // @param i_location : DB location // - // return : - // - /////////////////////////////////////////////////////////////////////// - void Gimmick::addDB(const std::string &i_name, - const std::string &i_location) + // add DB to TreeHandler Map // + // @param i_name : DB name // + // @param i_location : DB location // + // return : - // + //////////////////////////////////////////////////////////////////////// + void Gimmick::addDB(const std::string &i_name, + const std::string &i_location) { if(mTreeHandlerMap.find(i_name) == mTreeHandlerMap.end()) { @@ -91,16 +85,16 @@ namespace creaImageIO } } - /////////////////////////////////////////////////////////////////////////// - // create a DB from a attributes descriptor file for medical images // - // @param i_name : DB name // - // @param i_locDesc : location of descriptor file // - // @param i_locDB : location of DB // - // return : the SQLiteTreeHandler object on DB // - ///////////////////////////////////////////////////////////////////////// - SQLiteTreeHandler *Gimmick::createDB(const std::string &i_name, - const std::string &i_locDesc, - const std::string &i_locDB) + //////////////////////////////////////////////////////////////////////// + // create a DB from a attributes descriptor file for medical images // + // @param i_name : DB name // + // @param i_locDesc : location of descriptor file // + // @param i_locDB : location of DB // + // return : the SQLiteTreeHandler object on DB // + ////////////////////////////////////////////////////////////////// + SQLiteTreeHandler *Gimmick::createDB(const std::string &i_name, + const std::string &i_locDesc, + const std::string &i_locDB) { SQLiteTreeHandler *sqlTreeH = new SQLiteTreeHandler(i_locDB); // Create or open local database @@ -114,8 +108,8 @@ namespace creaImageIO // CREATING DB STRUCTURE sqlTreeH->GetTree().GetDescriptor().createDescriptorfromFile(i_locDesc); if ( ! sqlTreeH->Create(true) ) - { - GimmickError("ERROR CREATING '"<SetAttribute(0,"Name",i_name); } @@ -123,22 +117,22 @@ namespace creaImageIO { /// Open and test it GimmickMessage(1,"Opening local database '" <Open(true) ) + if ( !sqlTreeH->Open(true) ) { GimmickError("ERROR OPENING '"<second; } @@ -199,7 +193,6 @@ namespace creaImageIO return mLocalDatabasePath; } - //======================================================================== //======================================================================== @@ -237,10 +230,17 @@ namespace creaImageIO path=path.substr(0,path.size()-1); path=path.substr(0,path.find_last_of("/")); //Creating directories + +// The following stuff works on Linux, NOT CHECKED on Windows // JPR + +#if defined(_WIN32) path+="/bin/Shared/gimmick/localdatabase_Descriptor.dscp"; - std::cout<<"From: "<second; } - - //======================================================================== /// Add the files to the tree handler void Gimmick::AddFiles(const std::string& d, @@ -288,10 +286,9 @@ namespace creaImageIO GimmickMessage(2,"Adding files to '"<getValue(name); + value = mSettings->getValue(name); } //======================================================================== //======================================================================== void Gimmick::GetAttributes(const std::string& d, - const std::string& filename, - const std::vector& params, - std::vector& results) + const std::string& filename, + const std::vector& params, + std::vector& results) { TreeHandler * handler=GetTreeHandler(d); mImageAdder.SetCurrentDatabase(d); @@ -384,32 +381,32 @@ namespace creaImageIO void Gimmick::DeleteDrive(const std::string& drive) { - for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin(); - it!= mTreeHandlerMap.end(); ++it) + for( TreeHandlerMapType::const_iterator it = mTreeHandlerMap.begin(); + it!= mTreeHandlerMap.end(); + ++it) { mImageAdder.SetTreeHandler(it->second); mImageAdder.DeleteDriveFromMainDB(drive); } - mImageAdder.SetSynchronizer(mSynchronizer); - mImageAdder.DeleteDriveFromOtherDB(drive); + mImageAdder.SetSynchronizer(mSynchronizer); + mImageAdder.DeleteDriveFromOtherDB(drive); } //======================================================================== void Gimmick::EditField(tree::Node* node, const std::string& d, const std::string& name, const std::string& key, const std::string& val) { - TreeHandler * handler=GetTreeHandler(d); - mImageAdder.SetCurrentDatabase(d); - mImageAdder.SetTreeHandler(handler); - mImageAdder.EditField(node,name,key,val); + TreeHandler * handler=GetTreeHandler(d); + mImageAdder.SetCurrentDatabase(d); + mImageAdder.SetTreeHandler(handler); + mImageAdder.EditField(node,name,key,val); } //======================================================================== - - ///////////////////////////////////////////////////////////////////////// - // add DB from Settings file // - // @param : - // - // return : - // - ///////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// + // add DB from Settings file // + // @param : - // + // return : - // + //////////////////////////////////////////////////////////////////////// void Gimmick::addDBSettings() { @@ -436,7 +433,5 @@ namespace creaImageIO std::string name = it_path->substr(pos +1, last_pos -pos-1 ); addDB(name, it_path->c_str()); } - - } - + } }