openModeller  Version 1.4.0
TeDatabaseManager.cpp
Go to the documentation of this file.
00001 
00031 #include <openmodeller/TeDatabaseManager.hh>
00032 
00036 TeDatabaseManager& 
00037 TeDatabaseManager::instance()
00038 {
00039   static TeDatabaseManager unique_;
00040   return unique_;
00041 }
00042 
00044 
00048 TeDatabase*
00049 TeDatabaseManager::create( const TeDatabaseFactoryParams& params )
00050 {
00051   string id = params.dbms_name_ +
00052     params.database_ +
00053     params.host_ +
00054     params.user_;
00055 
00056   MapManager::const_iterator i = mapManager_.find( id );
00057   if( i != mapManager_.end() )
00058   {
00059     return i->second;
00060   }
00061   else
00062   {
00063     TeDatabase* tedb = TeDatabaseFactory::make( params );
00064     mapManager_.insert( MapManager::value_type(id, tedb) ).second;
00065     return tedb;
00066   }
00067 }
00068 
00070 
00073 TeDatabaseManager::~TeDatabaseManager()
00074 {
00075   // TODO - Test with other database (not Ado)
00076   /*MapManager::const_iterator i = mapManager_.begin();
00077   MapManager::const_iterator end = mapManager_.end();
00078   
00079   for(; i != end; ++i)
00080   {
00081     i->second->close();
00082     delete (i->second);
00083   }*/
00084 }