Blaze 3.9
List of all members
blaze::Dependency< T > Class Template Reference

Lifetime dependency on a singleton object. More...

#include <Dependency.h>

Public Member Functions

Constructors
 Dependency ()
 Default constructor for Dependency.
 

Private Attributes

Member variables
std::shared_ptr< T > dependency_
 Handle to the lifetime dependency.
 

Detailed Description

template<typename T>
class blaze::Dependency< T >

Lifetime dependency on a singleton object.

The Dependency template class represents a lifetime dependency on a singleton object based on the Blaze Singleton functionality. By use of the Dependency template, any class can by either public or non-public inheritance or composition define a single or multiple lifetime dependencies on one or several singletons, which guarantees that the singleton instance(s) will be destroyed after the dependent object. The following example demonstrates both the inheritance as well as the composition approach:

// Definition of the Viewer class, which is depending on the Logger singleton instance
// #1: Approach by non-public inheritance
class Viewer : private Dependency<Logger>
{
...
};
// #2: Approach by composition
class Viewer
{
private:
Dependency<Logger> dependency_;
};
Dependency()
Default constructor for Dependency.
Definition: Dependency.h:117
std::shared_ptr< T > dependency_
Handle to the lifetime dependency.
Definition: Dependency.h:98

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