35 #ifndef _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 36 #define _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 62 template<
typename >
class Dependency;
84 ,
size_t N = Length_v<D> >
85 struct HasCyclicDependencyHelper;
100 struct HasCyclicDependencyHelper<TL,
NullType,N>
102 static constexpr
bool value =
false;
116 template<
typename TL
118 struct HasCyclicDependencyHelper<TL,D,1>
136 template<
typename TL
138 struct HasCyclicDependencyHelper<TL,D,2>
140 using D1 = TypeAt_t<D,0>;
141 using D2 = TypeAt_t<D,1>;
143 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
144 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value );
158 template<
typename TL
160 struct HasCyclicDependencyHelper<TL,D,3>
162 using D1 = TypeAt_t<D,0>;
163 using D2 = TypeAt_t<D,1>;
164 using D3 = TypeAt_t<D,2>;
166 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
167 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
168 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value );
182 template<
typename TL
184 struct HasCyclicDependencyHelper<TL,D,4>
186 using D1 = TypeAt_t<D,0>;
187 using D2 = TypeAt_t<D,1>;
188 using D3 = TypeAt_t<D,2>;
189 using D4 = TypeAt_t<D,3>;
191 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
192 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
193 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
194 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value );
208 template<
typename TL
210 struct HasCyclicDependencyHelper<TL,D,5>
212 using D1 = TypeAt_t<D,0>;
213 using D2 = TypeAt_t<D,1>;
214 using D3 = TypeAt_t<D,2>;
215 using D4 = TypeAt_t<D,3>;
216 using D5 = TypeAt_t<D,4>;
218 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
219 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
220 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
221 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
222 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value );
236 template<
typename TL
238 struct HasCyclicDependencyHelper<TL,D,6>
240 using D1 = TypeAt_t<D,0>;
241 using D2 = TypeAt_t<D,1>;
242 using D3 = TypeAt_t<D,2>;
243 using D4 = TypeAt_t<D,3>;
244 using D5 = TypeAt_t<D,4>;
245 using D6 = TypeAt_t<D,5>;
247 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
248 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
249 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
250 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
251 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
252 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value );
266 template<
typename TL
268 struct HasCyclicDependencyHelper<TL,D,7>
270 using D1 = TypeAt_t<D,0>;
271 using D2 = TypeAt_t<D,1>;
272 using D3 = TypeAt_t<D,2>;
273 using D4 = TypeAt_t<D,3>;
274 using D5 = TypeAt_t<D,4>;
275 using D6 = TypeAt_t<D,5>;
276 using D7 = TypeAt_t<D,6>;
278 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
279 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
280 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
281 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
282 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
283 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value ||
284 HasCyclicDependency<D7,TL,Contains_v<TL,D7>>::value );
298 template<
typename TL
300 struct HasCyclicDependencyHelper<TL,D,8>
302 using D1 = TypeAt_t<D,0>;
303 using D2 = TypeAt_t<D,1>;
304 using D3 = TypeAt_t<D,2>;
305 using D4 = TypeAt_t<D,3>;
306 using D5 = TypeAt_t<D,4>;
307 using D6 = TypeAt_t<D,5>;
308 using D7 = TypeAt_t<D,6>;
309 using D8 = TypeAt_t<D,7>;
311 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
312 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
313 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
314 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
315 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
316 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value ||
317 HasCyclicDependency<D7,TL,Contains_v<TL,D7>>::value ||
318 HasCyclicDependency<D8,TL,Contains_v<TL,D8>>::value );
343 ,
bool C = Contains_v<TL,T> >
344 struct HasCyclicDependency
345 :
public BoolConstant< HasCyclicDependencyHelper<Append_t<TL,T>,typename T::Dependencies>::value >
362 struct HasCyclicDependency<T,TL,true>
383 #define BLAZE_DETECT_CYCLIC_LIFETIME_DEPENDENCY(T) \ 384 static_assert( ( !blaze::HasCyclicDependency<T,blaze::NullType>::value ), "Cyclic dependency detected" ) 403 #define BLAZE_BEFRIEND_SINGLETON \ 404 template< typename, typename, typename, typename, typename, typename, typename, typename, typename > friend class blaze::Singleton; \ 405 template< typename, typename, bool > friend struct blaze::HasCyclicDependency; \ 406 template< typename > friend class blaze::Dependency; 553 ,
typename D1 = NullType
554 ,
typename D2 = NullType
555 ,
typename D3 = NullType
556 ,
typename D4 = NullType
557 ,
typename D5 = NullType
558 ,
typename D6 = NullType
559 ,
typename D7 = NullType
560 ,
typename D8 = NullType >
620 static std::shared_ptr<T> instance()
622 static std::shared_ptr<T> object(
new T() );
726 static std::shared_ptr<T> instance()
728 static std::shared_ptr<T> object(
new T() );
775 class Singleton<T,D1,D2,D3,D4,D5,D6,NullType,NullType>
776 :
private NonCopyable
781 using SingletonType = Singleton<T,D1,D2,D3,D4,D5,D6,NullType,NullType>;
784 using Dependencies = TypeList< D1, D2, D3, D4, D5, D6 >;
828 static std::shared_ptr<T> instance()
830 static std::shared_ptr<T> object(
new T() );
875 class Singleton<T,D1,D2,D3,D4,D5,NullType,NullType,NullType>
876 :
private NonCopyable
881 using SingletonType = Singleton<T,D1,D2,D3,D4,D5,NullType,NullType,NullType>;
925 static std::shared_ptr<T> instance()
927 static std::shared_ptr<T> object(
new T() );
970 class Singleton<T,D1,D2,D3,D4,NullType,NullType,NullType,NullType>
971 :
private NonCopyable
976 using SingletonType = Singleton<T,D1,D2,D3,D4,NullType,NullType,NullType,NullType>;
1017 static std::shared_ptr<T> instance()
1019 static std::shared_ptr<T> object(
new T() );
1056 template<
typename T
1060 class Singleton<T,D1,D2,D3,NullType,NullType,NullType,NullType,NullType>
1061 :
private NonCopyable
1066 using SingletonType = Singleton<T,D1,D2,D3,NullType,NullType,NullType,NullType,NullType>;
1104 static std::shared_ptr<T> instance()
1106 static std::shared_ptr<T> object(
new T() );
1142 template<
typename T
1145 class Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType>
1146 :
private NonCopyable
1151 using SingletonType = Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType>;
1186 static std::shared_ptr<T> instance()
1188 static std::shared_ptr<T> object(
new T() );
1223 template<
typename T
1225 class Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1226 :
private NonCopyable
1231 using SingletonType = Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType>;
1263 static std::shared_ptr<T> instance()
1265 static std::shared_ptr<T> object(
new T() );
1299 template<
typename T >
1300 class Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1301 :
private NonCopyable
1306 using SingletonType = Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>;
1335 static std::shared_ptr<T> instance()
1337 static std::shared_ptr<T> object(
new T() );
typename TypeAt< TL, Index >::Type TypeAt_t
Auxiliary alias declaration for the TypeAt class template.The TypeAt_t alias declaration provides a c...
Definition: TypeAt.h:140
Utility type for generic codes.
std::shared_ptr< D1 > dependency1_
Handle to the first lifetime dependency.
Definition: Singleton.h:632
Base class for non-copyable class instances.
std::shared_ptr< D2 > dependency2_
Handle to the second lifetime dependency.
Definition: Singleton.h:633
std::shared_ptr< D7 > dependency7_
Handle to the seventh lifetime dependency.
Definition: Singleton.h:638
std::shared_ptr< D4 > dependency4_
Handle to the fourth lifetime dependency.
Definition: Singleton.h:635
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
~Singleton()
Destructor for the Singleton class.
Definition: Singleton.h:612
std::shared_ptr< D8 > dependency8_
Handle to the eighth lifetime dependency.
Definition: Singleton.h:639
std::shared_ptr< D5 > dependency5_
Handle to the fifth lifetime dependency.
Definition: Singleton.h:636
TypeList< D1, D2, D3, D4, D5, D6, D7, D8 > Dependencies
Type list of all lifetime dependencies.
Definition: Singleton.h:570
std::shared_ptr< D3 > dependency3_
Handle to the third lifetime dependency.
Definition: Singleton.h:634
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
std::shared_ptr< D6 > dependency6_
Handle to the sixth lifetime dependency.
Definition: Singleton.h:637
#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
Base class for non-copyable class instances.The NonCopyable class is intended to work as a base class...
Definition: NonCopyable.h:63
Constraint on the inheritance relationship of a data type.
Implementation of a type list.The TypeList class template represents a list of data types of arbitrar...
Definition: TypeList.h:119
Base class for all lifetime managed singletons.The Singleton class represents the base class for all ...
Definition: Singleton.h:561
Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 > SingletonType
Type of this Singleton instance.
Definition: Singleton.h:567
Header file for the Unique class template.
Utility type for generic codes.The NullType class represents an invalid or terminating data type for ...
Definition: NullType.h:54
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:101
Definition: Singleton.h:63
Header file for the IntegralConstant class template.
#define BLAZE_DETECT_CYCLIC_LIFETIME_DEPENDENCY(T)
Constraint on the data type.In case the given data type T is not an integral data type...
Definition: Singleton.h:383
Singleton()
Constructor for the Singleton class.
Definition: Singleton.h:579
Header file for compile time constraints.
Header file for the TrueType type/value trait base class.