18 #ifndef itkSingleton_h
19 #define itkSingleton_h
26 #ifndef ITK_FUTURE_LEGACY_REMOVE
35 [[deprecated(
"Preferably use the C++ `[[maybe_unused]]` attribute instead!")]]
inline void
54 #ifndef ITK_LEGACY_REMOVE
55 using SingletonData [[deprecated(
"The internal representation of the singleton data is private, and may not "
56 "correspond with SingletonData anymore.")]] =
57 std::map<std::string, std::tuple<
void *, std::function<void(
void *)>, std::function<void()>>>;
66 return static_cast<T *>(this->GetGlobalInstancePrivate(globalName));
76 this->SetGlobalInstancePrivate(globalName,
GlobalObject{ global, std::move(deleteFunc) });
79 #ifndef ITK_FUTURE_LEGACY_REMOVE
81 [[deprecated(
"Prefer calling the SetGlobalInstance(globalName, global, deleteFunc) overload (without the unused func "
83 SetGlobalInstance(
const char * globalName,
85 std::function<
void(
void *)> itkNotUsed(func),
86 std::function<
void()> deleteFunc)
88 this->SetGlobalInstance(globalName, global, std::move(deleteFunc));
99 SetInstance(
Self * instance);
108 std::function<void()> DeleteFunc{};
118 GetGlobalInstancePrivate(
const char * globalName);
122 SetGlobalInstancePrivate(
const char * globalName, GlobalObject globalObject);
135 template <
typename T>
137 Singleton(
const char * globalName, std::function<
void()> deleteFunc)
141 if (instance ==
nullptr)
150 #ifndef ITK_FUTURE_LEGACY_REMOVE
151 template <
typename T>
152 [[deprecated(
"Prefer calling the Singleton(globalName, deleteFunc) overload (without the unused func parameter)!")]] T *
153 Singleton(
const char * globalName, std::function<
void(
void *)> itkNotUsed(func), std::function<
void()> deleteFunc)
155 return Singleton<T>(globalName, std::move(deleteFunc));