File Delegate.hpp¶
-
namespace Acts
Set the Geometry Context PLUGIN.
Set the Calibration Context PLUGIN.
Convenience functions to ease creation of and Acts::InterpolatedMaterialMap and to avoid code duplication.
Set the Mangetic Field Context PLUGIN.
Convenience functions to ease creation of and Acts::InterpolatedBFieldMap and to avoid code duplication.
Currently implemented for the two most common formats: rz and xyz.
-
template<typename>
class Delegate - #include <Acts/Utilities/Delegate.hpp>
-
template<typename R, typename ...Args>
class Delegate<R(Args...)> - #include <Acts/Utilities/Delegate.hpp>
Delegate type that allows type erasure of a callable without allocation and with a single level of indirection.
This type can support:
a free function pointer
a pointer to a member function alongside an instance pointer
Note
Delegate
does not assume ownership of the instance. You need to ensure that the lifetime of the callable instance is longer than that of theDelegate
.Note
Currently
Delegate
only supports callables that areconst
- tparam R
Return type of the function signature
- tparam Args
Types of the arguments of the function signatures
Public Functions
-
Delegate() = default
-
inline Delegate(function_type callable)
Constructor with an explicit runtime callable.
Note
The function signature requires the first argument of the callable is
const void*
. i.e. if the signature of the delegate isvoid(int)
, the callable’s signature has to bevoid(const void*, int)
.- Parameters
callable – The runtime value of the callable
-
template<auto Callable>
inline void connect() Connect a free function pointer.
Note
The function pointer must be
constexpr
forDelegate
to accept it- Template Parameters
Callable – The compile-time free function pointer
-
inline void connect(function_type callable)
Connect anything that is assignable to the function pointer.
Note
The function signature requires the first argument of the callable is
const void*
. i.e. if the signature of the delegate isvoid(int)
, the callable’s signature has to bevoid(const void*, int)
.- Parameters
callable – The runtime value of the callable
-
template<auto Callable, typename Type>
inline void connect(const Type *instance) Connect a member function to be called on an instance.
Note
Delegate
does not assume owner ship overinstance
. You need to ensure it’s lifetime is longer than that ofDelegate
.- Template Parameters
Callable – The compile-time member function pointer
Type – The type of the instance the member function should be called on
- Parameters
instance – The instance on which the member function pointer should be called on
-
inline bool connected() const
Return whether this delegate is currently connected.
- Returns
True if this delegate is connected
-
inline void disconnect()
Disconnect this delegate, meaning it cannot be called anymore.
-
inline operator bool() const
Return whether this delegate is currently connected.
- Returns
True if this delegate is connected
-
inline return_type operator()(Args... args) const
The call operator that exposes the functionality of the
Delegate
type.- Parameters
args – The arguments to call the contained function with
- Returns
Return value of the contained function
-
inline void operator=(function_type callable)
Assignment operator with an explicit runtime callable.
Note
The function signature requires the first argument of the callable is
const void*
. i.e. if the signature of the delegate isvoid(int)
, the callable’s signature has to bevoid(const void*, int)
.- Parameters
callable – The runtime value of the callable
Private Types
-
using function_type = return_type (*)(const void*, Args...)¶
Alias to the function pointer type this class will store.
Private Members
-
function_type m_function = {nullptr}¶
Stores the function pointer wrapping the compile time function pointer given in
connect()
.
-
const void *m_payload = {nullptr}¶
Stores the instance pointer.
-
template<typename>