$search
Implementation of designe pattern which can be compared to phoenix singleton with advanced instance life management. More...
Classes | |
class | utilmm::singleton::dummy |
base class for utilmm::singleton::wrapper More... | |
class | utilmm::singleton::server |
Singleton server. More... | |
struct | utilmm::singleton::use< Ty > |
Access point to singleton. More... | |
class | utilmm::singleton::wrapper< Ty > |
Wrapper for singleton instances. More... | |
Namespaces | |
namespace | utilmm::singleton |
Singleton manipulation. | |
Files | |
file | dummy.hh |
Declaration of utilmm::singleton::dummy. | |
file | server.hh |
Definition of | |
file | server_fwd.hh |
Forward declaration of | |
file | use.hh |
Declararation of | |
file | use_fwd.hh |
Forward declaration of | |
file | wrapper.hh |
Declaration of utilmm::singleton::wrapper. | |
file | wrapper_fwd.hh |
Forward declaration of |
Implementation of designe pattern which can be compared to phoenix singleton with advanced instance life management.
This module includes all the classes used to implement a phoenix singleton pattern design supporting shared libraires.
The phoenix singleton pattern design offers the possibility to have a special class with these properties :
This implementation offer also a support for shared libraries using one ingleton server with advanced controller of life time for each instances. This controller is a basic phoenix singleton stored in a shared library.
To access to a singleton we need to use the utilmm::singleton::use
class. This class will offer an acces to singleton instance and will manage the singleton life (it can be seen as a reference counting smart pointer.
For example if one class foo
need to access to a singleton of type bar
. User can code it asd this :
#include "utilmm/singleton/use.hh" class foo { private: utilmm::singleton::use<bar> bar_s; int value; public: foo():value(0) {} explicit foo(int v):value(v) {} ~foo() {} void send_to_bar() { bar_s.instance().send(value); // or bar_s->send(value); } };
To define a class singleton as a pure singleton (ie it is impossible to access to it except by utilmm::singleton::use
) one can follow this example :
#include "utilmm/singleton/wrapper_fwd.hh" class pure_singleton { public: // [...] private: pure_singleton(); ~pure_singleton(); // [...] friend class utilmm::singleton::wrapper<pure_singleton>; };
All the structors are defined as private then only firends (ie utilmm::singleton::wrapper
) can create and destroy the instance then we have the guarantee that this class is a pure phoenix singleton.