common: Provide Singleton mixin for handling pseudo singletons
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 28 Sep 2018 19:17:32 +0000 (21:17 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 1 Oct 2018 17:06:49 +0000 (19:06 +0200)
commitd19063654aa5fc2fd4cf7c111aac00803cf7c845
treee5b54fc55060a3363c40c66da9fcfe6bea54299c
parent17fb652189fe89b446e672505cc8b0138f79e8b8
common: Provide Singleton mixin for handling pseudo singletons

We have several singleton and pseudo-singleton classes in Quassel.
A pseudo singleton can be constructed and destroyed in a controlled
manner, but can be accessed through a static instance pointer while
it is alive. As an example, QCoreApplication behaves like this.

In order to avoid duplication and unify the behavior of our singletons
in the future, provide a mixin. Classes can inherit from this and gain
an instance() method, as well as protection against multiple
instantiation and access outside of the object's lifetime.
src/common/CMakeLists.txt
src/common/singleton.h [new file with mode: 0644]