-
Notifications
You must be signed in to change notification settings - Fork 0
Singleton
Gautier Lefebvre edited this page Feb 13, 2018
·
3 revisions
There is a Singleton templated class easily usable within the framework.
class Foo :public fwk::Singleton<Foo> {
friend class fwk::Singleton<Foo>;
// delete every default constructors
Foo(const Foo&) = delete;
Foo(const Foo&&) = delete;
Foo& operator=(const Foo&) = delete;
// keep empty ctor and dtor private
Foo(void);
virtual ~Foo(void);
};
You can get the singleton class instance by doing this:
Foo& foo = Foo::get();
Foo* bar = Foo::asPtr();
You can delete the singleton class instance by doing this:
Foo::destroy();