![]() |
Blaze
3.6
|
Classes | |
class | blaze::Dependency< T > |
Lifetime dependency on a singleton object.The Dependency template class represents a lifetime dependency on a singleton object based on the Blaze Singleton functionality. By use of the Dependency template, any class can by either public or non-public inheritance or composition define a single or multiple lifetime dependencies on one or several singletons, which guarantees that the singleton instance(s) will be destroyed after the dependent object. The following example demonstrates both the inheritance as well as the composition approach: More... | |
class | blaze::Singleton< T, D1, D2, D3, D4, D5, D6, D7, D8 > |
Base class for all lifetime managed singletons.The Singleton class represents the base class for all lifetime managed singletons of the Blaze library. Classes, which are supposed to be implemented in terms of the singleton pattern, only have to derive from this class in order to gain all basic characteristics of a singleton: More... | |
Macros | |
#define | BLAZE_DETECT_CYCLIC_LIFETIME_DEPENDENCY(T) static_assert( ( !blaze::HasCyclicDependency<T,blaze::NullType>::value ), "Cyclic dependency detected" ) |
Constraint on the data type.In case the given data type T is not an integral data type, a compilation error is created. | |
#define | BLAZE_BEFRIEND_SINGLETON |
Friendship declaration for the Singleton class template.This macro has to be used in order to declare the Singleton functionality as friend of the class deriving from Singleton. More... | |
The singleton design pattern is one of the most popular and most important design patterns available. It can be used to ensures that a specific class has only exactly one instance, and provides a global access point to this instance [1,2]. Additionally, via the singleton pattern it is posssible to manage the lifetime of objects, and especially the lifetime dependencies between several objects.
In the Blaze library the singleton pattern is realized by the Singleton class template. Classes that are supposed to be implemented in terms of the singleton pattern only have to derive from this class in order to gain all necessary characteristics of a singleton:
The only precondition on classes deriving from the Singleton class is the availability of a default constructor. In case it is not possible to instantiate the class via a default constructor, i.e., in case the class has only constructors that require at least a single argument, the Blaze Singleton implementation cannot be used!
In order to make a specific class a singleton, two modifications have to be applied to this class:
[1] E. Gamma, R. Helm, R.E. Johnson, J.M. Vlissides: Design Patterns, Addison-Wesley Professional Computing Series, 2008, ISBN: 978-0-201-63361-0
[2] S. Meyers: Effective C++, Third Edition, Addison-Wesley Professional Computing Series, 2008, ISBN: 978-0-321-33487-9
[3] J. Ringle: Singleton Creation the Thread-safe Way, Dr. Dobb's (www.drdobbs.com), 1999
[4] A. Alexandrescu: Modern C++ Design, Generic Programming and Design Patterns Applied, Addison-Wesley, 2001, ISBN: 978-0201704310
[5] E. Gabrilovich: Controlling the Destruction Order of Singleton Objects, Dr. Dobbs (www.drdobbs.com), 1999
#define BLAZE_BEFRIEND_SINGLETON |
Friendship declaration for the Singleton class template.This macro has to be used in order to declare the Singleton functionality as friend of the class deriving from Singleton.