The Gaudi Framework  master (37c0b60a)
DumpAddress.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #include <GaudiKernel/Algorithm.h>
12 
13 #include <GaudiKernel/DataObject.h>
15 #include <GaudiKernel/IRegistry.h>
17 #include <RootCnv/RootAddress.h>
18 
19 #include <fstream>
20 #include <memory>
21 
22 #include "MIHelpers.h"
23 
24 namespace Gaudi {
25  namespace TestSuite {
26  namespace MultiInput {
27 
29  class DumpAddress : public ::Algorithm {
30  public:
32 
33  StatusCode initialize() override {
35  if ( sc.isFailure() ) return sc;
36  m_outputFile.open( m_output.value().c_str() );
37  m_count = 0;
38  return sc;
39  }
40 
41  StatusCode execute() override {
42  MsgStream log( msgSvc() );
44  if ( obj ) {
45  Gaudi::RootAddress* addr = dynamic_cast<Gaudi::RootAddress*>( obj->registry()->address() );
46  if ( addr ) {
47  m_outputFile << *addr << std::endl;
48  } else {
49  log << MSG::ERROR << "Event " << m_count << " does not have a Gaudi::RootAddress" << endmsg;
50  return StatusCode::FAILURE;
51  }
52  } else {
53  log << MSG::ERROR << "No data at " << m_path.value() << endmsg;
54  return StatusCode::FAILURE;
55  }
56  ++m_count;
57  return StatusCode::SUCCESS;
58  }
59 
60  StatusCode finalize() override {
62  return Algorithm::finalize();
63  }
64 
65  private:
66  Gaudi::Property<std::string> m_output{ this, "OutputFile", {}, "Name of the output file" };
67  Gaudi::Property<std::string> m_path{ this, "ObjectPath", {}, "Path to the object in the transient store" };
69  long m_count = 0;
70  };
72  } // namespace MultiInput
73  } // namespace TestSuite
74 } // namespace Gaudi
MIHelpers.h
Gaudi.Configuration.log
log
Definition: Configuration.py:28
Gaudi::TestSuite::MultiInput::DumpAddress::initialize
StatusCode initialize() override
Definition: DumpAddress.cpp:33
Gaudi::Algorithm::eventSvc
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Definition: Algorithm.cpp:559
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:658
Gaudi::TestSuite::MultiInput::DumpAddress::finalize
StatusCode finalize() override
Definition: DumpAddress.cpp:60
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
Algorithm.h
Gaudi::TestSuite::MultiInput::DumpAddress::m_outputFile
std::ofstream m_outputFile
Definition: DumpAddress.cpp:68
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
Gaudi::TestSuite::MultiInput::DumpAddress::m_count
long m_count
Definition: DumpAddress.cpp:69
StatusCode
Definition: StatusCode.h:65
std::ofstream
STL class.
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
SmartDataPtr.h
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
Gaudi::TestSuite::MultiInput::DumpAddress::m_output
Gaudi::Property< std::string > m_output
Definition: DumpAddress.cpp:66
std::ofstream::close
T close(T... args)
std::ofstream::open
T open(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
IRegistry.h
MsgStream
Definition: MsgStream.h:33
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::TestSuite::MultiInput::DumpAddress::m_path
Gaudi::Property< std::string > m_path
Definition: DumpAddress.cpp:67
Gaudi::TestSuite::MultiInput::DumpAddress::execute
StatusCode execute() override
Definition: DumpAddress.cpp:41
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition: Algorithm.h:184
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
DataObject.h
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
Gaudi::TestSuite::MultiInput::DumpAddress
Write the content of the RootAddress of a data object.
Definition: DumpAddress.cpp:29
RootAddress.h
Gaudi::Algorithm::Algorithm
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition: Algorithm.h:101
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
Gaudi::Property< std::string >
IDataManagerSvc.h
Gaudi::RootAddress
Definition: RootAddress.h:46