The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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\***********************************************************************************/
12
17#include <RootCnv/RootAddress.h>
18
19#include <fstream>
20#include <memory>
21
22#include "MIHelpers.h"
23
24namespace Gaudi {
25 namespace TestSuite {
26 namespace MultiInput {
27
29 class DumpAddress : public ::Algorithm {
30 public:
32
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;
51 }
52 } else {
53 log << MSG::ERROR << "No data at " << m_path.value() << endmsg;
55 }
56 ++m_count;
58 }
59
60 StatusCode finalize() override {
61 m_outputFile.close();
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" };
68 std::ofstream m_outputFile;
69 long m_count = 0;
70 };
72 } // namespace MultiInput
73 } // namespace TestSuite
74} // namespace Gaudi
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
SmartIF< IDataProviderSvc > & eventSvc() const
The standard event data service.
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition Algorithm.h:175
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition Algorithm.h:181
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Description:
Definition RootAddress.h:45
Write the content of the RootAddress of a data object.
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
Gaudi::Property< std::string > m_output
Gaudi::Property< std::string > m_path
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29
A small class used to access easily (and efficiently) data items residing in data stores.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
@ ERROR
Definition IMessageSvc.h:22