/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Classes | Public Member Functions | Protected Attributes
RootIOEvtSelector Class Reference

Example event selector for RootIO. More...

#include <RootIOEvtSelector.h>

Collaboration diagram for RootIOEvtSelector:
Collaboration graph
[legend]

List of all members.

Classes

class  Context

Public Member Functions

 RootIOEvtSelector (const std::string &name, ISvcLocator *svcloc)
virtual ~RootIOEvtSelector ()
virtual StatusCode setEntry (RootIOEvtSelector::Context &rc, int entry) const
 Extended interface:
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode createContext (IEvtSelector::Context *&c) const
 Create and return a context object that will keep track of the state of selection.
virtual StatusCode next (IEvtSelector::Context &c) const
 Fetch the next event or the first event if it will be use soon after the creation of the context.
virtual StatusCode next (IEvtSelector::Context &c, int jump) const
 Same of next(const Context&) plus the possibility to jump the next n-1 events.
virtual StatusCode previous (IEvtSelector::Context &c) const
 Fetch the previous event.
virtual StatusCode previous (IEvtSelector::Context &c, int jump) const
 Same of previous(Context& c) the possibility to jump the previous n-1 events.
virtual StatusCode last (IEvtSelector::Context &refContext) const
 Access last item in the iteration.
virtual StatusCode rewind (IEvtSelector::Context &c) const
 Will set the state of the context in a way that the next event read is the first of the list.
virtual StatusCode createAddress (const IEvtSelector::Context &c, IOpaqueAddress *&iop) const
 Create an IOpaqueAddress object from the event fetched.
virtual StatusCode releaseContext (IEvtSelector::Context *&c) const
 Release the Context object.
virtual StatusCode resetCriteria (const std::string &cr, IEvtSelector::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.
StatusCode queryInterface (const InterfaceID &riid, void **ppif)

Protected Attributes

IRootIOSvcm_rioSvc

Detailed Description

Example event selector for RootIO.

This loads in all input streams and assume each are to be kept in lock-step sync.

bv@bnl.gov Thu Jul 3 11:00:03 2008

Definition at line 20 of file RootIOEvtSelector.h.


Constructor & Destructor Documentation

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

Definition at line 12 of file RootIOEvtSelector.cc.

    : Service(name,svcloc)
    , m_rioSvc(0)
{

}
RootIOEvtSelector::~RootIOEvtSelector ( ) [virtual]

Definition at line 19 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "RootIOEvtSelector::~RootIOEvtSelector()" << endreq;
}

Member Function Documentation

StatusCode RootIOEvtSelector::setEntry ( RootIOEvtSelector::Context rc,
int  entry 
) const [virtual]

Extended interface:

This will be called from the IEvtSelector navigation methods with the context prior to navigation (old entry) and the new entry. By default this sets the context to the new entry and then loads all possible input streams to that entry.

Subclasses may override this method to enforce some other input policy.

Definition at line 116 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "setEntry(" << entry << ")" << endreq;

    IRootIOSvc::InputStreamMap& ism = m_rioSvc->inputStreams();
    IRootIOSvc::InputStreamMap::iterator it, done = ism.end();
    int errors = 0;
    for (it = ism.begin(); it != done; ++it) {
        RootInputStream* ris = it->second;
        bool okay = ris->setEntry(entry);
        if (!okay) {
            log << MSG::WARNING
                << "setEntry("<<entry<<") failed to set entry on input stream for " 
                << it->first << endreq;
            ++errors;
            continue;
        }
    }

    if (errors) return StatusCode::FAILURE;
    rc.m_entry = entry;
    return StatusCode::SUCCESS;
}
StatusCode RootIOEvtSelector::initialize ( ) [virtual]

Definition at line 25 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "initializing @" << (void*)this << endreq;
    log << MSG::DEBUG << "called " << this->name() << endreq;

    StatusCode sc = this->Service::initialize();
    if (sc.isFailure()) return sc;

    IService* isvc=0;
    sc = serviceLocator()->service("RootIOCnvSvc", isvc, false);
    //sc = serviceLocator()->service("EventPersistencySvc", isvc, false);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Conversion service RootIOCnvSvc"
            << " could not be retrieved" << endreq;
        return sc;
    }
    isvc->addRef();

    sc = isvc->queryInterface(IRootIOSvc::interfaceID(), (void**)&m_rioSvc);
    if (sc.isFailure()) {
        log << MSG::ERROR << "Conversion service RootIOCnvSvc"
            << " does not implement IRootIOCnvSvc" << endreq;
        return sc;
    }

    log << MSG::DEBUG << "initialized @" << (void*)this
        << " got RootIOCnvSvc @" << (void*)m_rioSvc
        << endreq;
    return sc;
}
StatusCode RootIOEvtSelector::finalize ( ) [virtual]

Definition at line 56 of file RootIOEvtSelector.cc.

{
    return this->Service::finalize();
}
StatusCode RootIOEvtSelector::createContext ( IEvtSelector::Context *&  c) const [virtual]

Create and return a context object that will keep track of the state of selection.

Parameters:
cReference of a pointer to a Context object.

Definition at line 62 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "createContext" << endreq;

    c = new RootIOEvtSelector::Context(this);
    return StatusCode::SUCCESS;
}
StatusCode RootIOEvtSelector::next ( IEvtSelector::Context &  c) const [virtual]

Fetch the next event or the first event if it will be use soon after the creation of the context.

It will return StatusCode::FAILURE if there have been problem in the fetching or it has been reached the end of the list of events.

Parameters:
cReference to the Context object.

Definition at line 71 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "next" << endreq;
    return this->next(c,1);
}
StatusCode RootIOEvtSelector::next ( IEvtSelector::Context &  c,
int  jump 
) const [virtual]

Same of next(const Context&) plus the possibility to jump the next n-1 events.

Parameters:
cReference to the Context object.
jumpThe event to jump to from the current event.

Definition at line 78 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "next(" << jump << ")" << endreq;
    RootIOEvtSelector::Context* rc = 
        dynamic_cast<RootIOEvtSelector::Context*>(&c);
    if (!rc) return StatusCode::FAILURE;
    return this->setEntry(*rc,rc->m_entry+jump);
}
StatusCode RootIOEvtSelector::previous ( IEvtSelector::Context &  c) const [virtual]

Fetch the previous event.

It will return StatusCode::FAILURE if there have been problem in the fetching or it has been reached the begin of the list of events.

Parameters:
cReference to the Context object.

Definition at line 88 of file RootIOEvtSelector.cc.

{
    return this->previous(c,1);
}
StatusCode RootIOEvtSelector::previous ( IEvtSelector::Context &  c,
int  jump 
) const [virtual]

Same of previous(Context& c) the possibility to jump the previous n-1 events.

Parameters:
cReference to the Context object.
jumpThe event to jump to from the current event.

Definition at line 93 of file RootIOEvtSelector.cc.

{
    RootIOEvtSelector::Context* rc = 
        dynamic_cast<RootIOEvtSelector::Context*>(&c);
    if (!rc) return StatusCode::FAILURE;
    rc->m_entry -= jump;
    return this->setEntry(*rc,rc->m_entry-jump);
}
StatusCode RootIOEvtSelector::last ( IEvtSelector::Context &  refContext) const [virtual]

Access last item in the iteration.

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

Definition at line 102 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::ERROR << "last() not currently supported" << endreq;
    return StatusCode::FAILURE;
}
StatusCode RootIOEvtSelector::rewind ( IEvtSelector::Context &  c) const [virtual]

Will set the state of the context in a way that the next event read is the first of the list.

Parameters:
cReference to the Context object.

Definition at line 109 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::ERROR << "rewind() not currently supported" << endreq;
    return StatusCode::FAILURE;
}
StatusCode RootIOEvtSelector::createAddress ( const IEvtSelector::Context &  c,
IOpaqueAddress *&  iop 
) const [virtual]

Create an IOpaqueAddress object from the event fetched.

Parameters:
cReference to the Context object.
iopRefernce pointer to a IOpaqueAddress object

Definition at line 142 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::DEBUG << "createAddress" << endreq;
    const RootIOEvtSelector::Context* rc = 
        dynamic_cast<const RootIOEvtSelector::Context*>(&c);
    if (!rc) {
        log << MSG::ERROR << "Failed to get RootIOEvtSelector::Context" << endreq;
        return StatusCode::FAILURE;
    }

    RootInputAddress* ria = 
        new RootInputAddress(DataObject::classID(),"/Event");
    ria->setEntry(rc->m_entry);
    iop = ria;
    log << MSG::DEBUG << "createAddress for /Event" << endreq;
    return StatusCode::SUCCESS;
}
StatusCode RootIOEvtSelector::releaseContext ( IEvtSelector::Context *&  c) const [virtual]

Release the Context object.

Parameters:
cReference pointer to the Context object.

Definition at line 162 of file RootIOEvtSelector.cc.

{
    RootIOEvtSelector::Context* rc = 
        dynamic_cast<RootIOEvtSelector::Context*>(c);
    if (!rc) return StatusCode::FAILURE;

    delete rc;
    c = 0;
    return StatusCode::SUCCESS;
}
StatusCode RootIOEvtSelector::resetCriteria ( const std::string &  cr,
IEvtSelector::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:
crThe new criteria string.
cReference pointer to the Context object.

Definition at line 174 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");
    log << MSG::INFO << "resetCriteria(" << cr << ")" << endreq;

    RootIOEvtSelector::Context* rc = 
        dynamic_cast<RootIOEvtSelector::Context*>(&c);
    if (!rc) return StatusCode::FAILURE;

    // what to do here???

    return StatusCode::SUCCESS;
}
StatusCode RootIOEvtSelector::queryInterface ( const InterfaceID &  riid,
void **  ppif 
)

Definition at line 189 of file RootIOEvtSelector.cc.

{
    MsgStream log(msgSvc(), "RootIOEvtSelector");

    if (riid == IID_IEvtSelector) {
        *ppif = (IEvtSelector*)this;
        addRef();
        log << MSG::DEBUG << "queryInterface(IID_IEvtSelector)" << endreq;
        return StatusCode::SUCCESS;
    }
    log << MSG::DEBUG << "queryInterface(" << riid << ")" << endreq;
    return Service::queryInterface(riid,ppif);
}

Member Data Documentation

Definition at line 25 of file RootIOEvtSelector.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:58:18 for RootIOSvc by doxygen 1.7.4