ORIGINAL
|
Thread-safe singleton pattern implementation with ownership management. More...
#include <singleton.h>
Public Member Functions | |
singleton (const singleton &)=delete | |
Deleted copy constructor to prevent copying. | |
singleton & | operator= (const singleton &)=delete |
Deleted copy assignment operator to prevent copying. | |
singleton (singleton &&)=delete | |
Deleted move constructor to prevent moving. | |
singleton & | operator= (singleton &&)=delete |
Deleted move assignment operator to prevent moving. | |
Static Public Member Functions | |
static bool | exist () |
Checks if the singleton instance exists. | |
template<typename... Args> | |
static void | init (Args &&... args) |
Initializes the singleton instance with provided arguments. | |
static TYPE & | instance () |
Provides access to the singleton instance. | |
static void | clear () |
Clears the singleton instance. | |
template<typename... Args> | |
static void | reset (Args &&... args) |
Resets the singleton instance with new arguments. | |
Thread-safe singleton pattern implementation with ownership management.
TYPE | Type of the singleton instance |
Provides a global point of access to a single instance of TYPE while ensuring proper initialization, destruction, and ownership semantics. Uses ownerPtr for exclusive ownership and automatic cleanup.
Key Features:
|
static |
Clears the singleton instance.
|
static |
Checks if the singleton instance exists.
|
static |
Initializes the singleton instance with provided arguments.
Args | Argument types for TYPE constructor |
args | Arguments to forward to TYPE constructor |
valueError | if instance already exists |
|
static |
Provides access to the singleton instance.
nullPointerError | if instance not initialized |
|
static |
Resets the singleton instance with new arguments.
Args | Argument types for TYPE constructor |
args | Arguments to forward to TYPE constructor |