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
53 #ifndef ITK_LEGACY_REMOVE
54 using SingletonData [[deprecated(
"The internal representation of the singleton data is private, and may not "
55 "correspond with SingletonData anymore.")]] =
56 std::map<std::string, std::tuple<
void *, std::function<void(
void *)>, std::function<void()>>>;
65 return static_cast<T *>(this->GetGlobalInstancePrivate(globalName));
75 this->SetGlobalInstancePrivate(globalName,
GlobalObject{ global, std::move(deleteFunc) });
78 #ifndef ITK_FUTURE_LEGACY_REMOVE
80 [[deprecated(
"Prefer calling the SetGlobalInstance(globalName, global, deleteFunc) overload (without the unused func "
82 SetGlobalInstance(
const char * globalName,
84 std::function<
void(
void *)> itkNotUsed(func),
85 std::function<
void()> deleteFunc)
87 this->SetGlobalInstance(globalName, global, std::move(deleteFunc));
98 SetInstance(
Self * instance);
107 std::function<void()> DeleteFunc{};
117 GetGlobalInstancePrivate(
const char * globalName);
121 SetGlobalInstancePrivate(
const char * globalName, GlobalObject globalObject);
134 template <
typename T>
136 Singleton(
const char * globalName, std::function<
void()> deleteFunc)
140 if (instance ==
nullptr)
149 #ifndef ITK_FUTURE_LEGACY_REMOVE
150 template <
typename T>
151 [[deprecated(
"Prefer calling the Singleton(globalName, deleteFunc) overload (without the unused func parameter)!")]] T *
152 Singleton(
const char * globalName, std::function<
void(
void *)> itkNotUsed(func), std::function<
void()> deleteFunc)
154 return Singleton<T>(globalName, std::move(deleteFunc));