Blaze  3.6
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 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
83 template< 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_;
99 
100  //**********************************************************************************************
101 };
102 //*************************************************************************************************
103 
104 
105 
106 
107 //=================================================================================================
108 //
109 // CONSTRUCTORS
110 //
111 //=================================================================================================
112 
113 //*************************************************************************************************
116 template< 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
std::shared_ptr< T > dependency_
Handle to the lifetime dependency.
Definition: Dependency.h:98
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_CONSTRAINT_MUST_BE_DERIVED_FROM(D, B)
Constraint on the inheritance relationship of a data type.In case D is not derived from B,...
Definition: DerivedFrom.h:60
Constraint on the inheritance relationship of a data type.
Lifetime dependency on a singleton object.The Dependency template class represents a lifetime depende...
Definition: Dependency.h:84
Dependency()
Default constructor for Dependency.
Definition: Dependency.h:117