Manual for OpenFLUID 2.1.11

Static Public Member Functions | Protected Member Functions | List of all members
openfluid::utils::MeyerSingleton< T > Class Template Reference

Detailed Description

template<typename T>
class openfluid::utils::MeyerSingleton< T >

Singleton template class implementing the Meyer's singleton design. This implementation is thread safe in C++11.

Warning
This template class does not work in a cross-dll context on Windows. Due to this restriction, it must not be used in the OpenFLUID framework.

Example of use to design an Example class as a singleton

class MeyerExample : public openfluid::utils::MeyerSingleton<MeyerExample>
{
friend class openfluid::utils::MeyerSingleton<MeyerExample>;
private:
MeyerExample();
~MeyerExample();
public:
// some public members
};

#include <utils/MeyerSingleton.hpp>

Static Public Member Functions

static T * instance ()
 

Protected Member Functions

 MeyerSingleton ()=default
 

Constructor & Destructor Documentation

◆ MeyerSingleton()

template<typename T >
openfluid::utils::MeyerSingleton< T >::MeyerSingleton ( )
protecteddefault

Member Function Documentation

◆ instance()

template<typename T >
static T* openfluid::utils::MeyerSingleton< T >::instance ( )
inlinestatic

Returns a pointer to the singleton object. Instantiates the class if it not has not been instantiated before.

Returns
A pointer to the singleton object

The documentation for this class was generated from the following file:
openfluid::utils::MeyerSingleton
Definition: MeyerSingleton.hpp:57
MeyerSingleton.hpp