CMS 3D CMS Logo

ContainerIterator.h

Go to the documentation of this file.
00001 #ifndef CondCore_DBCommon_ContainerIterator_h
00002 #define CondCore_DBCommon_ContainerIterator_h
00003 #include "Collection/Collection.h"
00004 #include "CondCore/DBCommon/interface/TypedRef.h"
00005 
00006 //#include <iostream>
00007 namespace cond{
00008   class Connection;
00009   /*
00010    *wrapper around pool implicit collection
00011    **/
00012   template<typename DataT>
00013     class ContainerIterator{
00014     public:
00015     ContainerIterator( PoolTransaction& pooldb, 
00016                        const std::string& containername):
00017       m_pooldb(&pooldb), m_collection(new pool::Collection<DataT>( &(pooldb.poolDataSvc()),"ImplicitCollection","PFN:" + pooldb.parentConnection().connectStr(),containername, pool::ICollection::READ )),m_it(m_collection->select()){
00018     }
00019     std::string dataToken(){
00020       return m_data.token();
00021     }
00022     cond::TypedRef<DataT>& dataRef(){
00023       return m_data;
00024     }
00025     bool next(){ 
00026       if( m_it.next() ){
00027         m_data=cond::TypedRef<DataT>(*m_pooldb,m_it.ref());
00028         return true;
00029       }
00030       return false;
00031     }
00032     std::string name(){
00033       return m_collection->name();
00034     }
00035     virtual ~ContainerIterator(){
00036       delete m_collection;
00037     }
00038     private:
00039     mutable cond::TypedRef<DataT> m_data;
00040     cond::PoolTransaction* m_pooldb;
00041     pool::Collection<DataT>* m_collection;
00042     typename pool::Collection<DataT>::Iterator m_it;
00043   };
00044 }//ns cond
00045 #endif

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