#include <singleton.hpp>
|
static std::shared_ptr< T > | get (const std::string &name, Args... args) |
| Retrieves (or creates) the shared instance of type T by name.
|
|
static void | release (const std::string &name) |
| Explicitly removes the named singleton instance from the global map.
|
|
static void | reset () |
| Resets (shuts down) all stored singleton instances.
|
|
static void | set_operational () |
| Ends the shut-down state and allows singletons to be created again.
|
|
◆ singleton()
template<typename T, typename... Args>
Internal constructor. Use get() to create a new instance.
◆ ~singleton()
template<typename T, typename... Args>
◆ get()
template<typename T, typename... Args>
Retrieves (or creates) the shared instance of type T by name.
If _shutdown
is true, returns nullptr
immediately. Otherwise, it either returns the existing instance (if present) or creates a new one.
- Parameters
-
name | Unique name for the resource. |
args | Forwarded constructor arguments for T if a new instance is created. |
- Returns
- A
std::shared_ptr<T>
to the managed resource, or nullptr
if shut down.
- Exceptions
-
◆ release()
template<typename T, typename... Args>
Explicitly removes the named singleton instance from the global map.
If you need a full reset of all singletons, use singleton_control::reset()
.
- Parameters
-
name | Name of the resource to remove. |
◆ release_instance()
template<typename T, typename... Args>
|
inlineoverrideprotectedvirtual |
The documentation for this class was generated from the following file: