Container for a list of pointers to providers. More...
#include <ProviderPack.h>
Public Member Functions | |
ProviderPack ()=default | |
Default constructor: a null provider pointer for each type. More... | |
ProviderPack (Providers const *...provider_ptrs) | |
Constructor: stores a provider pointer for each type. More... | |
template<typename... OtherProviders> | |
ProviderPack (ProviderPack< OtherProviders... > const &from) | |
Constructor: extracts the providers from anothe parameter pack. More... | |
template<typename... OtherProviders> | |
ProviderPack (OtherProviders const *...providers_tmp) | |
Constructor: extracts the providers from anothe parameter pack. More... | |
template<typename Provider > | |
Provider const * | get () const |
Returns the provider with the specified type. More... | |
template<typename Provider > | |
void | set (Provider const *provider_ptr) |
Sets the provider with the specified type. More... | |
Static Public Member Functions | |
template<typename Provider > | |
static constexpr bool | has () |
Returns whether there is a provider with the specified type. More... | |
Private Types | |
using | this_type = ProviderPack< Providers... > |
alias of this class More... | |
using | tuple_type = std::tuple< Providers const *... > |
type used for storage of the pointers More... | |
Private Attributes | |
tuple_type | providers |
container of the pointers, type-safe More... | |
Container for a list of pointers to providers.
Providers | types of the providers in the parameter pack |
The pointers are stored as constant. Note that this container can host any type of objects, and it has "provider" in the name because the reason it was written was to provide a fast way to specify a set of GArSoft service providers. The only limitation is that there should be only one object per type. Pointed objects are not owned by this class.
A a; B b; C c; D d; ProviderPack<A, B, C> pack(&a, &b, &c); // obtain a constant pointerto b from pack: B const* b_ptr = pack.get<B>(); if (pack.has<D>()) std::cerr << "Unexpected!" << std::endl;
(note that the latter check can be coded as a static assert)
Definition at line 90 of file ProviderPack.h.
|
private |
alias of this class
Definition at line 94 of file ProviderPack.h.
|
private |
type used for storage of the pointers
Definition at line 97 of file ProviderPack.h.
|
default |
Default constructor: a null provider pointer for each type.
|
inline |
Constructor: stores a provider pointer for each type.
Definition at line 104 of file ProviderPack.h.
|
inline |
Constructor: extracts the providers from anothe parameter pack.
OtherProviders | list of the providers of the source provider pack |
from | where to copy the information from |
This constructor requires all the providers we need to be present in the source provider pack.
Definition at line 116 of file ProviderPack.h.
|
inline |
Constructor: extracts the providers from anothe parameter pack.
OtherProviders | list of the providers of the source provider pack |
providers | all the providers needed (or more) |
This constructor requires all the providers we need to be present in the source provider pack.
Definition at line 132 of file ProviderPack.h.
|
inline |
Returns the provider with the specified type.
Definition at line 141 of file ProviderPack.h.
|
inlinestatic |
Returns whether there is a provider with the specified type.
Definition at line 159 of file ProviderPack.h.
|
inline |
Sets the provider with the specified type.
Definition at line 150 of file ProviderPack.h.
|
private |
container of the pointers, type-safe
Definition at line 167 of file ProviderPack.h.