| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 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 121 of file PoolDbEvtSelector.cpp.

    00123   : base_class( name, svcloc),
    00124     m_rootCLID(CLID_NULL)
    00125 {
    00126   declareProperty("CnvService",  m_cnvSvcName);
    00127   pool::DbInstanceCount::increment(this);
    00128 }

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

Standard destructor.

Definition at line 130 of file PoolDbEvtSelector.cpp.

    00130                                       {
    00131   pool::DbInstanceCount::decrement(this);
    00132 }

## Member Function Documentation

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

IService implementation: Db event selector override.

Reimplemented from Service.

Definition at line 135 of file PoolDbEvtSelector.cpp.

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

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

IService implementation: Service finalization.

Reimplemented from Service.

Definition at line 168 of file PoolDbEvtSelector.cpp.

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

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 180 of file PoolDbEvtSelector.cpp.

    00181 {
    00182   refpCtxt = new PoolDbContext(this);
    00183   return StatusCode::SUCCESS;
    00184 }

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 187 of file PoolDbEvtSelector.cpp.

    00187                                                                  {
    00188   return StatusCode::FAILURE;
    00189 }

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 192 of file PoolDbEvtSelector.cpp.

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

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 235 of file PoolDbEvtSelector.cpp.

    00236 {
    00237   if ( jump > 0 ) {
    00238     for ( int i = 0; i < jump; ++i ) {
    00239       StatusCode status = next(ctxt);
    00240       if ( !status.isSuccess() ) {
    00241         return status;
    00242       }
    00243     }
    00244     return StatusCode::SUCCESS;
    00245   }
    00246   return StatusCode::FAILURE;
    00247 }

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 250 of file PoolDbEvtSelector.cpp.

    00251 {
    00252   MsgStream log(msgSvc(), name());
    00253   log << MSG::FATAL
    00254     << " EventSelector Iterator, operator -- not supported " << endmsg;
    00255   return StatusCode::FAILURE;
    00256 }

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 259 of file PoolDbEvtSelector.cpp.

    00260 {
    00261   if ( jump > 0 ) {
    00262     for ( int i = 0; i < jump; ++i ) {
    00263       StatusCode status = previous(ctxt);
    00264       if ( !status.isSuccess() ) {
    00265         return status;
    00266       }
    00267     }
    00268     return StatusCode::SUCCESS;
    00269   }
    00270   return StatusCode::FAILURE;
    00271 }

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 274 of file PoolDbEvtSelector.cpp.

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

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 291 of file PoolDbEvtSelector.cpp.

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

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 310 of file PoolDbEvtSelector.cpp.

    00311 {
    00312   PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(ctxt);
    00313   if ( pCtxt ) {
    00314     pool::deletePtr(pCtxt);
    00315     return StatusCode::SUCCESS;
    00316   }
    00317   return StatusCode::FAILURE;
    00318 }

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 321 of file PoolDbEvtSelector.cpp.

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

## 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_v21r8/GaudiPoolDb/GaudiPoolDb/PoolDbEvtSelector.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiPoolDb/src/PoolDbEvtSelector.cpp