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 >
581 : dependency1_( D1::instance() )
582 , dependency2_( D2::instance() )
583 , dependency3_( D3::instance() )
584 , dependency4_( D4::instance() )
585 , dependency5_( D5::instance() )
586 , dependency6_( D6::instance() )
587 , dependency7_( D7::instance() )
588 , dependency8_( D8::instance() )
621 static std::shared_ptr<T> instance()
623 static std::shared_ptr<T> object(
new T() );
690 : dependency1_( D1::instance() )
691 , dependency2_( D2::instance() )
692 , dependency3_( D3::instance() )
693 , dependency4_( D4::instance() )
694 , dependency5_( D5::instance() )
695 , dependency6_( D6::instance() )
696 , dependency7_( D7::instance() )
727 static std::shared_ptr<T> instance()
729 static std::shared_ptr<T> object(
new T() );
739 std::shared_ptr<D1> dependency1_;
740 std::shared_ptr<D2> dependency2_;
741 std::shared_ptr<D3> dependency3_;
742 std::shared_ptr<D4> dependency4_;
743 std::shared_ptr<D5> dependency5_;
744 std::shared_ptr<D6> dependency6_;
745 std::shared_ptr<D7> dependency7_;
776 class Singleton<T,D1,D2,D3,D4,D5,D6,NullType,NullType>
795 : dependency1_( D1::instance() )
796 , dependency2_( D2::instance() )
797 , dependency3_( D3::instance() )
798 , dependency4_( D4::instance() )
799 , dependency5_( D5::instance() )
800 , dependency6_( D6::instance() )
829 static std::shared_ptr<T> instance()
831 static std::shared_ptr<T> object(
new T() );
841 std::shared_ptr<D1> dependency1_;
842 std::shared_ptr<D2> dependency2_;
843 std::shared_ptr<D3> dependency3_;
844 std::shared_ptr<D4> dependency4_;
845 std::shared_ptr<D5> dependency5_;
846 std::shared_ptr<D6> dependency6_;
876 class Singleton<T,D1,D2,D3,D4,D5,NullType,NullType,NullType>
895 : dependency1_( D1::instance() )
896 , dependency2_( D2::instance() )
897 , dependency3_( D3::instance() )
898 , dependency4_( D4::instance() )
899 , dependency5_( D5::instance() )
926 static std::shared_ptr<T> instance()
928 static std::shared_ptr<T> object(
new T() );
938 std::shared_ptr<D1> dependency1_;
939 std::shared_ptr<D2> dependency2_;
940 std::shared_ptr<D3> dependency3_;
941 std::shared_ptr<D4> dependency4_;
942 std::shared_ptr<D5> dependency5_;
971 class Singleton<T,D1,D2,D3,D4,NullType,NullType,NullType,NullType>
990 : dependency1_( D1::instance() )
991 , dependency2_( D2::instance() )
992 , dependency3_( D3::instance() )
993 , dependency4_( D4::instance() )
1018 static std::shared_ptr<T> instance()
1020 static std::shared_ptr<T> object(
new T() );
1030 std::shared_ptr<D1> dependency1_;
1031 std::shared_ptr<D2> dependency2_;
1032 std::shared_ptr<D3> dependency3_;
1033 std::shared_ptr<D4> dependency4_;
1057 template<
typename T
1061 class Singleton<T,D1,D2,D3,NullType,NullType,NullType,NullType,NullType>
1080 : dependency1_( D1::instance() )
1081 , dependency2_( D2::instance() )
1082 , dependency3_( D3::instance() )
1105 static std::shared_ptr<T> instance()
1107 static std::shared_ptr<T> object(
new T() );
1117 std::shared_ptr<D1> dependency1_;
1118 std::shared_ptr<D2> dependency2_;
1119 std::shared_ptr<D3> dependency3_;
1143 template<
typename T
1146 class Singleton<T,D1,D2,NullType,NullType,NullType,NullType,NullType,NullType>
1165 : dependency1_( D1::instance() )
1166 , dependency2_( D2::instance() )
1187 static std::shared_ptr<T> instance()
1189 static std::shared_ptr<T> object(
new T() );
1199 std::shared_ptr<D1> dependency1_;
1200 std::shared_ptr<D2> dependency2_;
1224 template<
typename T
1226 class Singleton<T,D1,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1245 : dependency1_( D1::instance() )
1264 static std::shared_ptr<T> instance()
1266 static std::shared_ptr<T> object(
new T() );
1276 std::shared_ptr<D1> dependency1_;
1300 template<
typename T >
1301 class Singleton<T,NullType,NullType,NullType,NullType,NullType,NullType,NullType,NullType>
1336 static std::shared_ptr<T> instance()
1338 static std::shared_ptr<T> object(
new T() );
Utility type for generic codes.
Appending a type to a type list.The Append class can be used to append the data type T to a type list...
Definition: Append.h:69
std::shared_ptr< D1 > dependency1_
Handle to the first lifetime dependency.
Definition: Singleton.h:633
Base class for non-copyable class instances.
std::shared_ptr< D2 > dependency2_
Handle to the second lifetime dependency.
Definition: Singleton.h:634
std::shared_ptr< D7 > dependency7_
Handle to the seventh lifetime dependency.
Definition: Singleton.h:639
std::shared_ptr< D4 > dependency4_
Handle to the fourth lifetime dependency.
Definition: Singleton.h:636
~Singleton()
Destructor for the Singleton class.
Definition: Singleton.h:613
std::shared_ptr< D8 > dependency8_
Handle to the eighth lifetime dependency.
Definition: Singleton.h:640
std::shared_ptr< D5 > dependency5_
Handle to the fifth lifetime dependency.
Definition: Singleton.h:637
std::shared_ptr< D3 > dependency3_
Handle to the third lifetime dependency.
Definition: Singleton.h:635
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:638
#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
Calculating the length of a type list.The Length class can be used to obtain the length of a type lis...
Definition: Length.h:71
Base class for all lifetime managed singletons.The Singleton class represents the base class for all ...
Definition: Singleton.h:562
Indexing a type list.The TypeAt class can be used to access a type list at a specified position to qu...
Definition: TypeAt.h:76
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
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: Contains.h:78
Singleton()
Constructor for the Singleton class.
Definition: Singleton.h:580
Header file for compile time constraints.