template<typename T>
class Ocean::Singleton< T >
This template class is the base class for all singleton objects.
Each object derived from this class can only have at most one instance at the same time within the same process unless standalone dynamic libraries attached to the process.
By default, in the case a standalone dynamic library is attached, this library has it's own global variables and thus also provides own singleton objects.
If only one unique process-wide singleton is desired for applications with standalone dynamic libraries, the OceanManager object needs to be initialized accordingly directly at process beginning and directly during initialization of the dynamic library.
Beware: The derived class must not be accomplished entirely with inline functions.
Further, the derived class has to defined the Singleton base class as friend class.
- Template Parameters
-
T | Class type that will be extended as singleton |
- See also
- OceanManager.
See this tutorial:
class DerivedClass :
public Singleton<DerivedClass>
{
public:
void anyFunction()
{
}
private:
DerivedClass()
{
}
~DerivedClass()
{
}
};
void anywhereInYourCode()
{
DerivedClass::get().anyFunction();
}
Singleton()=default
Default constructor.