Blaze 3.9
Dependency.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_SINGLETON_DEPENDENCY_H_
36#define _BLAZE_UTIL_SINGLETON_DEPENDENCY_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <memory>
45
46
47namespace blaze {
48
49//=================================================================================================
50//
51// CLASS DEFINITION
52//
53//=================================================================================================
54
55//*************************************************************************************************
83template< typename T > // Type of the lifetime dependency
85{
86 public:
87 //**Constructors********************************************************************************
90 inline Dependency();
92 //**********************************************************************************************
93
94 private:
95 //**Member variables****************************************************************************
98 std::shared_ptr<T> dependency_;
100 //**********************************************************************************************
101};
102//*************************************************************************************************
103
104
105
106
107//=================================================================================================
108//
109// CONSTRUCTORS
110//
111//=================================================================================================
112
113//*************************************************************************************************
116template< typename T > // Type of the lifetime dependency
118 : dependency_( T::instance() ) // Handle to the lifetime dependency
119{
120 BLAZE_CONSTRAINT_MUST_BE_DERIVED_FROM( T, typename T::SingletonType );
121}
122//*************************************************************************************************
123
124} // namespace blaze
125
126#endif
Constraint on the inheritance relationship of a data type.
Lifetime dependency on a singleton object.
Definition: Dependency.h:85
Dependency()
Default constructor for Dependency.
Definition: Dependency.h:117
std::shared_ptr< T > dependency_
Handle to the lifetime dependency.
Definition: Dependency.h:98
#define BLAZE_CONSTRAINT_MUST_BE_DERIVED_FROM(D, B)
Constraint on the inheritance relationship of a data type.
Definition: DerivedFrom.h:60