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
- Template Parameters
R – Return type of the function signature
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<typename Callable, typename = isNoFunPtr<Callable>>
inline Delegate(Callable &callable) Constructor with a possibly stateful function object.
Note
Delegate
does not assume owner ship overcallable
. You need to ensure it’s lifetime is longer than that ofDelegate
.- Template Parameters
Callable – Type of the callable
- Parameters
callable – The callable (function object or lambda)
-
template<typename Callable, typename = isNoFunPtr<Callable>>
Delegate(Callable&&) = delete Constructor from rvalue reference is deleted, should catch construction with temporary objects and thus invalid pointers.
-
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
-
template<typename Callable, typename = isNoFunPtr<Callable>>
inline void connect(Callable &callable) Assignment operator with possibly stateful function object.
Note
Delegate
does not assume owner ship overcallable
. You need to ensure it’s lifetime is longer than that ofDelegate
.- Template Parameters
Callable – Type of the callable
- Parameters
callable – The callable (function object or lambda)
-
template<typename Callable, typename = isNoFunPtr<Callable>>
void connect(Callable&&) = delete Connection with rvalue reference is deleted, should catch assignment from temporary objects and thus invalid pointers.
-
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
-
template<typename Callable, typename = isNoFunPtr<Callable>>
inline void operator=(Callable &callable) Assignment operator with possibly stateful function object.
Note
Delegate
does not assume owner ship overcallable
. You need to ensure it’s lifetime is longer than that ofDelegate
.- Template Parameters
Callable – Type of the callable
- Parameters
callable – The callable (function object or lambda)
-
template<typename Callable, typename = isNoFunPtr<Callable>>
void operator=(Callable&&) = delete Assignment operator from rvalue reference is deleted, should catch assignment from temporary objects and thus invalid pointers.
Private Types
-
using function_ptr_type = return_type (*)(Args...)¶
-
using function_type = return_type (*)(const void*, Args...)¶
Alias to the function pointer type this class will store.
-
using isNoFunPtr = std::enable_if_t<not std::is_convertible_v<std::decay_t<T>, function_type>>¶
-
using isSignatureCompatible = decltype(std::declval<T&>() = std::declval<C>())¶
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>