A Discrete-Event Network Simulator
API
ns3::Singleton< T > Class Template Reference

A template singleton. More...

#include <singleton.h>

Static Public Member Functions

static T * Get (void)
 Get a pointer to the singleton instance. More...
 

Private Member Functions

Singleton pattern

Private constructor, copy and assignment operator.

Note these do not have to be implemented, since they are never called.

 Singleton (void)
 Default constructor. More...
 
 Singleton (const Singleton< T > &)
 Copy constructor. More...
 
Singleton< T > operator= (const Singleton< T > &)
 Assignment. More...
 

Detailed Description

template<typename T>
class ns3::Singleton< T >

A template singleton.

This template class can be used to implement the singleton pattern. The underlying object will be destroyed automatically when the process exits.

For a singleton whose lifetime is bounded by the simulation run, not the process, see SimulationSingleton.

Note
If you call Get() again after the object has been destroyed, the object will be re-created which will result in a memory leak as reported by most memory leak checkers. It is up to the user to ensure that Get() is never called from a static variable finalizer.

Definition at line 49 of file singleton.h.

Constructor & Destructor Documentation

template<typename T>
ns3::Singleton< T >::Singleton ( void  )
private

Default constructor.

template<typename T>
ns3::Singleton< T >::Singleton ( const Singleton< T > &  )
private

Copy constructor.

Member Function Documentation

template<typename T>
Singleton<T> ns3::Singleton< T >::operator= ( const Singleton< T > &  )
private

Assignment.

Returns
The Singleton.

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