The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
User.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#include <Gaudi/Algorithm.h>
13
17 class UserAlg : public ConditionAccessorHolder<Algorithm> {
20
22 ConditionAccessor<int> m_cond{ this, "MyCondition", "condition/key" };
23
25 auto status = base_class::initialize();
26 if ( !status ) return status;
27
28 info() << "initialize" << endmsg;
29
30 return status;
31 }
32
33 StatusCode execute( const EventContext& ctx ) const override {
34 // get the condition slot for the current event
35 const auto& condCtx = getConditionContext( ctx );
36 // get the condition value from the current condition slot.
37 const auto& cond = m_cond.get( condCtx );
38
39 info() << "got condition value " << cond << endmsg;
40
42 }
43
44 StatusCode finalize() override {
45 info() << "finalize" << endmsg;
46
47 return base_class::finalize();
48 }
49 };
50 DECLARE_COMPONENT( UserAlg )
51} // namespace Gaudi::TestSuite::Conditions
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class represents an entry point to all the event specific data.
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition Algorithm.h:181
Example of a ConditionAccessorHolder implementation.
const ConditionContext & getConditionContext(const EventContext &ctx) const
Example of a simple algorithm using conditions via the ConditionAccessorHolder pattern.
Definition User.cpp:17
ConditionAccessor< int > m_cond
Data member to access condition values for the current event.
Definition User.cpp:22
StatusCode execute(const EventContext &ctx) const override
Definition User.cpp:33
StatusCode finalize() override
Definition User.cpp:44
StatusCode initialize() override
Definition User.cpp:24
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99