The Gaudi Framework  v33r0 (d5ea422b)
InputCopyStream.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 // Framework include files
12 #include "InputCopyStream.h"
13 #include "GaudiKernel/DataObject.h"
19 #include "GaudiKernel/IRegistry.h"
20 #include "GaudiKernel/MsgStream.h"
21 
22 // Define the algorithm factory for the standard output data writer
24 
25 // Standard Constructor
26 InputCopyStream::InputCopyStream( const std::string& name, ISvcLocator* pSvcLocator )
27  : OutputStream( name, pSvcLocator ) {
28  m_doPreLoad = false;
29  m_doPreLoadOpt = false;
30 }
31 
32 // Initialize the instance.
35  if ( sc.isFailure() ) return sc;
36 
37  sc = toolSvc()->retrieveTool( "DataSvcFileEntriesTool", "InputCopyStreamTool", m_leavesTool );
38  return sc;
39 }
40 
41 // Finalize the instance.
44  m_leavesTool = nullptr;
45  return OutputStream::finalize();
46 }
47 
50  // Get the objects in the same file as the root node
51  try {
52  // Get all the leaves on the input stream
54 
55  // Do we need to veto anything ?
56  if ( UNLIKELY( !m_tesVetoList.empty() ) ) {
57  // Veto out locations
58  IDataStoreLeaves::LeavesList filteredLeaves;
59  filteredLeaves.reserve( leaves.size() );
60  std::copy_if( leaves.begin(), leaves.end(), std::back_inserter( filteredLeaves ),
61  [&]( IDataStoreLeaves::LeavesList::const_reference i ) {
62  return i && i->registry() &&
63  std::find( m_tesVetoList.begin(), m_tesVetoList.end(), i->registry()->identifier() ) ==
64  m_tesVetoList.end();
65  } );
66  // save the veto'ed list
67  m_objects.assign( filteredLeaves.begin(), filteredLeaves.end() );
68 
69  } else {
70  // no veto'ing, so save everything
71  m_objects.assign( leaves.begin(), leaves.end() );
72  }
73  } catch ( const GaudiException& e ) {
74  error() << e.message() << endmsg;
75  return StatusCode::FAILURE;
76  }
77 
78  // Collect the other objects from the transient store (mandatory and optional)
80 }
#define UNLIKELY(x)
Definition: Kernel.h:106
Extension of OutputStream to copy the content of the main input file.
T copy_if(T... args)
StatusCode initialize() override
Initialize the instance.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
IDataSelector m_objects
Collection of objects being selected.
Definition: OutputStream.h:115
StatusCode finalize() override
Terminate OutputStream.
virtual const std::string & message() const
error message to be printed
STL namespace.
SmartIF< IToolSvc > & toolSvc() const
The standard ToolSvc service, Return a pointer to the service if present.
Definition: Algorithm.cpp:594
T end(T... args)
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned.
Definition: IToolSvc.h:148
A small to stream Data I/O.
Definition: OutputStream.h:38
#define DECLARE_COMPONENT(type)
StatusCode initialize() override
Initialize OutputStream.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
IDataStoreLeaves * m_leavesTool
Pointer to the (public) tool used to retrieve the objects in a file.
Gaudi::Property< std::vector< std::string > > m_tesVetoList
T find(T... args)
T size(T... args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
T assign(T... args)
virtual const LeavesList & leaves() const =0
Return the list of leaves.
T begin(T... args)
T back_inserter(T... args)
StatusCode finalize() override
Finalize the instance.
constexpr static const auto FAILURE
Definition: StatusCode.h:97
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
bool isFailure() const
Definition: StatusCode.h:141
StatusCode collectObjects() override
Collect all objects to be written to the output stream.
virtual StatusCode collectObjects()
Collect all objects to be written to the output stream.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
T reserve(T... args)