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

In This Package:

Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
StageDataManager Class Reference

Manage data produced and consumed by stages. More...

#include <StageDataManager.h>

Inheritance diagram for StageDataManager:
Inheritance graph
[legend]
Collaboration diagram for StageDataManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 StageDataManager (const std::string &name, ISvcLocator *svc)
virtual ~StageDataManager ()
virtual StatusCode initialize ()
 Service interface:
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppint)
StatusCode registerData (const std::string &location, IStageData &sd)
 IStageDataManager interface.
StatusCode consumeData (IStageData &sd)
 Stage notifies the manager when data is consumed.

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Types

typedef std::map< std::string,
IStageDataList
LocDataListMap

Private Member Functions

void find_and_flush (const DayaBay::HeaderObject *ho)

Private Attributes

LocDataListMap m_cache
IDataProviderSvc * m_evtsvc

Detailed Description

Manage data produced and consumed by stages.

Brett Viren <bv@bnl.gov> Thu Mar 24 09:43:52 2011

Definition at line 25 of file StageDataManager.h.


Member Typedef Documentation

typedef std::map<std::string, IStageDataList> StageDataManager::LocDataListMap [private]

Definition at line 52 of file StageDataManager.h.


Constructor & Destructor Documentation

StageDataManager::StageDataManager ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 13 of file StageDataManager.cc.

    : Service(name,svc)
{
}
StageDataManager::~StageDataManager ( ) [virtual]

Definition at line 18 of file StageDataManager.cc.

{
}

Member Function Documentation

StatusCode StageDataManager::initialize ( ) [virtual]

Service interface:

Definition at line 23 of file StageDataManager.cc.

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

    sc = this->service("EventDataSvc",m_evtsvc);
    if (sc.isFailure()) return sc;

    MsgStream log(msgSvc(), "StageDataManager");
    log << MSG::DEBUG << "Initialized" << endreq;

    return sc;
}
StatusCode StageDataManager::finalize ( ) [virtual]

Definition at line 37 of file StageDataManager.cc.

{
    MsgStream log(msgSvc(), "StageDataManager");
    log << MSG::DEBUG << "Finalizing" << endreq;

    return this->Service::finalize();
}
StatusCode StageDataManager::queryInterface ( const InterfaceID &  riid,
void **  ppint 
) [virtual]

Definition at line 45 of file StageDataManager.cc.

{
    if (IID_IStageDataManager.versionMatch(riid)) {
        *ppint = (IStageDataManager*)this;
    }
    else {
        return this->Service::queryInterface(riid,ppint);
    }
    addRef();
    return StatusCode::SUCCESS;
}
StatusCode StageDataManager::registerData ( const std::string &  location,
IStageData sd 
) [virtual]

IStageDataManager interface.

StageProcess calls this to register data to be at a given location.

Implements IStageDataManager.

Definition at line 57 of file StageDataManager.cc.

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

    HeaderObject& ho = sd.header();

    log << MSG::DEBUG << "Registering data at " << location 
        << " id#" << ho.clID() << " @ " << ho.context().AsString()
        << endreq;

    HeaderStageData<HeaderObject>* hsd = new HeaderStageData<HeaderObject>(ho);
    ho.addRef();
    m_cache[location].insert(IStageDataListPair(hsd->time(),hsd));
    return StatusCode::SUCCESS;
}
StatusCode StageDataManager::consumeData ( IStageData sd) [virtual]

Stage notifies the manager when data is consumed.

Implements IStageDataManager.

Definition at line 170 of file StageDataManager.cc.

{
    MsgStream log(msgSvc(), "StageDataManager");
    log << MSG::DEBUG << "consumeData()" << endreq;

    // need to:
    // 
    // 3. add sd->header() to TES, if not yet already added
    // 
    // 2. add all input headers to TES, inyaa
    // 
    // 1. add all cached headers to TES, inyaa and if earlier than any
    // in the category above on a per-location basis

    const HeaderObject& ho = sd.header();

    if (1) {                    // some debugging
        log << MSG::DEBUG << "Consuming with " << m_cache.size() << " locations cached"
            << endreq;
        LocDataListMap::iterator it, done = m_cache.end();
        for (it = m_cache.begin(); it != done; ++it) {
            IStageDataList& sdlist = it->second;
            log << MSG::DEBUG << "\t" << it->first 
                << " with " << sdlist.size()
                << ":" << endreq;
            IStageDataList::iterator lit, ldone = sdlist.end();
            for (lit = sdlist.begin(); lit != ldone; ++lit) {
                HeaderObject& ho = lit->second->header();
                log << MSG::DEBUG << "\t\t id#"
                    << ho.clID() << " at \""
                    << ho.defLoc() << "\" @ " 
                    << ho.context().AsString()
                    << endreq;
            }
        }
    }
    vector<const HeaderObject*> hos;
    bool ok = find_hos(&ho,hos);
    if (!ok) {
        log << MSG::ERROR << "Got IHeader that isn't a HeaderObject! WTF?" << endreq;
        return StatusCode::FAILURE;        
    }

    size_t nhos = hos.size();

    log << MSG::DEBUG << "Consuming id#" << ho.clID() 
        << " \"" << ho.defLoc() << "\" @ " 
        << ho.context().AsString()
        << " along with " << nhos << " other HeaderObjects" << endreq;

    for (size_t ind=0; ind<nhos; ++ind) {
        log << MSG::DEBUG << "\t" << ind << ": id#" << hos[ind]->clID() 
            << " \"" << hos[ind]->defLoc() << "\" @ " 
            << hos[ind]->context().AsString() << endreq;
        this->find_and_flush(hos[ind]);
    }

    return StatusCode::SUCCESS;
}
void StageDataManager::find_and_flush ( const DayaBay::HeaderObject ho) [private]

Definition at line 128 of file StageDataManager.cc.

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

    LocDataListMap::iterator it, done = m_cache.end();
    for (it = m_cache.begin(); it != done; ++it) {
        
        const string& loc = it->first;
        IStageDataList& sdlist = it->second;

        IStageDataList::iterator sdit = find_ho(sdlist,ho);
        if (sdit == sdlist.end()) continue;

        ++sdit;                 // always up-to-but-not-including
        size_t before = sdlist.size();
        vector<const HeaderObject*> dead_hos = strip_sdlist(sdlist, sdit);
        size_t after = sdlist.size();

        size_t siz = dead_hos.size();
        log << MSG::DEBUG << "Loading " << siz << " HeaderObjects into TES, stripped from "
            << before << " to " << after
            << endreq;

        for (size_t ind=0; ind<siz; ++ind) {
            // gotta break const'ness here because the TES must call
            // addRef/release.  This const-incorectness is ultimately
            // because HeaderObject::inputHeaders() forces constness
            // on us, even thought the original HO isn't const.  This
            // is probably a deficiency of HeaderObject.
            HeaderObject* malleable_ho = const_cast<HeaderObject*>(dead_hos[ind]);
            m_evtsvc->registerObject(loc,malleable_ho);

            log << MSG::DEBUG << "Releasing HeaderObject clID: " << malleable_ho->clID() << endreq;
            malleable_ho->release();
        }

        // in principle, we could bail from the function at this point
        // as no one would ever think to put a HO in more than one
        // spot.  But, lets be paranoid and keep checking.
    }
}
static const InterfaceID& IStageDataManager::interfaceID ( ) [inline, static, inherited]

Definition at line 28 of file IStageDataManager.h.


Member Data Documentation

Definition at line 53 of file StageDataManager.h.

IDataProviderSvc* StageDataManager::m_evtsvc [private]

Definition at line 55 of file StageDataManager.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 10:07:33 for Stage by doxygen 1.7.4