openModeller  Version 1.5.0
TeDatabaseManager.cpp
Go to the documentation of this file.
1 
32 
38 {
39  static TeDatabaseManager unique_;
40  return unique_;
41 }
42 
44 
48 TeDatabase*
49 TeDatabaseManager::create( const TeDatabaseFactoryParams& params )
50 {
51  string id = params.dbms_name_ +
52  params.database_ +
53  params.host_ +
54  params.user_;
55 
56  MapManager::const_iterator i = mapManager_.find( id );
57  if( i != mapManager_.end() )
58  {
59  return i->second;
60  }
61  else
62  {
63  TeDatabase* tedb = TeDatabaseFactory::make( params );
64  mapManager_.insert( MapManager::value_type(id, tedb) ).second;
65  return tedb;
66  }
67 }
68 
70 
74 {
75  // TODO - Test with other database (not Ado)
76  /*MapManager::const_iterator i = mapManager_.begin();
77  MapManager::const_iterator end = mapManager_.end();
78 
79  for(; i != end; ++i)
80  {
81  i->second->close();
82  delete (i->second);
83  }*/
84 }
Manages TeDatabases connections.
TeDatabase * create(const TeDatabaseFactoryParams &params)
Return a TeDatabase pointer if it exists or create a new one.
static TeDatabaseManager & instance()
Singleton pattern.
MapManager mapManager_
Map of TeDatabase and identifiers.
~TeDatabaseManager()
No destruct allowed.