| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# PoolDbEvtSelector Class Reference

`#include <PoolDbEvtSelector.h>`

Inheritance diagram for PoolDbEvtSelector:
[legend]
Collaboration diagram for PoolDbEvtSelector:
[legend]

List of all members.

## Public Member Functions
virtual StatusCode | initialize ()
| IService implementation: Db event selector override.
virtual StatusCode | finalize ()
| IService implementation: Service finalization.
virtual StatusCode | createContext (Context *&refpCtxt) const
| Create a new event loop context.
virtual StatusCode | last (Context &refContext) const
| Access last item in the iteration.
virtual StatusCode | next (Context &refCtxt) const
| Get next iteration item from the event loop context.
virtual StatusCode | next (Context &refCtxt, int jump) const
| Get next iteration item from the event loop context, but skip jump elements.
virtual StatusCode | previous (Context &refCtxt) const
| Get previous iteration item from the event loop context.
virtual StatusCode | previous (Context &refCtxt, int jump) const
| Get previous iteration item from the event loop context, but skip jump elements.
virtual StatusCode | rewind (Context &refCtxt) const
| Rewind the dataset.
virtual StatusCode | createAddress (const Context &refCtxt, IOpaqueAddress *&) const
| Create new Opaque address corresponding to the current record.
virtual StatusCode | releaseContext (Context *&refCtxt) const
| Release existing event iteration context.
virtual StatusCode | resetCriteria (const std::string &cr, Context &c) const
| Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.
| PoolDbEvtSelector (const std::string &name, ISvcLocator *svcloc)
| Service Constructor.
virtual | ~PoolDbEvtSelector ()
| Standard destructor.
## Protected Attributes
std::string | m_cnvSvcName
SmartIF< IPoolDbMgr > | m_dbMgr
CLID | m_rootCLID
std::string | m_rootName
std::string | m_criteria

## Detailed Description

Definition at line 39 of file PoolDbEvtSelector.h.

## Constructor & Destructor Documentation

PoolDbEvtSelector::PoolDbEvtSelector | ( | const std::string & | name,
|  | ISvcLocator * | svcloc |
| ) |  |  |

Service Constructor.

Definition at line 126 of file PoolDbEvtSelector.cpp.

    00128   : base_class( name, svcloc),
    00129     m_rootCLID(CLID_NULL)
    00130 {
    00131   declareProperty("CnvService",  m_cnvSvcName);
    00132   pool::DbInstanceCount::increment(this);
    00133 }

PoolDbEvtSelector::~PoolDbEvtSelector | ( |  | ) | `[virtual]`

Standard destructor.

Definition at line 135 of file PoolDbEvtSelector.cpp.

    00135                                       {
    00136   pool::DbInstanceCount::decrement(this);
    00137 }

## Member Function Documentation

StatusCode PoolDbEvtSelector::initialize | ( |  | ) | `[virtual]`

IService implementation: Db event selector override.

Reimplemented from Service.

Definition at line 140 of file PoolDbEvtSelector.cpp.

    00140                                             {
    00141   // Initialize base class
    00142   StatusCode status = Service::initialize();
    00143   MsgStream log(msgSvc(), name());
    00144   if ( !status.isSuccess() )    {
    00145     log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
    00146     return status;
    00147   }
    00148   // Retrieve conversion service handling event iteration
    00149   m_dbMgr = serviceLocator()->service(m_cnvSvcName);
    00150   if( !m_dbMgr.isValid() ) {
    00151     log << MSG::ERROR
    00152         << "Unable to localize interface IPoolDbMgr from service:"
    00153         << m_cnvSvcName << endmsg;
    00154     return StatusCode::FAILURE;
    00155   }
    00156   // Get DataSvc
    00157   SmartIF<IDataManagerSvc> eds(serviceLocator()->service("EventDataSvc"));
    00158   if( !eds.isValid() ) {
    00159     log << MSG::ERROR
    00160       << "Unable to localize interface IDataManagerSvc "
    00161       << "from service EventDataSvc"
    00162             << endmsg;
    00163     return status;
    00164   }
    00165   m_rootCLID = eds->rootCLID();
    00166   m_rootName = eds->rootName();
    00167   log << MSG::DEBUG << "Selection root:" << m_rootName
    00168                     << " CLID:" << m_rootCLID << endmsg;
    00169   return status;
    00170 }

StatusCode PoolDbEvtSelector::finalize | ( |  | ) | `[virtual]`

IService implementation: Service finalization.

Reimplemented from Service.

Definition at line 173 of file PoolDbEvtSelector.cpp.

    00173                                           {
    00174   // Initialize base class
    00175   MsgStream log(msgSvc(), name());
    00176   m_dbMgr = 0; // release
    00177   StatusCode status = Service::finalize();
    00178   if ( !status.isSuccess() )    {
    00179     log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
    00180   }
    00181   return status;
    00182 }

StatusCode PoolDbEvtSelector::createContext | ( | Context *& | refpCtxt | ) | const`[virtual]`

Create a new event loop context.

Parameters:

  | refpCtxt | [IN/OUT] Reference to pointer to store the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 185 of file PoolDbEvtSelector.cpp.

    00186 {
    00187   refpCtxt = new PoolDbContext(this);
    00188   return StatusCode::SUCCESS;
    00189 }

StatusCode PoolDbEvtSelector::last | ( | Context & | refContext | ) | const`[virtual]`

Access last item in the iteration.

Parameters:

  | refContext | [IN/OUT] Reference to the Context object.

Implements IEvtSelector.

Definition at line 192 of file PoolDbEvtSelector.cpp.

    00192                                                                  {
    00193   return StatusCode::FAILURE;
    00194 }

StatusCode PoolDbEvtSelector::next | ( | Context & | refCtxt | ) | const`[virtual]`

Get next iteration item from the event loop context.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 197 of file PoolDbEvtSelector.cpp.

    00198 {
    00199   PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(&ctxt);
    00200   if ( pCtxt != 0 ) {
    00201     pool::DbSelect* it = pCtxt->iterator();
    00202     if ( !it ) {
    00203       PoolDbContext::ListName::const_iterator fileit = pCtxt->fileIterator();
    00204       if ( pCtxt->currentInput().length() > 0 ) {
    00205         pCtxt->setToken(0);
    00206         m_dbMgr->disconnect(pCtxt->currentInput());
    00207       }
    00208       if ( fileit != pCtxt->files().end() ) {
    00209         std::string input = *fileit;
    00210         pCtxt->setFileIterator(++fileit);
    00211         it = pCtxt->selectInput(m_dbMgr, "", input, m_rootName);
    00212       }
    00213     }
    00214     if ( it ) {
    00215       pool::Token* token = 0;
    00216       if ( it->next(token).isSuccess() )  {
    00217         pCtxt->setToken(token);
    00218         if( 0 == pCtxt->token() ) {
    00219           pCtxt->setIterator(0);
    00220           return next(ctxt);
    00221         }
    00222         return StatusCode::SUCCESS;
    00223       }
    00224       return StatusCode::FAILURE;
    00225     }
    00226   }
    00227   if ( pCtxt ) {
    00228     if ( pCtxt->currentInput().length() > 0 ) {
    00229       m_dbMgr->disconnect( pCtxt->currentInput() );
    00230     }
    00231     pCtxt->setToken(0);
    00232     pCtxt->setIterator(0);
    00233     pCtxt->setCurrentInput("");
    00234     pCtxt->setFileIterator(pCtxt->files().end());
    00235   }
    00236   return StatusCode::FAILURE;
    00237 }

StatusCode PoolDbEvtSelector::next | ( | Context & | refCtxt,
|  | int | jump |
| ) |  |  | const`[virtual]`

Get next iteration item from the event loop context, but skip jump elements.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 240 of file PoolDbEvtSelector.cpp.

    00241 {
    00242   if ( jump > 0 ) {
    00243     for ( int i = 0; i < jump; ++i ) {
    00244       StatusCode status = next(ctxt);
    00245       if ( !status.isSuccess() ) {
    00246         return status;
    00247       }
    00248     }
    00249     return StatusCode::SUCCESS;
    00250   }
    00251   return StatusCode::FAILURE;
    00252 }

StatusCode PoolDbEvtSelector::previous | ( | Context & | refCtxt | ) | const`[virtual]`

Get previous iteration item from the event loop context.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context
  | jump | [IN] Number of events to be skipped

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 255 of file PoolDbEvtSelector.cpp.

    00256 {
    00257   MsgStream log(msgSvc(), name());
    00258   log << MSG::FATAL
    00259     << " EventSelector Iterator, operator -- not supported " << endmsg;
    00260   return StatusCode::FAILURE;
    00261 }

StatusCode PoolDbEvtSelector::previous | ( | Context & | refCtxt,
|  | int | jump |
| ) |  |  | const`[virtual]`

Get previous iteration item from the event loop context, but skip jump elements.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context
  | jump | [IN] Number of events to be skipped

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 264 of file PoolDbEvtSelector.cpp.

    00265 {
    00266   if ( jump > 0 ) {
    00267     for ( int i = 0; i < jump; ++i ) {
    00268       StatusCode status = previous(ctxt);
    00269       if ( !status.isSuccess() ) {
    00270         return status;
    00271       }
    00272     }
    00273     return StatusCode::SUCCESS;
    00274   }
    00275   return StatusCode::FAILURE;
    00276 }

StatusCode PoolDbEvtSelector::rewind | ( | Context & | refCtxt | ) | const`[virtual]`

Rewind the dataset.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 279 of file PoolDbEvtSelector.cpp.

    00280 {
    00281   PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(&ctxt);
    00282   if ( pCtxt ) {
    00283     if ( pCtxt->currentInput().length() > 0 ) {
    00284       m_dbMgr->disconnect( pCtxt->currentInput() );
    00285     }
    00286     pCtxt->setToken(0);
    00287     pCtxt->setIterator(0);
    00288     pCtxt->setCurrentInput("");
    00289     pCtxt->setFileIterator(pCtxt->files().begin());
    00290     return StatusCode::SUCCESS;
    00291   }
    00292   return StatusCode::FAILURE;
    00293 }

StatusCode PoolDbEvtSelector::createAddress | ( | const Context & | refCtxt,
|  | IOpaqueAddress *& | pAddr |
| ) |  |  | const`[virtual]`

Create new Opaque address corresponding to the current record.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 296 of file PoolDbEvtSelector.cpp.

    00297 {
    00298   const PoolDbContext* pctxt = dynamic_cast<const PoolDbContext*>(&ctxt);
    00299   if ( pctxt ) {
    00300     pool::Token* tok = pctxt->token();
    00301     if ( 0 != tok )  {
    00302       PoolDbAddress* pA = 0;
    00303       if ( m_dbMgr->createAddress(tok, &pA).isSuccess() )  {
    00304         pAddr = pA;
    00305         return StatusCode::SUCCESS;
    00306       }
    00307       pool::releasePtr(tok);
    00308     }
    00309   }
    00310   pAddr = 0;
    00311   return StatusCode::FAILURE;
    00312 }

StatusCode PoolDbEvtSelector::releaseContext | ( | Context *& | refCtxt | ) | const`[virtual]`

Release existing event iteration context.

Parameters:

  | refCtxt | [IN/OUT] Reference to the context

Returns:
  StatusCode indicating success or failure

Implements IEvtSelector.

Definition at line 315 of file PoolDbEvtSelector.cpp.

    00316 {
    00317   PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(ctxt);
    00318   if ( pCtxt ) {
    00319     pool::deletePtr(pCtxt);
    00320     return StatusCode::SUCCESS;
    00321   }
    00322   return StatusCode::FAILURE;
    00323 }

StatusCode PoolDbEvtSelector::resetCriteria | ( | const std::string & | cr,
|  | Context & | c |
| ) |  |  | const`[virtual]`

Will set a new criteria for the selection of the next list of events and will change the state of the context in a way to point to the new list.

Parameters:

  | cr | The new criteria string.
  | c | Reference pointer to the Context object.

Implements IEvtSelector.

Definition at line 326 of file PoolDbEvtSelector.cpp.

    00328 {
    00329   MsgStream log(msgSvc(), name());
    00330   PoolDbContext* ctxt = dynamic_cast<PoolDbContext*>(&context);
    00331   std::string db, typ, item, sel, stmt, aut, addr;
    00332   if ( ctxt )  {
    00333     if ( criteria.substr(0,5) == "FILE " )  {
    00334       // The format for the criteria is:
    00335       //        FILE  filename1, filename2 ...
    00336       db = criteria.substr(5);
    00337     }
    00338     else  {
    00339       Tokenizer tok(true);
    00340       tok.analyse(criteria," ","","","=","'","'");
    00341       for(Tokenizer::Items::iterator i=tok.items().begin(); i!=tok.items().end();i++) {
    00342         std::string tmp = (*i).tag().substr(0,3);
    00343         if(tmp=="DAT")  {
    00344           db = (*i).value();
    00345         }
    00346         if(tmp=="OPT")   {
    00347           if((*i).value() != "REA")   {
    00348             log << MSG::ERROR << "Option:\"" << (*i).value() << "\" not valid" << endmsg;
    00349             return StatusCode::FAILURE;
    00350           }
    00351         }
    00352         if (tmp=="TYP") {
    00353           typ = (*i).value();
    00354         }
    00355         if(tmp=="ADD")  {
    00356           item = (*i).value();
    00357         }
    00358         if(tmp=="SEL")  {
    00359           sel = (*i).value();
    00360         }
    00361         if(tmp=="FUN")  {
    00362           stmt = (*i).value();
    00363         }
    00364         if(tmp=="AUT")  {
    00365           aut = (*i).value();
    00366         }
    00367         if(tmp=="COL")  {
    00368           addr = (*i).value();
    00369         }
    00370       }
    00371     }
    00372     // It's now time to parse the criteria for the event selection
    00373     // The format for the criteria is:
    00374     //        FILE  filename1, filename2 ...
    00375     //        JOBID number1-number2, number3, ...
    00376     std::string rest = db;
    00377     ctxt->files().clear();
    00378     while(true)  {
    00379       int ipos = rest.find_first_not_of(" ,");
    00380       if (ipos == -1 ) break;
    00381       rest = rest.substr(ipos, std::string::npos);// remove blanks before
    00382       int lpos  = rest.find_first_of(" ,");       // locate next blank
    00383       ctxt->files().push_back( rest.substr(0,lpos )); // insert in list
    00384       if (lpos == -1 ) break;
    00385       rest = rest.substr(lpos, std::string::npos);// get the rest
    00386     }
    00387     ctxt->setFileIterator(ctxt->files().begin());
    00388     ctxt->setCriteria(criteria);
    00389     return StatusCode::SUCCESS;
    00390   }
    00391   log << MSG::ERROR << "Invalid iteration context." << endmsg;
    00392   return StatusCode::FAILURE;
    00393 }

## Member Data Documentation

std::string PoolDbEvtSelector::m_cnvSvcName`[protected]`

Definition at line 126 of file PoolDbEvtSelector.h.

SmartIF<IPoolDbMgr> PoolDbEvtSelector::m_dbMgr`[mutable, protected]`

Definition at line 127 of file PoolDbEvtSelector.h.

CLID PoolDbEvtSelector::m_rootCLID`[protected]`

Definition at line 128 of file PoolDbEvtSelector.h.

std::string PoolDbEvtSelector::m_rootName`[protected]`

Definition at line 129 of file PoolDbEvtSelector.h.

std::string PoolDbEvtSelector::m_criteria`[protected]`

Definition at line 130 of file PoolDbEvtSelector.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiPoolDb/GaudiPoolDb/PoolDbEvtSelector.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r11/GaudiPoolDb/src/PoolDbEvtSelector.cpp