31#ifndef ETL_SINGLETON_INCLUDED
32#define ETL_SINGLETON_INCLUDED
54 :
exception(reason_, file_name_, line_number_)
67 :
singleton_exception(ETL_ERROR_TEXT(
"singleton:not created", ETL_SINGLETON_FILE_ID
"A"), file_name_, line_number_)
72#if ETL_USING_CPP11 && !defined(ETL_SINGLETON_FORCE_CPP03_IMPLEMENTATION)
87 template <
typename... TArgs>
88 static void create(TArgs&&... args)
90 Data& data = get_data();
94 T* p = data.storage.begin();
95 ::new (p) T(etl::forward<TArgs>(args)...);
105 Data& data = get_data();
109 T* p = data.storage.begin();
122 Data& data = get_data();
126 return *data.storage.begin();
134 Data& data = get_data();
158 static Data& get_data()
166 singleton() =
delete;
167 singleton(
const singleton&) =
delete;
168 singleton& operator =(
const singleton&) =
delete;
187 Data& data = get_data();
191 T* p = data.storage.begin();
201 template <
typename T1>
204 Data& data = get_data();
208 T* p = data.storage.begin();
218 template <
typename T1,
typename T2>
219 static void create(
const T1& p1,
const T2& p2)
221 Data& data = get_data();
225 T* p = data.storage.begin();
235 template <
typename T1,
typename T2,
typename T3>
236 static void create(
const T1& p1,
const T2& p2,
const T3& p3)
238 Data& data = get_data();
242 T* p = data.storage.begin();
243 ::new (p) T(p1, p2, p3);
252 template <
typename T1,
typename T2,
typename T3,
typename T4>
253 static void create(
const T1& p1,
const T2& p2,
const T3& p3,
const T4& p4)
255 Data& data = get_data();
259 T* p = data.storage.begin();
260 ::new (p) T(p1, p2, p3, p4);
270 Data& data = get_data();
274 T* p = data.storage.begin();
287 Data& data = get_data();
291 return *data.storage.begin();
299 Data& data = get_data();
320 static Data& get_data()
329 singleton(
const singleton&);
330 singleton& operator =(
const singleton&);
Base singleton error exception.
Definition: singleton.h:50
Singleton not created error exception.
Definition: singleton.h:63
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
ETL_CONSTEXPR exception(string_type reason_, string_type, numeric_type line_)
Constructor.
Definition: exception.h:69
Definition: exception.h:47
static void create(const T1 &p1, const T2 &p2, const T3 &p3)
Definition: singleton.h:236
static void create(const T1 &p1, const T2 &p2, const T3 &p3, const T4 &p4)
Definition: singleton.h:253
static void create()
Constructs the instance of the singleton type.
Definition: singleton.h:185
static bool is_valid()
Checks the validity of the singleton.
Definition: singleton.h:297
static void create(const T1 &p1)
Definition: singleton.h:202
static void destroy()
Destructs the instance of the singleton type.
Definition: singleton.h:268
static void create(const T1 &p1, const T2 &p2)
Definition: singleton.h:219
static T & instance()
Definition: singleton.h:285
Creates .
Definition: singleton.h:43
bitset_ext
Definition: absolute.h:38