A Discrete-Event Network Simulator
API
Static Public Member Functions | Static Private Member Functions | List of all members
ns3::SimulationSingleton< T > Class Template Reference

This singleton class template ensures that the type for which we want a singleton has a lifetime bounded by the simulation run lifetime. More...

#include "simulation-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.

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

Static Private Member Functions

static void DeleteObject (void)
 Delete the static instance. More...
 
static T ** GetObject (void)
 Get the singleton object, creating a new one if it doesn't exist yet. More...
 

Detailed Description

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

This singleton class template ensures that the type for which we want a singleton has a lifetime bounded by the simulation run lifetime.

That it, the underlying type will be automatically deleted upon a call to Simulator::Destroy.

For a singleton with a lifetime bounded by the process, not the simulation run, see Singleton.

Definition at line 43 of file simulation-singleton.h.

Constructor & Destructor Documentation

◆ SimulationSingleton() [1/2]

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

Default constructor.

◆ SimulationSingleton() [2/2]

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

Copy constructor.

Member Function Documentation

◆ DeleteObject()

template<typename T >
void ns3::SimulationSingleton< T >::DeleteObject ( void  )
staticprivate

Delete the static instance.

Definition at line 128 of file simulation-singleton.h.

◆ Get()

template<typename T >
T * ns3::SimulationSingleton< T >::Get ( void  )
static

◆ GetObject()

template<typename T >
T ** ns3::SimulationSingleton< T >::GetObject ( void  )
staticprivate

Get the singleton object, creating a new one if it doesn't exist yet.

Internal:
When a new object is created, this method schedules it's own destruction using Simulator::ScheduleDestroy().
Returns
The address of the pointer holding the static instance.

Definition at line 115 of file simulation-singleton.h.

References ns3::Simulator::ScheduleDestroy().

◆ operator=()

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

Assignment.

Returns
The Singleton.

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