OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
DependencyManager< Service > Struct Template Reference

Dependency Manager. More...

#include <InternalServices.hpp>

Public Types

typedef std::vector< Service * > InstanceSet
 Type of the set of injected instances.
 

Static Public Member Functions

static Service * getInstance ()
 Get a singleton instance of the service provider.
 
static const InstanceSet getAllInstances ()
 Get all instances of the service provider.
 
template<typename Provider >
static void inject (Provider *instance, bool multipleInstances=false)
 Inject an instance of the service provider to the service interface.
 
static void reset ()
 Remove all injected service providers (for testing)
 

Detailed Description

template<typename Service>
struct DependencyManager< Service >

Dependency Manager.

Template Parameters
ServiceService interface

Definition at line 89 of file InternalServices.hpp.

Member Typedef Documentation

◆ InstanceSet

template<typename Service >
std::vector<Service *> DependencyManager< Service >::InstanceSet

Type of the set of injected instances.

Definition at line 92 of file InternalServices.hpp.

Member Function Documentation

◆ getAllInstances()

template<typename Service >
static const InstanceSet DependencyManager< Service >::getAllInstances ( )
inlinestatic

Get all instances of the service provider.

Returns
InstanceSet Vector of pointers to service providers. Do not delete them.

Definition at line 120 of file InternalServices.hpp.

◆ getInstance()

template<typename Service >
static Service * DependencyManager< Service >::getInstance ( )
inlinestatic

Get a singleton instance of the service provider.

Returns
Service* A pointer to the service provider. Do not delete.

Definition at line 100 of file InternalServices.hpp.

◆ inject()

template<typename Service >
template<typename Provider >
static void DependencyManager< Service >::inject ( Provider * instance,
bool multipleInstances = false )
inlinestatic

Inject an instance of the service provider to the service interface.

Template Parameters
ProviderService interface
Parameters
instanceInstance of a service provider
multipleInstancesWhen true, instance is retrieved with getAllInstances(). When false, instance is retrieved with getInstance().

Definition at line 131 of file InternalServices.hpp.

◆ reset()

template<typename Service >
static void DependencyManager< Service >::reset ( )
inlinestatic

Remove all injected service providers (for testing)

Warning
For testing only. Do not call in production code.

Definition at line 151 of file InternalServices.hpp.


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