|
Gaudi Framework, version v22r4 |
| Home | Generated: Fri Sep 2 2011 |
#include <PoolDbEvtSelector.h>


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 |
Definition at line 39 of file PoolDbEvtSelector.h.
| PoolDbEvtSelector::PoolDbEvtSelector | ( | const std::string & | name, |
| ISvcLocator * | svcloc | ||
| ) |
Service Constructor.
Definition at line 126 of file PoolDbEvtSelector.cpp.
: base_class( name, svcloc), m_rootCLID(CLID_NULL) { declareProperty("CnvService", m_cnvSvcName); pool::DbInstanceCount::increment(this); }
| PoolDbEvtSelector::~PoolDbEvtSelector | ( | ) | [virtual] |
Standard destructor.
Definition at line 135 of file PoolDbEvtSelector.cpp.
{
pool::DbInstanceCount::decrement(this);
}
| StatusCode PoolDbEvtSelector::createAddress | ( | const Context & | refCtxt, |
| IOpaqueAddress *& | pAddr | ||
| ) | const [virtual] |
Create new Opaque address corresponding to the current record.
| refCtxt | [IN/OUT] Reference to the context |
Implements IEvtSelector.
Definition at line 296 of file PoolDbEvtSelector.cpp.
{
const PoolDbContext* pctxt = dynamic_cast<const PoolDbContext*>(&ctxt);
if ( pctxt ) {
pool::Token* tok = pctxt->token();
if ( 0 != tok ) {
PoolDbAddress* pA = 0;
if ( m_dbMgr->createAddress(tok, &pA).isSuccess() ) {
pAddr = pA;
return StatusCode::SUCCESS;
}
pool::releasePtr(tok);
}
}
pAddr = 0;
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::createContext | ( | Context *& | refpCtxt ) | const [virtual] |
Create a new event loop context.
| refpCtxt | [IN/OUT] Reference to pointer to store the context |
Implements IEvtSelector.
Definition at line 185 of file PoolDbEvtSelector.cpp.
{
refpCtxt = new PoolDbContext(this);
return StatusCode::SUCCESS;
}
| StatusCode PoolDbEvtSelector::finalize | ( | void | ) | [virtual] |
IService implementation: Service finalization.
Reimplemented from Service.
Definition at line 173 of file PoolDbEvtSelector.cpp.
{
// Initialize base class
MsgStream log(msgSvc(), name());
m_dbMgr = 0; // release
StatusCode status = Service::finalize();
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
}
return status;
}
| StatusCode PoolDbEvtSelector::initialize | ( | void | ) | [virtual] |
IService implementation: Db event selector override.
Reimplemented from Service.
Definition at line 140 of file PoolDbEvtSelector.cpp.
{
// Initialize base class
StatusCode status = Service::initialize();
MsgStream log(msgSvc(), name());
if ( !status.isSuccess() ) {
log << MSG::ERROR << "Error initializing base class Service!" << endmsg;
return status;
}
// Retrieve conversion service handling event iteration
m_dbMgr = serviceLocator()->service(m_cnvSvcName);
if( !m_dbMgr.isValid() ) {
log << MSG::ERROR
<< "Unable to localize interface IPoolDbMgr from service:"
<< m_cnvSvcName << endmsg;
return StatusCode::FAILURE;
}
// Get DataSvc
SmartIF<IDataManagerSvc> eds(serviceLocator()->service("EventDataSvc"));
if( !eds.isValid() ) {
log << MSG::ERROR
<< "Unable to localize interface IDataManagerSvc "
<< "from service EventDataSvc"
<< endmsg;
return status;
}
m_rootCLID = eds->rootCLID();
m_rootName = eds->rootName();
log << MSG::DEBUG << "Selection root:" << m_rootName
<< " CLID:" << m_rootCLID << endmsg;
return status;
}
| StatusCode PoolDbEvtSelector::last | ( | Context & | refContext ) | const [virtual] |
Access last item in the iteration.
| refContext | [IN/OUT] Reference to the Context object. |
Implements IEvtSelector.
Definition at line 192 of file PoolDbEvtSelector.cpp.
{
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::next | ( | Context & | refCtxt ) | const [virtual] |
Get next iteration item from the event loop context.
| refCtxt | [IN/OUT] Reference to the context |
Implements IEvtSelector.
Definition at line 197 of file PoolDbEvtSelector.cpp.
{
PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(&ctxt);
if ( pCtxt != 0 ) {
pool::DbSelect* it = pCtxt->iterator();
if ( !it ) {
PoolDbContext::ListName::const_iterator fileit = pCtxt->fileIterator();
if ( pCtxt->currentInput().length() > 0 ) {
pCtxt->setToken(0);
m_dbMgr->disconnect(pCtxt->currentInput());
}
if ( fileit != pCtxt->files().end() ) {
std::string input = *fileit;
pCtxt->setFileIterator(++fileit);
it = pCtxt->selectInput(m_dbMgr, "", input, m_rootName);
}
}
if ( it ) {
pool::Token* token = 0;
if ( it->next(token).isSuccess() ) {
pCtxt->setToken(token);
if( 0 == pCtxt->token() ) {
pCtxt->setIterator(0);
return next(ctxt);
}
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
}
if ( pCtxt ) {
if ( pCtxt->currentInput().length() > 0 ) {
m_dbMgr->disconnect( pCtxt->currentInput() );
}
pCtxt->setToken(0);
pCtxt->setIterator(0);
pCtxt->setCurrentInput("");
pCtxt->setFileIterator(pCtxt->files().end());
}
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::next | ( | Context & | refCtxt, |
| int | jump | ||
| ) | const [virtual] |
Get next iteration item from the event loop context, but skip jump elements.
| refCtxt | [IN/OUT] Reference to the context |
Implements IEvtSelector.
Definition at line 240 of file PoolDbEvtSelector.cpp.
{
if ( jump > 0 ) {
for ( int i = 0; i < jump; ++i ) {
StatusCode status = next(ctxt);
if ( !status.isSuccess() ) {
return status;
}
}
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::previous | ( | Context & | refCtxt, |
| int | jump | ||
| ) | const [virtual] |
Get previous iteration item from the event loop context, but skip jump elements.
| refCtxt | [IN/OUT] Reference to the context |
| jump | [IN] Number of events to be skipped |
Implements IEvtSelector.
Definition at line 264 of file PoolDbEvtSelector.cpp.
{
if ( jump > 0 ) {
for ( int i = 0; i < jump; ++i ) {
StatusCode status = previous(ctxt);
if ( !status.isSuccess() ) {
return status;
}
}
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::previous | ( | Context & | refCtxt ) | const [virtual] |
Get previous iteration item from the event loop context.
| refCtxt | [IN/OUT] Reference to the context |
| jump | [IN] Number of events to be skipped |
Implements IEvtSelector.
Definition at line 255 of file PoolDbEvtSelector.cpp.
{
MsgStream log(msgSvc(), name());
log << MSG::FATAL
<< " EventSelector Iterator, operator -- not supported " << endmsg;
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::releaseContext | ( | Context *& | refCtxt ) | const [virtual] |
Release existing event iteration context.
| refCtxt | [IN/OUT] Reference to the context |
Implements IEvtSelector.
Definition at line 315 of file PoolDbEvtSelector.cpp.
{
PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(ctxt);
if ( pCtxt ) {
pool::deletePtr(pCtxt);
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
| 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.
| cr | The new criteria string. |
| c | Reference pointer to the Context object. |
Implements IEvtSelector.
Definition at line 326 of file PoolDbEvtSelector.cpp.
{
MsgStream log(msgSvc(), name());
PoolDbContext* ctxt = dynamic_cast<PoolDbContext*>(&context);
std::string db, typ, item, sel, stmt, aut, addr;
if ( ctxt ) {
if ( criteria.substr(0,5) == "FILE " ) {
// The format for the criteria is:
// FILE filename1, filename2 ...
db = criteria.substr(5);
}
else {
Tokenizer tok(true);
tok.analyse(criteria," ","","","=","'","'");
for(Tokenizer::Items::iterator i=tok.items().begin(); i!=tok.items().end();i++) {
std::string tmp = (*i).tag().substr(0,3);
if(tmp=="DAT") {
db = (*i).value();
}
if(tmp=="OPT") {
if((*i).value() != "REA") {
log << MSG::ERROR << "Option:\"" << (*i).value() << "\" not valid" << endmsg;
return StatusCode::FAILURE;
}
}
if (tmp=="TYP") {
typ = (*i).value();
}
if(tmp=="ADD") {
item = (*i).value();
}
if(tmp=="SEL") {
sel = (*i).value();
}
if(tmp=="FUN") {
stmt = (*i).value();
}
if(tmp=="AUT") {
aut = (*i).value();
}
if(tmp=="COL") {
addr = (*i).value();
}
}
}
// It's now time to parse the criteria for the event selection
// The format for the criteria is:
// FILE filename1, filename2 ...
// JOBID number1-number2, number3, ...
std::string rest = db;
ctxt->files().clear();
while(true) {
size_t ipos = rest.find_first_not_of(" ,");
if (ipos == std::string::npos ) break;
rest = rest.substr(ipos, std::string::npos);// remove blanks before
size_t lpos = rest.find_first_of(" ,"); // locate next blank
ctxt->files().push_back( rest.substr(0,lpos )); // insert in list
if (lpos == std::string::npos ) break;
rest = rest.substr(lpos, std::string::npos);// get the rest
}
ctxt->setFileIterator(ctxt->files().begin());
ctxt->setCriteria(criteria);
return StatusCode::SUCCESS;
}
log << MSG::ERROR << "Invalid iteration context." << endmsg;
return StatusCode::FAILURE;
}
| StatusCode PoolDbEvtSelector::rewind | ( | Context & | refCtxt ) | const [virtual] |
Rewind the dataset.
| refCtxt | [IN/OUT] Reference to the context |
Implements IEvtSelector.
Definition at line 279 of file PoolDbEvtSelector.cpp.
{
PoolDbContext* pCtxt = dynamic_cast<PoolDbContext*>(&ctxt);
if ( pCtxt ) {
if ( pCtxt->currentInput().length() > 0 ) {
m_dbMgr->disconnect( pCtxt->currentInput() );
}
pCtxt->setToken(0);
pCtxt->setIterator(0);
pCtxt->setCurrentInput("");
pCtxt->setFileIterator(pCtxt->files().begin());
return StatusCode::SUCCESS;
}
return StatusCode::FAILURE;
}
std::string PoolDbEvtSelector::m_cnvSvcName [protected] |
Definition at line 126 of file PoolDbEvtSelector.h.
std::string PoolDbEvtSelector::m_criteria [protected] |
Definition at line 130 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.