| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

# EvtCollectionStream.cpp

Go to the documentation of this file.

    00001 //      ====================================================================
    00002 //  EvtCollectionStream.cpp
    00003 //      --------------------------------------------------------------------
    00004 //
    00005 //      Package   : GaudiSvc/PersistencySvc
    00006 //
    00007 //      Author    : Markus Frank
    00008 //
    00009 //      ====================================================================
    00010 #define GAUDISVC_PERSISTENCYSVC_EVTCOLLECTIONSTREAM_CPP
    00011
    00012 // Framework include files
    00013 #include "GaudiKernel/AlgFactory.h"
    00014 #include "GaudiKernel/MsgStream.h"
    00015 #include "GaudiKernel/INTupleSvc.h"
    00016 #include "GaudiKernel/IDataProviderSvc.h"
    00017
    00018 #include "GaudiKernel/DataStoreItem.h"
    00019 #include "EvtCollectionStream.h"
    00020
    00021 // Define the algorithm factory for the standard output data writer
    00022 DECLARE_ALGORITHM_FACTORY(EvtCollectionStream)
    00023
    00024 // Standard Constructor
    00025 EvtCollectionStream::EvtCollectionStream(const std::string& name, ISvcLocator* pSvcLocator)
    00026 : Algorithm(name, pSvcLocator)
    00027 {
    00028   m_storeName = "TagCollectionSvc";
    00029   declareProperty("ItemList",   m_itemNames);
    00030   declareProperty("EvtDataSvc", m_storeName);
    00031 }
    00032
    00033 // Standard Destructor
    00034 EvtCollectionStream::~EvtCollectionStream()   {
    00035 }
    00036
    00037 // initialize data writer
    00038 StatusCode EvtCollectionStream::initialize() {
    00039   MsgStream log(msgSvc(), name());
    00040   // Use the Job options service to set the Algorithm's parameters
    00041   setProperties();
    00042   // Get access to the DataManagerSvc
    00043   m_pTupleSvc = serviceLocator()->service(m_storeName);
    00044   if( !m_pTupleSvc.isValid() ) {
    00045     log << MSG::FATAL << "Unable to locate IDataManagerSvc interface" << endmsg;
    00046     return StatusCode::FAILURE;
    00047   }
    00048   // Clear the item list
    00049   clearItems();
    00050   // Take the new item list from the properties.
    00051   for(ItemNames::iterator i = m_itemNames.begin(); i != m_itemNames.end(); i++)   {
    00052     addItem( *i );
    00053   }
    00054   log << MSG::INFO << "Data source:             " << m_storeName  << endmsg;
    00055   return StatusCode::SUCCESS;
    00056 }
    00057
    00058 // terminate data writer
    00059 StatusCode EvtCollectionStream::finalize()    {
    00060   m_pTupleSvc = 0; // release
    00061   clearItems();
    00062   return StatusCode::SUCCESS;
    00063 }
    00064
    00065 // Work entry point
    00066 StatusCode EvtCollectionStream::execute() {
    00067   StatusCode status = (m_pTupleSvc) ? StatusCode::SUCCESS : StatusCode::FAILURE;
    00068   if ( status.isSuccess() )   {
    00069     for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ )    {
    00070       StatusCode iret = m_pTupleSvc->writeRecord((*i)->path());
    00071       if ( !iret.isSuccess() )    {
    00072         status = iret;
    00073       }
    00074     }
    00075   }
    00076   return status;
    00077 }
    00078
    00079 // Remove all items from the output streamer list;
    00080 void EvtCollectionStream::clearItems()     {
    00081   for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ )    {
    00082     delete (*i);
    00083   }
    00084   m_itemList.erase(m_itemList.begin(), m_itemList.end());
    00085 }
    00086
    00087 // Add item to output streamer list
    00088 void EvtCollectionStream::addItem(const std::string& descriptor)   {
    00089   MsgStream log(msgSvc(), name());
    00090   int sep = descriptor.rfind("#");
    00091   int level = 0;
    00092   std::string obj_path (descriptor,0,sep);
    00093   std::string slevel   (descriptor,sep+1,descriptor.length());
    00094   if ( slevel == "*" )  {
    00095     level = 9999999;
    00096   }
    00097   else   {
    00098     level = ::atoi(slevel.c_str());
    00099   }
    00100   DataStoreItem* item = new DataStoreItem(obj_path, level);
    00101   log << MSG::INFO << "Adding OutputStream item " << item->path()
    00102       << " with " << item->depth()
    00103       << " level(s)." << endmsg;
    00104   m_itemList.push_back( item );
    00105 }

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines