A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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"

Public Member Functions

 SimulationSingleton ()=delete
 
 SimulationSingleton (const SimulationSingleton< T > &)=delete
 
SimulationSingletonoperator= (const SimulationSingleton< T > &)=delete
 

Static Public Member Functions

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

Static Private Member Functions

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

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 32 of file simulation-singleton.h.

Constructor & Destructor Documentation

◆ SimulationSingleton() [1/2]

template<typename T>
ns3::SimulationSingleton< T >::SimulationSingleton ( )
delete

Referenced by SimulationSingleton(), and operator=().

+ Here is the caller graph for this function:

◆ SimulationSingleton() [2/2]

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

References SimulationSingleton().

+ Here is the call graph for this function:

Member Function Documentation

◆ DeleteObject()

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

Delete the static instance.

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

References GetObject().

Referenced by GetObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Get()

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

Get a pointer to the singleton instance.

This instance will be automatically deleted when the simulation is destroyed by a call to Simulator::Destroy.

Returns
A pointer to the singleton instance.

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

References GetObject().

Referenced by ns3::Ipv4AddressGenerator::AddAllocated(), ns3::Ipv6AddressGenerator::AddAllocated(), ns3::GlobalRouteManager::BuildGlobalRoutingDatabase(), ns3::GlobalRouteManager::DeleteGlobalRoutes(), ns3::Ipv4AddressGenerator::GetAddress(), ns3::Ipv6AddressGenerator::GetAddress(), ns3::Ipv4AddressGenerator::GetNetwork(), ns3::Ipv6AddressGenerator::GetNetwork(), ns3::Ipv4AddressGenerator::Init(), ns3::Ipv6AddressGenerator::Init(), ns3::Ipv4AddressGenerator::InitAddress(), ns3::Ipv6AddressGenerator::InitAddress(), ns3::GlobalRouteManager::InitializeRoutes(), ns3::Ipv4AddressGenerator::IsAddressAllocated(), ns3::Ipv6AddressGenerator::IsAddressAllocated(), ns3::Ipv4AddressGenerator::IsNetworkAllocated(), ns3::Ipv6AddressGenerator::IsNetworkAllocated(), ns3::Ipv4AddressGenerator::NextAddress(), ns3::Ipv6AddressGenerator::NextAddress(), ns3::Ipv4AddressGenerator::NextNetwork(), ns3::Ipv6AddressGenerator::NextNetwork(), ns3::Ipv4AddressGenerator::Reset(), ns3::Ipv6AddressGenerator::Reset(), ns3::Ipv4AddressGenerator::TestMode(), and ns3::Ipv6AddressGenerator::TestMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetObject()

template<typename T>
T ** ns3::SimulationSingleton< T >::GetObject ( )
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 87 of file simulation-singleton.h.

References DeleteObject(), and ns3::Simulator::ScheduleDestroy().

Referenced by DeleteObject(), and Get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

References SimulationSingleton().

+ Here is the call graph for this function:

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