The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
UseSvcWithoutInterface.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 2025 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#include <GaudiKernel/Service.h>
14
15namespace Gaudi::TestSuite {
17 public:
18 using Service::Service;
19
21 return Service::initialize().andThen( [this] { info() << "initialized" << endmsg; } );
22 }
23
24 void doSomething() const { info() << "doing something" << endmsg; }
25 };
26 DECLARE_COMPONENT( SvcWithoutInterface )
27
28 class UseSvcWithoutInterface : public Gaudi::Functional::Consumer<void()> {
29 public:
30 UseSvcWithoutInterface( const std::string& name, ISvcLocator* svcLoc )
31 : Consumer( name, svcLoc ), m_svc( "Gaudi::TestSuite::SvcWithoutInterface/SvcWithoutInterface", name ) {}
34 .andThen( [this] { info() << "initializing..." << endmsg; } )
35 .andThen( [this] { m_svc->doSomething(); } )
36 .andThen( [this] { info() << "initialized" << endmsg; } );
37 }
38 void operator()() const override {}
39
40 private:
41 // Add your member variables here
43 };
45} // namespace Gaudi::TestSuite
#define class
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)
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition Algorithm.h:175
Service(std::string name, ISvcLocator *svcloc)
Standard Constructor.
Definition Service.cpp:340
UseSvcWithoutInterface(const std::string &name, ISvcLocator *svcLoc)
ServiceHandle< SvcWithoutInterface > m_svc
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Handle to be used in lieu of naked pointers to services.
StatusCode initialize() override
Definition Service.cpp:118
Service(std::string name, ISvcLocator *svcloc)
Standard Constructor.
Definition Service.cpp:340
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition StatusCode.h:163
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1