JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
jevois::Singleton< T > Class Template Reference

#include <jevois/Types/Singleton.H>

template<class T>
class jevois::Singleton< T >

A generic singleton class to enforce a single instance of an object.

The Singleton class should be inherited by any class which needs:

  1. To have only one instance
  2. To be globally accessible

Note that there are currently no guarantees on the order of destruction of Singletons, so care should be taken to never reference another Singleton in the destructor of a Singleton.

This particular implementation is from: http://stackoverflow.com/questions/1008019/c-singleton-design-pattern

The following is an example use of the Singleton:

class MyClass : public Singleton<MyClass>
{
public:
void doIt() {...}
private:
MyClass();
};
int main()
{
...
MyClass::instance().doIt();
...
}
A generic singleton class to enforce a single instance of an object.
Definition Singleton.H:92
int main(int argc, char const *argv[])
Add a new mapping to videomappings.cfg skipping duplicates.
Template Parameters
TThe class that is being made the singleton.

This class was first designed by Rand Voorhies in the Neuromorphic Robotics Toolkit.

Definition at line 91 of file Singleton.H.

Inheritance diagram for jevois::Singleton< T >:

Static Public Member Functions

static T & instance ()
 Get the global, unique instance of the class T.
 

Protected Member Functions

 Singleton ()
 Only classes that inherit from Singleton can construct it via its protected default constructor.
 

Constructor & Destructor Documentation

◆ Singleton()

template<class T >
jevois::Singleton< T >::Singleton ( )
protected

Only classes that inherit from Singleton can construct it via its protected default constructor.

Member Function Documentation

◆ instance()

template<class T >
static T & jevois::Singleton< T >::instance ( )
static

Get the global, unique instance of the class T.

If the global, unique instance of class T has not yet been created, then this method will create it in a thread-safe manner.


The documentation for this class was generated from the following file: