|
Open Model Railroad Network (OpenMRN)
|
#include <Singleton.hxx>
Static Public Member Functions | |
| static T * | instance () |
| static bool | exists () |
Static Private Attributes | |
| static T * | instance_ = nullptr |
| The singleton instance pointer. | |
Singleton class.
By inheriting from this class you declare that the descendants will have only a single instance in the running binary. This will allow accessing the running instance without passing around a pointer to it.
Usage:
class Foo;
class Foo: public Singleton<Foo> { ...as usual... };
DEFINE_SINGLETON_INSTANCE(Foo);
void appl_main() { Foo my_instance(constructor_args); }
somewhere else:
Foo::instance()->DoSomething();
Definition at line 65 of file Singleton.hxx.
|
inline |
Definition at line 67 of file Singleton.hxx.
Definition at line 72 of file Singleton.hxx.
Definition at line 83 of file Singleton.hxx.
|
inlinestatic |
Definition at line 77 of file Singleton.hxx.
|
staticprivate |
The singleton instance pointer.
Definition at line 89 of file Singleton.hxx.