35 #ifndef _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 36 #define _BLAZE_UTIL_SINGLETON_SINGLETON_H_ 60 template<
typename >
class Dependency;
83 struct HasCyclicDependencyHelper;
98 struct HasCyclicDependencyHelper<TL,
NullType,N>
100 enum :
bool { value = 0 };
114 template<
typename TL
116 struct HasCyclicDependencyHelper<TL,D,1>
134 template<
typename TL
136 struct HasCyclicDependencyHelper<TL,D,2>
156 template<
typename TL
158 struct HasCyclicDependencyHelper<TL,D,3>
180 template<
typename TL
182 struct HasCyclicDependencyHelper<TL,D,4>
206 template<
typename TL
208 struct HasCyclicDependencyHelper<TL,D,5>
234 template<
typename TL
236 struct HasCyclicDependencyHelper<TL,D,6>
264 template<
typename TL
266 struct HasCyclicDependencyHelper<TL,D,7>
296 template<
typename TL
298 struct HasCyclicDependencyHelper<TL,D,8>
345 enum :
bool { value = HasCyclicDependencyHelper<ETL,typename T::Dependencies>::value };
364 enum :
bool { value = 1 };
384 #define BLAZE_DETECT_CYCLIC_LIFETIME_DEPENDENCY(T) \ 385 static_assert( ( !blaze::HasCyclicDependency<T,blaze::NullType>::value ), "Cyclic dependency detected" ) 404 #define BLAZE_BEFRIEND_SINGLETON \ 405 template< typename, typename, typename, typename, typename, typename, typename, typename, typename > friend class blaze::Singleton; \ 406 template< typename, typename, bool > friend struct blaze::HasCyclicDependency; \ 407 template< typename > friend class blaze::Dependency; 554 ,
typename D1 = NullType
555 ,
typename D2 = NullType
556 ,
typename D3 = NullType
557 ,
typename D4 = NullType
558 ,
typename D5 = NullType
559 ,
typename D6 = NullType
560 ,
typename D7 = NullType
561 ,
typename D8 = NullType >
580 : dependency1_( D1::instance() )
581 , dependency2_( D2::instance() )
582 , dependency3_( D3::instance() )
583 , dependency4_( D4::instance() )
584 , dependency5_( D5::instance() )
585 , dependency6_( D6::instance() )
586 , dependency7_( D7::instance() )
587 , dependency8_( D8::instance() )
620 static std::shared_ptr<T> instance()
622 static std::shared_ptr<T> object(
new T() );
688 : dependency1_( D1::instance() )
689 , dependency2_( D2::instance() )
690 , dependency3_( D3::instance() )
691 , dependency4_( D4::instance() )
692 , dependency5_( D5::instance() )
693 , dependency6_( D6::instance() )
694 , dependency7_( D7::instance() )
725 static std::shared_ptr<T> instance()
727 static std::shared_ptr<T> object(
new T() );
737 std::shared_ptr<D1> dependency1_;
738 std::shared_ptr<D2> dependency2_;
739 std::shared_ptr<D3> dependency3_;
740 std::shared_ptr<D4> dependency4_;
741 std::shared_ptr<D5> dependency5_;
742 std::shared_ptr<D6> dependency6_;
743 std::shared_ptr<D7> dependency7_;
792 : dependency1_( D1::instance() )
793 , dependency2_( D2::instance() )
794 , dependency3_( D3::instance() )
795 , dependency4_( D4::instance() )
796 , dependency5_( D5::instance() )
797 , dependency6_( D6::instance() )
826 static std::shared_ptr<T> instance()
828 static std::shared_ptr<T> object(
new T() );
838 std::shared_ptr<D1> dependency1_;
839 std::shared_ptr<D2> dependency2_;
840 std::shared_ptr<D3> dependency3_;
841 std::shared_ptr<D4> dependency4_;
842 std::shared_ptr<D5> dependency5_;
843 std::shared_ptr<D6> dependency6_;
891 : dependency1_( D1::instance() )
892 , dependency2_( D2::instance() )
893 , dependency3_( D3::instance() )
894 , dependency4_( D4::instance() )
895 , dependency5_( D5::instance() )
922 static std::shared_ptr<T> instance()
924 static std::shared_ptr<T> object(
new T() );
934 std::shared_ptr<D1> dependency1_;
935 std::shared_ptr<D2> dependency2_;
936 std::shared_ptr<D3> dependency3_;
937 std::shared_ptr<D4> dependency4_;
938 std::shared_ptr<D5> dependency5_;
985 : dependency1_( D1::instance() )
986 , dependency2_( D2::instance() )
987 , dependency3_( D3::instance() )
988 , dependency4_( D4::instance() )
1013 static std::shared_ptr<T> instance()
1015 static std::shared_ptr<T> object(
new T() );
1025 std::shared_ptr<D1> dependency1_;
1026 std::shared_ptr<D2> dependency2_;
1027 std::shared_ptr<D3> dependency3_;
1028 std::shared_ptr<D4> dependency4_;
1052 template<
typename T
1074 : dependency1_( D1::instance() )
1075 , dependency2_( D2::instance() )
1076 , dependency3_( D3::instance() )
1099 static std::shared_ptr<T> instance()
1101 static std::shared_ptr<T> object(
new T() );
1111 std::shared_ptr<D1> dependency1_;
1112 std::shared_ptr<D2> dependency2_;
1113 std::shared_ptr<D3> dependency3_;
1137 template<
typename T
1140 class Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType> :
private NonCopyable 1158 : dependency1_( D1::instance() )
1159 , dependency2_( D2::instance() )
1180 static std::shared_ptr<T> instance()
1182 static std::shared_ptr<T> object(
new T() );
1192 std::shared_ptr<D1> dependency1_;
1193 std::shared_ptr<D2> dependency2_;
1217 template<
typename T
1219 class Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType> :
private NonCopyable 1237 : dependency1_( D1::instance() )
1256 static std::shared_ptr<T> instance()
1258 static std::shared_ptr<T> object(
new T() );
1268 std::shared_ptr<D1> dependency1_;
1292 template<
typename T >
1293 class Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType> :
private NonCopyable 1301 typedef NullType Dependencies;
1327 static std::shared_ptr<T> instance()
1329 static std::shared_ptr<T> object(
new T() );
#define BLAZE_TYPELIST_3(T1, T2, T3)
Type list generation macro.This macro creates a type list consisting of the three types T1...
Definition: TypeList.h:191
Utility type for generic codes.
#define BLAZE_TYPELIST_6(T1, T2, T3, T4, T5, T6)
Type list generation macro.This macro creates a type list consisting of the six types T1...
Definition: TypeList.h:254
Appending a type to a type list.The Append class can be used to append the data type Type to a type l...
Definition: TypeList.h:771
#define BLAZE_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8)
Type list generation macro.This macro creates a type list consisting of the eight types T1...
Definition: TypeList.h:296
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
~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
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:57
std::shared_ptr< D6 > dependency6_
Handle to the sixth lifetime dependency.
Definition: Singleton.h:637
#define BLAZE_TYPELIST_1(T1)
Type list generation macro.This macro creates a type list only consisting of the type T1...
Definition: TypeList.h:149
#define BLAZE_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7)
Type list generation macro.This macro creates a type list consisting of the seven types T1...
Definition: TypeList.h:275
#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
#define BLAZE_TYPELIST_2(T1, T2)
Type list generation macro.This macro creates a type list consisting of the two types T1 and T2...
Definition: TypeList.h:170
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.
Calculating the length of a type list.The Length class can be used to obtain the length of a type lis...
Definition: TypeList.h:369
Base class for all lifetime managed singletons.The Singleton class represents the base class for all ...
Definition: Singleton.h:562
#define BLAZE_TYPELIST_5(T1, T2, T3, T4, T5)
Type list generation macro.This macro creates a type list consisting of the five types T1...
Definition: TypeList.h:233
Indexing a type list.The TypeAt class can be used to access a type list at a specified position to qu...
Definition: TypeList.h:434
Header file for a type list implementation.
Utility type for generic codes.The NullType class represents an invalid or terminating data type for ...
Definition: NullType.h:54
Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 > SingletonType
Type of this Singleton instance.
Definition: Singleton.h:567
#define BLAZE_TYPELIST_4(T1, T2, T3, T4)
Type list generation macro.This macro creates a type list consisting of the four types T1...
Definition: TypeList.h:212
Definition: Singleton.h:61
#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:384
Searching a type list.The Contains class can be used to search the type list for a particular type Ty...
Definition: TypeList.h:520
Singleton()
Constructor for the Singleton class.
Definition: Singleton.h:579
Header file for compile time constraints.