Gaudi Framework, version v21r7

Home   Generated: 22 Jan 2010

InputCopyStream.cpp

Go to the documentation of this file.
00001 // $Id: InputCopyStream.cpp,v 1.2 2006/01/10 20:09:27 hmd Exp $
00002 #define GAUDISVC_PERSISTENCYSVC_INPUTCOPYSTREAM_CPP
00003 
00004 // Framework include files
00005 #include "GaudiKernel/AlgFactory.h"
00006 #include "GaudiKernel/IRegistry.h"
00007 #include "GaudiKernel/IDataManagerSvc.h"
00008 #include "GaudiKernel/IDataProviderSvc.h"
00009 #include "GaudiKernel/IOpaqueAddress.h"
00010 #include "GaudiKernel/DataStoreItem.h"
00011 #include "GaudiKernel/DataObject.h"
00012 #include "GaudiKernel/MsgStream.h"
00013 #include "OutputStreamAgent.h"
00014 #include "InputCopyStream.h"
00015 
00016 // Define the algorithm factory for the standard output data writer
00017 DECLARE_ALGORITHM_FACTORY(InputCopyStream)
00018 
00019 // Standard Constructor
00020 InputCopyStream::InputCopyStream(const std::string& name, ISvcLocator* pSvcLocator)
00021  : OutputStream(name, pSvcLocator)
00022 {
00023   m_doPreLoad      = false;
00024   m_doPreLoadOpt   = false;
00025   m_itemNames.push_back("/Event#99999");
00026   declareProperty("TakeOptionalFromTES", m_takeOptionalFromTES = false, 
00027                   "Allow optional items to be on TES instead of input file") ;
00028 }
00029 
00030 // Standard Destructor
00031 InputCopyStream::~InputCopyStream()   {
00032 }
00033 
00034 // Place holder to create configurable data store agent
00035 StatusCode InputCopyStream::collectLeaves(IRegistry* dir, int level)    {
00036   MsgStream log(msgSvc(), name());
00037   if ( level < m_currentItem->depth() )   {
00038     if ( dir )  {
00039       // dir->object != 0, because was retrived in previous recursion
00040       m_objects.push_back(dir->object());
00041       if ( dir->address() )  {
00042         std::vector<IRegistry*> lfs;
00043         const std::string& dbase = dir->address()->par()[0];
00044         // Cololect all pending leaves
00045         StatusCode iret, sc = m_pDataManager->objectLeaves(dir,lfs);
00046         if ( sc.isSuccess() )  {
00047           std::vector<IRegistry*>::iterator i=lfs.begin();
00048           for(; i!=lfs.end(); ++i)  {
00049             // Continue if the leaf has the same database as the parent
00050             if ( (*i)->address() && (*i)->address()->par()[0] == dbase )  {
00051               DataObject* obj = 0;
00052               iret = m_pDataProvider->retrieveObject(dir, (*i)->name(), obj);
00053               if (  iret.isSuccess() )  {
00054                 log << MSG::VERBOSE << "::collectLeaves Success retrieving " << (*i)->name() << endmsg ;
00055                 iret = collectLeaves(*i, level+1);
00056               }
00057               if ( !iret.isSuccess() )  {
00058                 log << MSG::VERBOSE << "::collectLeaves Failure retrieving " << (*i)->name() << endmsg ;
00059                 sc = iret;
00060               }
00061             }
00062           }
00063         }
00064         return sc;
00065       }
00066     }
00067     return StatusCode::FAILURE;
00068   }
00069   return StatusCode::SUCCESS;
00070 }
00071 
00073 StatusCode InputCopyStream::collectObjects()   {
00074   MsgStream log(msgSvc(), name());
00075   StatusCode status = StatusCode::SUCCESS;
00076   Items::iterator i;
00077   // Traverse the tree and collect the requested objects
00078   for ( i = m_itemList.begin(); i != m_itemList.end(); i++ )    {
00079     DataObject* obj = 0;
00080     m_currentItem = (*i);
00081     log << MSG::VERBOSE << "::collectObjects Looping over mandatory " << m_currentItem->path() << endmsg ;
00082     StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
00083     if ( iret.isSuccess() )  {
00084       log << MSG::VERBOSE << "::collectObjects Success retrieving mandatory " << (*i)->path() << endmsg ;
00085       iret = collectLeaves(obj->registry(), 0);
00086     }
00087     if ( !iret.isSuccess() )  {
00088       log << MSG::ERROR << "Cannot write mandatory object(s) (Not found) "
00089           << m_currentItem->path() << endmsg;
00090       status = iret;
00091     }
00092   }
00093   // Traverse the tree and collect the requested objects (tolerate missing itmes here)
00094   for ( i = m_optItemList.begin(); i != m_optItemList.end(); i++ )    {
00095     DataObject* obj = 0;
00096     m_currentItem = (*i);
00097     StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
00098     if ( iret.isSuccess() )  {
00099       log << MSG::VERBOSE << "::collectObjects Success retrieving optional " << (*i)->path() << endmsg ;
00100       if ( m_takeOptionalFromTES ){ // look into TES
00101         iret = m_pDataManager->traverseSubTree(obj, m_agent);      
00102       } else { // look only at DST
00103         iret = collectLeaves(obj->registry(), 0);
00104       }
00105     }
00106     if ( !iret.isSuccess() )    {
00107       log << MSG::DEBUG << "Ignore request to write non-mandatory object(s) "
00108           << m_currentItem->path() << endmsg;
00109     }
00110   }
00111   return status;
00112 }

Generated at Fri Jan 22 20:28:09 2010 for Gaudi Framework, version v21r7 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004