| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- File List
- File Members

# 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 "InputCopyStream.h"
    00014
    00015 // Define the algorithm factory for the standard output data writer
    00016 DECLARE_ALGORITHM_FACTORY(InputCopyStream)
    00017
    00018 // Standard Constructor
    00019 InputCopyStream::InputCopyStream(const std::string& name, ISvcLocator* pSvcLocator)
    00020  : OutputStream(name, pSvcLocator)
    00021 {
    00022   m_doPreLoad      = false;
    00023   m_doPreLoadOpt   = false;
    00024   m_itemNames.push_back("/Event#99999");
    00025 }
    00026
    00027 // Standard Destructor
    00028 InputCopyStream::~InputCopyStream()   {
    00029 }
    00030
    00031 // Place holder to create configurable data store agent
    00032 StatusCode InputCopyStream::collectLeaves(IRegistry* dir, int level)    {
    00033   if ( level < m_currentItem->depth() )   {
    00034     if ( dir )  {
    00035       // dir->object != 0, because was retrived in previous recursion
    00036       m_objects.push_back(dir->object());
    00037       if ( dir->address() )  {
    00038         std::vector<IRegistry*> lfs;
    00039         const std::string& dbase = dir->address()->par()[0];
    00040         // Cololect all pending leaves
    00041         StatusCode iret, sc = m_pDataManager->objectLeaves(dir,lfs);
    00042         if ( sc.isSuccess() )  {
    00043           std::vector<IRegistry*>::iterator i=lfs.begin();
    00044           for(; i!=lfs.end(); ++i)  {
    00045             // Continue if the leaf has the same database as the parent
    00046             if ( (*i)->address() && (*i)->address()->par()[0] == dbase )  {
    00047               DataObject* obj = 0;
    00048               iret = m_pDataProvider->retrieveObject(dir, (*i)->name(), obj);
    00049               if (  iret.isSuccess() )  {
    00050                 iret = collectLeaves(*i, level+1);
    00051               }
    00052               if ( !iret.isSuccess() )  {
    00053                 sc = iret;
    00054               }
    00055             }
    00056           }
    00057         }
    00058         return sc;
    00059       }
    00060     }
    00061     return StatusCode::FAILURE;
    00062   }
    00063   return StatusCode::SUCCESS;
    00064 }
    00065
    00067 StatusCode InputCopyStream::collectObjects()   {
    00068   MsgStream log(msgSvc(), name());
    00069   StatusCode status = StatusCode::SUCCESS;
    00070   Items::iterator i;
    00071   // Traverse the tree and collect the requested objects
    00072   for ( i = m_itemList.begin(); i != m_itemList.end(); i++ )    {
    00073     DataObject* obj = 0;
    00074     m_currentItem = (*i);
    00075     StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
    00076     if ( iret.isSuccess() )  {
    00077       iret = collectLeaves(obj->registry(), 0);
    00078     }
    00079     if ( !iret.isSuccess() )  {
    00080       log << MSG::ERROR << "Cannot write mandatory object(s) (Not found) "
    00081           << m_currentItem->path() << endmsg;
    00082       status = iret;
    00083     }
    00084   }
    00085   // Traverse the tree and collect the requested objects (tolerate missing itmes here)
    00086   for ( i = m_optItemList.begin(); i != m_optItemList.end(); i++ )    {
    00087     DataObject* obj = 0;
    00088     m_currentItem = (*i);
    00089     StatusCode iret = m_pDataProvider->retrieveObject(m_currentItem->path(), obj);
    00090     if ( iret.isSuccess() )  {
    00091       iret = collectLeaves(obj->registry(), 0);
    00092     }
    00093     if ( !iret.isSuccess() )    {
    00094       log << MSG::DEBUG << "Ignore request to write non-mandatory object(s) "
    00095           << m_currentItem->path() << endmsg;
    00096     }
    00097   }
    00098   return status;
    00099 }