35 #ifndef _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 36 #define _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 61 template<
typename >
class Dependency;
83 ,
size_t N = Length_v<D> >
84 struct HasCyclicDependencyHelper;
99 struct HasCyclicDependencyHelper<TL,
NullType,N>
101 static constexpr
bool value =
false;
115 template<
typename TL
117 struct HasCyclicDependencyHelper<TL,D,1>
135 template<
typename TL
137 struct HasCyclicDependencyHelper<TL,D,2>
139 using D1 = TypeAt_t<D,0>;
140 using D2 = TypeAt_t<D,1>;
142 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
143 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value );
157 template<
typename TL
159 struct HasCyclicDependencyHelper<TL,D,3>
161 using D1 = TypeAt_t<D,0>;
162 using D2 = TypeAt_t<D,1>;
163 using D3 = TypeAt_t<D,2>;
165 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
166 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
167 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value );
181 template<
typename TL
183 struct HasCyclicDependencyHelper<TL,D,4>
185 using D1 = TypeAt_t<D,0>;
186 using D2 = TypeAt_t<D,1>;
187 using D3 = TypeAt_t<D,2>;
188 using D4 = TypeAt_t<D,3>;
190 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
191 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
192 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
193 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value );
207 template<
typename TL
209 struct HasCyclicDependencyHelper<TL,D,5>
211 using D1 = TypeAt_t<D,0>;
212 using D2 = TypeAt_t<D,1>;
213 using D3 = TypeAt_t<D,2>;
214 using D4 = TypeAt_t<D,3>;
215 using D5 = TypeAt_t<D,4>;
217 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
218 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
219 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
220 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
221 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value );
235 template<
typename TL
237 struct HasCyclicDependencyHelper<TL,D,6>
239 using D1 = TypeAt_t<D,0>;
240 using D2 = TypeAt_t<D,1>;
241 using D3 = TypeAt_t<D,2>;
242 using D4 = TypeAt_t<D,3>;
243 using D5 = TypeAt_t<D,4>;
244 using D6 = TypeAt_t<D,5>;
246 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
247 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
248 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
249 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
250 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
251 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value );
265 template<
typename TL
267 struct HasCyclicDependencyHelper<TL,D,7>
269 using D1 = TypeAt_t<D,0>;
270 using D2 = TypeAt_t<D,1>;
271 using D3 = TypeAt_t<D,2>;
272 using D4 = TypeAt_t<D,3>;
273 using D5 = TypeAt_t<D,4>;
274 using D6 = TypeAt_t<D,5>;
275 using D7 = TypeAt_t<D,6>;
277 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
278 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
279 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
280 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
281 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
282 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value ||
283 HasCyclicDependency<D7,TL,Contains_v<TL,D7>>::value );
297 template<
typename TL
299 struct HasCyclicDependencyHelper<TL,D,8>
301 using D1 = TypeAt_t<D,0>;
302 using D2 = TypeAt_t<D,1>;
303 using D3 = TypeAt_t<D,2>;
304 using D4 = TypeAt_t<D,3>;
305 using D5 = TypeAt_t<D,4>;
306 using D6 = TypeAt_t<D,5>;
307 using D7 = TypeAt_t<D,6>;
308 using D8 = TypeAt_t<D,7>;
310 static constexpr
bool value = ( HasCyclicDependency<D1,TL,Contains_v<TL,D1>>::value ||
311 HasCyclicDependency<D2,TL,Contains_v<TL,D2>>::value ||
312 HasCyclicDependency<D3,TL,Contains_v<TL,D3>>::value ||
313 HasCyclicDependency<D4,TL,Contains_v<TL,D4>>::value ||
314 HasCyclicDependency<D5,TL,Contains_v<TL,D5>>::value ||
315 HasCyclicDependency<D6,TL,Contains_v<TL,D6>>::value ||
316 HasCyclicDependency<D7,TL,Contains_v<TL,D7>>::value ||
317 HasCyclicDependency<D8,TL,Contains_v<TL,D8>>::value );
342 ,
bool C = Contains_v<TL,T> >
343 struct HasCyclicDependency
344 :
public BoolConstant< HasCyclicDependencyHelper<Append_t<TL,T>,typename T::Dependencies>::value >
361 struct HasCyclicDependency<T,TL,true>
382 #define BLAZE_DETECT_CYCLIC_LIFETIME_DEPENDENCY(T) \ 383 static_assert( ( !blaze::HasCyclicDependency<T,blaze::NullType>::value ), "Cyclic dependency detected" ) 402 #define BLAZE_BEFRIEND_SINGLETON \ 403 template< typename, typename, typename, typename, typename, typename, typename, typename, typename > friend class blaze::Singleton; \ 404 template< typename, typename, bool > friend struct blaze::HasCyclicDependency; \ 405 template< typename > friend class blaze::Dependency; 552 ,
typename D1 = NullType
553 ,
typename D2 = NullType
554 ,
typename D3 = NullType
555 ,
typename D4 = NullType
556 ,
typename D5 = NullType
557 ,
typename D6 = NullType
558 ,
typename D7 = NullType
559 ,
typename D8 = NullType >
619 static std::shared_ptr<T> instance()
621 static std::shared_ptr<T> object(
new T() );
725 static std::shared_ptr<T> instance()
727 static std::shared_ptr<T> object(
new T() );
774 class Singleton<T,D1,D2,D3,D4,D5,D6,NullType,NullType>
775 :
private NonCopyable
780 using SingletonType = Singleton<T,D1,D2,D3,D4,D5,D6,NullType,NullType>;
783 using Dependencies = TypeList< D1, D2, D3, D4, D5, D6 >;
827 static std::shared_ptr<T> instance()
829 static std::shared_ptr<T> object(
new T() );
874 class Singleton<T,D1,D2,D3,D4,D5,NullType,NullType,NullType>
875 :
private NonCopyable
880 using SingletonType = Singleton<T,D1,D2,D3,D4,D5,NullType,NullType,NullType>;
924 static std::shared_ptr<T> instance()
926 static std::shared_ptr<T> object(
new T() );
969 class Singleton<T,D1,D2,D3,D4,NullType,NullType,NullType,NullType>
970 :
private NonCopyable
975 using SingletonType = Singleton<T,D1,D2,D3,D4,NullType,NullType,NullType,NullType>;
1016 static std::shared_ptr<T> instance()
1018 static std::shared_ptr<T> object(
new T() );
1055 template<
typename T
1059 class Singleton<T,D1,D2,D3,NullType,NullType,NullType,NullType,NullType>
1060 :
private NonCopyable
1065 using SingletonType = Singleton<T,D1,D2,D3,NullType,NullType,NullType,NullType,NullType>;
1103 static std::shared_ptr<T> instance()
1105 static std::shared_ptr<T> object(
new T() );
1141 template<
typename T
1144 class Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType>
1145 :
private NonCopyable
1150 using SingletonType = Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType>;
1185 static std::shared_ptr<T> instance()
1187 static std::shared_ptr<T> object(
new T() );
1222 template<
typename T
1224 class Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1225 :
private NonCopyable
1230 using SingletonType = Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType>;
1262 static std::shared_ptr<T> instance()
1264 static std::shared_ptr<T> object(
new T() );
1298 template<
typename T >
1299 class Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1300 :
private NonCopyable
1305 using SingletonType = Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>;
1334 static std::shared_ptr<T> instance()
1336 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:139
Utility type for generic codes.
std::shared_ptr< D1 > dependency1_
Handle to the first lifetime dependency.
Definition: Singleton.h:631
Base class for non-copyable class instances.
std::shared_ptr< D2 > dependency2_
Handle to the second lifetime dependency.
Definition: Singleton.h:632
std::shared_ptr< D7 > dependency7_
Handle to the seventh lifetime dependency.
Definition: Singleton.h:637
std::shared_ptr< D4 > dependency4_
Handle to the fourth lifetime dependency.
Definition: Singleton.h:634
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
~Singleton()
Destructor for the Singleton class.
Definition: Singleton.h:611
std::shared_ptr< D8 > dependency8_
Handle to the eighth lifetime dependency.
Definition: Singleton.h:638
std::shared_ptr< D5 > dependency5_
Handle to the fifth lifetime dependency.
Definition: Singleton.h:635
TypeList< D1, D2, D3, D4, D5, D6, D7, D8 > Dependencies
Type list of all lifetime dependencies.
Definition: Singleton.h:569
std::shared_ptr< D3 > dependency3_
Handle to the third lifetime dependency.
Definition: Singleton.h:633
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:636
#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:560
Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 > SingletonType
Type of this Singleton instance.
Definition: Singleton.h:566
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 alias template represents ...
Definition: IntegralConstant.h:110
Definition: Singleton.h:62
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:382
Singleton()
Constructor for the Singleton class.
Definition: Singleton.h:578
Header file for compile time constraints.