CMS 3D CMS Logo

PoolContainerManager.cc

Go to the documentation of this file.
00001 #include "CondCore/DBCommon/interface/PoolContainerManager.h"
00002 #include "CondCore/DBCommon/interface/PoolTransaction.h"
00003 #include "PersistencySvc/ISession.h"
00004 #include "PersistencySvc/IDatabase.h"
00005 #include "PersistencySvc/ITokenIterator.h"
00006 #include "PersistencySvc/IContainer.h"
00007 #include "POOLCore/Token.h"
00008 #include "StorageSvc/DbType.h"
00009 #include "DataSvc/IDataSvc.h"
00010 #include "DataSvc/RefBase.h"
00011 #include "DataSvc/AnyPtr.h"
00012 #include <algorithm>
00013 cond::PoolContainerManager::PoolContainerManager(  cond::PoolTransaction& pooldb ) : m_pooldb(&pooldb){  
00014 }
00015 void 
00016 cond::PoolContainerManager::listAll( std::vector<std::string>& containers ){
00017   std::string con=m_pooldb->parentConnection().connectStr();
00018   pool::IDatabase* mydb=m_pooldb->poolDataSvc().session().databaseHandle(con, pool::DatabaseSpecification::PFN);
00019   mydb->connectForRead();
00020   mydb->containers().swap(containers);
00021   mydb->disconnect();
00022   delete mydb;
00023 }
00024 void 
00025 cond::PoolContainerManager::exportContainer( cond::PoolTransaction& destdb, 
00026                                              const std::string& containername,
00027                                              const std::string& className){
00028   std::string con=m_pooldb->parentConnection().connectStr();
00029   pool::IDataSvc* datasvc=&(m_pooldb->poolDataSvc());
00030   const ROOT::Reflex::Type myclassType=ROOT::Reflex::Type::ByName(className);
00031   pool::Placement destPlace;
00032   destPlace.setDatabase(destdb.parentConnection().connectStr(), 
00033                         pool::DatabaseSpecification::PFN );
00034   destPlace.setContainerName(containername);
00035   destPlace.setTechnology(pool::POOL_RDBMS_HOMOGENEOUS_StorageType.type());
00036   pool::ITokenIterator* tokenIt=datasvc->session().databaseHandle(con,pool::DatabaseSpecification::PFN)->containerHandle(containername)->tokens("");
00037   pool::Token* myToken=0;
00038   while( (myToken=tokenIt->next())!=0 ){
00039     pool::RefBase myobj(datasvc,*myToken,myclassType.TypeInfo() );
00040     const pool::AnyPtr myPtr=myobj.object().get();
00041     pool::RefBase mycopy(&(destdb.poolDataSvc()),myPtr,myclassType.TypeInfo());
00042     mycopy.markWrite(destPlace);
00043     myToken->release();
00044   }
00045   delete tokenIt;//?????what about others?
00046 }

Generated on Tue Jun 9 17:26:06 2009 for CMSSW by  doxygen 1.5.4