A template singleton. More...
#include "singleton.h"
Inheritance diagram for ns3::Singleton< T >:
Collaboration diagram for ns3::Singleton< T >:Static Public Member Functions | |
| static T * | Get (void) |
| Get a pointer to the singleton instance. More... | |
Additional Inherited Members | |
Private Member Functions inherited from ns3::NonCopyable | |
| NonCopyable () | |
| Constructor. More... | |
| ~NonCopyable () | |
| Destructor. More... | |
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.
To force your class ExampleS to be a singleton, inherit from Singleton:
Then, to reach the singleton instance, just do
Definition at line 63 of file singleton.h.
|
static |
Get a pointer to the singleton instance.
The instance will be automatically deleted when the process exits.
Definition at line 89 of file singleton.h.