LibreOffice 5.3 SDK C/C++ API Reference
template for implementing singleton classes. More...
|standard ctor. More...|
|standard dtor. More...|
|SingletonClass *||operator-> () const|
|Allows rSingle->someBodyOp(). More...|
|SingletonClass &||operator* () const|
|Allows (*rSingle).someBodyOp(). More...|
template for implementing singleton classes.
Such classes can be instantiated every time they are needed. But the internal wrapped object will be created one times only. Of course its used resources are referenced one times only too. This template hold it alive till the last reference is gone. Further all operations on this reference are threadsafe. Only calls directly to the internal object (which modify its state) must be made threadsafe by the object itself or from outside.
The only chance to suppress such strange constellations is a lazy-init mechanism.
Note further that this singleton pattern can work only, if all user of such singleton are located inside the same library! Because static values can't be exported - e.g. from windows libraries.
The internal wrapped object is created only, if its ref count was 0. Otherwise this method does nothing ... except increasing of the internal ref count!
The internal wrapped object is removed only, if its ref count wil be 0. Otherwise this method does nothing ... except decreasing of the internal ref count!