Audacity 3.2.0
Classes | Public Types | Static Public Member Functions | List of all members
GlobalHook< Tag, Signature, Default, Options > Class Template Reference

Global function-valued variable, adding a convenient Call() More...

#include <GlobalVariable.h>

Inheritance diagram for GlobalHook< Tag, Signature, Default, Options >:
[legend]
Collaboration diagram for GlobalHook< Tag, Signature, Default, Options >:
[legend]

Classes

struct  SubstituteInShared
 Can generate overriding hooks of shared_ptr factories. More...
 
struct  SubstituteInUnique
 Can generate overriding hooks of unique_ptr factories. More...
 

Public Types

using result_type = typename std::function< Signature >::result_type
 
using Scope = typename GlobalVariable< Tag, const std::function< Signature >, Default, Options... >::Scope
 
- Public Types inherited from GlobalVariable< Tag, const std::function< Signature >, nullptr, Options... >
using variable_type = GlobalVariable
 
using stored_type = const std::function< Signature >
 
using mutable_type = std::remove_const_t< const std::function< Signature > >
 

Static Public Member Functions

template<typename... Arguments>
static result_type Call (Arguments &&...arguments)
 Null check of the installed function is done for you. More...
 
- Static Public Member Functions inherited from GlobalVariable< Tag, const std::function< Signature >, nullptr, Options... >
static stored_typeGet ()
 Get the installed value. More...
 
static auto Set (std::conditional_t< ScopedOnly, dummy, mutable_type > replacement) -> std::conditional_t< ScopedOnly, void, mutable_type >
 Move in a new value, move out and return the previous. More...
 

Detailed Description

template<typename Tag, typename Signature, auto Default = nullptr, auto... Options>
class GlobalHook< Tag, Signature, Default, Options >

Global function-valued variable, adding a convenient Call()

Definition at line 155 of file GlobalVariable.h.

Member Typedef Documentation

◆ result_type

template<typename Tag , typename Signature , auto Default = nullptr, auto... Options>
using GlobalHook< Tag, Signature, Default, Options >::result_type = typename std::function<Signature>::result_type

Definition at line 160 of file GlobalVariable.h.

◆ Scope

template<typename Tag , typename Signature , auto Default = nullptr, auto... Options>
using GlobalHook< Tag, Signature, Default, Options >::Scope = typename GlobalVariable<Tag, const std::function<Signature>, Default, Options... >::Scope

Definition at line 161 of file GlobalVariable.h.

Member Function Documentation

◆ Call()

template<typename Tag , typename Signature , auto Default = nullptr, auto... Options>
template<typename... Arguments>
static result_type GlobalHook< Tag, Signature, Default, Options >::Call ( Arguments &&...  arguments)
inlinestatic

Null check of the installed function is done for you.

Requires that the return type of the function is void or default-constructible

Definition at line 169 of file GlobalVariable.h.

170 {
171 auto &fn = GlobalHook::Get();
172 if (fn)
173 return fn(std::forward<Arguments>(arguments)...);
174 else if constexpr (std::is_void_v<result_type>)
175 return;
176 else
177 return result_type{};
178 }
static const auto fn
typename std::function< Signature >::result_type result_type

References fn, and GlobalVariable< Tag, const std::function< Signature >, nullptr, Options... >::Get().

Here is the call graph for this function:

The documentation for this class was generated from the following file: