CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CondCore/Utilities/src/CondBasicIter.cc

Go to the documentation of this file.
00001 #include "CondCore/Utilities/interface/CondBasicIter.h"
00002 
00003 CondBasicIter::CondBasicIter(){}
00004 CondBasicIter::~CondBasicIter(){}
00005 
00006 CondBasicIter::CondBasicIter(
00007                              const std::string & NameDB,
00008                              const std::string & Tag,
00009                              const std::string & User,
00010                              const std::string & Pass,
00011                              const std::string & nameBlob) :
00012   rdbms(User,Pass), 
00013   db(rdbms.getDB(NameDB)), 
00014   iov(db.iov(Tag)),
00015   m_begin( iov.begin() ),
00016   m_end( iov.end() ){
00017 }
00018 
00019 CondBasicIter::CondBasicIter(const std::string & NameDB,
00020               const std::string & Tag,
00021               const std::string & auth
00022               ):
00023   rdbms(auth), 
00024   db(rdbms.getDB(NameDB)), 
00025   iov(db.iov(Tag)),
00026   m_begin( iov.begin() ),
00027   m_end( iov.end() ){
00028 }
00029 
00030 void CondBasicIter::create(
00031                            const std::string & NameDB,
00032                            const std::string & Tag,
00033                            const std::string & User,
00034                            const std::string & Pass,
00035                            const std::string & nameBlob) {
00036   rdbms = cond::RDBMS(User,Pass);
00037   db = rdbms.getDB(NameDB);
00038   iov = db.iov(Tag);
00039   clear();
00040 }
00041 
00042 void CondBasicIter::create(const std::string & NameDB,
00043                            const std::string & Tag,
00044                            const std::string & auth
00045                            ) {
00046   rdbms = cond::RDBMS(auth);
00047   db = rdbms.getDB(NameDB);
00048   iov = db.iov(Tag);
00049   clear();
00050 }
00051 
00052 
00053 void CondBasicIter::setRange(unsigned int min,unsigned int max){
00054   cond::IOVRange rg = iov.range( min, max );
00055   m_begin = rg.begin();
00056   m_end = rg.end();
00057   clear();
00058 }
00059 
00060 void CondBasicIter::setMin(unsigned int min){
00061   cond::IOVRange rg = iov.range( min, 0 );
00062   m_begin = rg.begin();
00063   m_end = rg.end();
00064   clear();
00065 }
00066 
00067 void CondBasicIter::setMax(unsigned int max){
00068   cond::IOVRange rg = iov.range( 1, max );
00069   m_begin = rg.begin();
00070   m_end = rg.end();
00071   clear();
00072 }
00073 
00074 unsigned int CondBasicIter::getTime()  const {return (getStartTime()+getStopTime())/2;}
00075 
00076 unsigned int CondBasicIter::getStartTime()  const {return (*iter).since();}
00077 
00078 unsigned int CondBasicIter::getStopTime() const {return (*iter).till();}
00079 
00080 std::string const & CondBasicIter::getToken() const  {return (*iter).token();}
00081 
00082 bool CondBasicIter::init() {
00083   iter = m_begin;
00084   return iter!=m_end;
00085 
00086 }
00087 
00088 bool CondBasicIter::forward(){
00089   ++iter;
00090   return iter!=m_end;
00091 }
00092 
00093 
00094 bool CondBasicIter::make(){
00095   return load(db.session(),(*iter).token());
00096 }
00097