The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
IBinder.h
Go to the documentation of this file.
1/*****************************************************************************\
2* (c) Copyright 2021-2025 CERN for the benefit of the LHCb Collaboration *
3* *
4* This software is distributed under the terms of the GNU General Public *
5* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
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#pragma once
14#include <type_traits>
15#include <utility>
16
17class EventContext;
18
20
21 template <typename IFace>
22 class Box final {
23 const IFace* m_ptr = nullptr;
24 bool m_owned = false;
25
26 public:
27 // identity binding: no actual binding is required...
28 Box( IFace const* ptr ) : m_ptr{ ptr } { assert( m_ptr != nullptr ); }
29 // bind the arguments...
30 template <std::derived_from<IFace> Ret, typename... Args>
31 Box( std::in_place_type_t<Ret>, Args&&... args )
32 : m_ptr{ new Ret{ std::forward<Args>( args )... } }, m_owned{ true } {}
33
34 ~Box() {
35 if ( m_owned ) delete m_ptr;
36 }
37 Box( const Box& ) = delete;
38 Box& operator=( const Box& ) = delete;
39 Box( Box&& rhs ) = delete;
40 Box& operator=( Box&& ) = delete;
41
42 operator IFace const&() const { return *m_ptr; }
43 // operator IFace&() && = delete;
44 };
45
46 template <typename IFace>
47 struct IBinder : extend_interfaces<IAlgTool> {
49 virtual Box<IFace> bind( const EventContext& ctx ) const = 0;
50 };
51
52 template <typename IFace>
53 struct AlgToolStub : IFace {
54
55 using IFace::IFace;
56 AlgToolStub( const AlgToolStub& ) = delete;
57 AlgToolStub& operator=( const AlgToolStub& ) = delete;
58 AlgToolStub( AlgToolStub&& ) = delete;
60
61 const std::string& name() const override {
62 static std::string s{ "<STUB>" };
63 return s;
64 }
65 const std::string& type() const override { return name(); }
66 const IInterface* parent() const override { return nullptr; }
67
70 StatusCode start() override { return StatusCode::FAILURE; }
71 StatusCode stop() override { return StatusCode::FAILURE; }
75 StatusCode restart() override { return StatusCode::FAILURE; }
79 StatusCode sysStop() override { return StatusCode::FAILURE; }
83 };
84
85 template <typename IFace>
86 struct Stub : implements<AlgToolStub<IFace>> {};
87
88} // namespace Gaudi::Interface::Bind
This class represents an entry point to all the event specific data.
Box & operator=(const Box &)=delete
Box(std::in_place_type_t< Ret >, Args &&... args)
Definition IBinder.h:31
Box & operator=(Box &&)=delete
Box(IFace const *ptr)
Definition IBinder.h:28
Box(const Box &)=delete
Definition of the basic interface.
Definition IInterface.h:225
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto FAILURE
Definition StatusCode.h:100
State
Allowed states for classes implementing the state machine (ApplicationMgr, Algorithm,...
STL namespace.
StatusCode terminate() override
Definition IBinder.h:73
AlgToolStub & operator=(AlgToolStub &&)=delete
const std::string & type() const override
Definition IBinder.h:65
StatusCode initialize() override
Definition IBinder.h:69
const std::string & name() const override
Definition IBinder.h:61
AlgToolStub(AlgToolStub &&)=delete
StatusCode finalize() override
Definition IBinder.h:72
StatusCode sysReinitialize() override
Definition IBinder.h:81
StatusCode sysStart() override
Definition IBinder.h:78
StatusCode sysFinalize() override
Definition IBinder.h:80
AlgToolStub & operator=(const AlgToolStub &)=delete
StatusCode restart() override
Definition IBinder.h:75
StatusCode stop() override
Definition IBinder.h:71
Gaudi::StateMachine::State FSMState() const override
Definition IBinder.h:76
StatusCode sysStop() override
Definition IBinder.h:79
StatusCode sysRestart() override
Definition IBinder.h:82
AlgToolStub(const AlgToolStub &)=delete
StatusCode configure() override
Definition IBinder.h:68
StatusCode sysInitialize() override
Definition IBinder.h:77
StatusCode reinitialize() override
Definition IBinder.h:74
const IInterface * parent() const override
Definition IBinder.h:66
StatusCode start() override
Definition IBinder.h:70
virtual Box< IFace > bind(const EventContext &ctx) const =0
Base class to be used to extend an interface.