24 #ifndef PXR_BASE_TF_REGISTRY_MANAGER_H 25 #define PXR_BASE_TF_REGISTRY_MANAGER_H 33 #include "pxr/base/tf/preprocessorUtilsLite.h" 34 #include "pxr/base/tf/api.h" 39 PXR_NAMESPACE_OPEN_SCOPE
54 typedef void (*RegistrationFunctionType)(
void*,
void*);
55 typedef std::function<void ()> UnloadFunctionType;
69 _SubscribeTo(
typeid(T));
78 _UnsubscribeFrom(
typeid(T));
119 TF_API
void _SubscribeTo(
const std::type_info&);
120 TF_API
void _UnsubscribeFrom(
const std::type_info&);
123 TF_API
void Tf_RegistryInitCtor(
char const *name);
124 TF_API
void Tf_RegistryInitDtor(
char const *name);
127 struct Tf_RegistryStaticInit {
128 Tf_RegistryStaticInit() {
129 Tf_RegistryInitCtor(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME));
131 ~Tf_RegistryStaticInit() {
132 Tf_RegistryInitDtor(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME));
140 class Tf_RegistryInit {
142 TF_API
static void Add(
const char* libName,
143 TfRegistryManager::RegistrationFunctionType func,
144 const char* typeName);
145 template <
class T,
class U>
146 static void Add(
const char* libName,
147 void (*func)(T*, U*),
148 const char* typeName)
150 Add(libName,(TfRegistryManager::RegistrationFunctionType)func,typeName);
155 #define TF_REGISTRY_PRIORITY 100 163 #define TF_REGISTRY_DEFINE_WITH_TYPE(KEY_TYPE, TAG) \ 164 static void _Tf_RegistryFunction(KEY_TYPE*, TAG*); \ 165 ARCH_CONSTRUCTOR(TF_PP_CAT(_Tf_RegistryAdd, __LINE__), \ 166 TF_REGISTRY_PRIORITY, KEY_TYPE*, TAG*) \ 168 Tf_RegistryInit::Add(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME), \ 169 (void(*)(KEY_TYPE*, TAG*))_Tf_RegistryFunction, \ 170 TF_PP_STRINGIZE(KEY_TYPE)); \ 172 _ARCH_ENSURE_PER_LIB_INIT(Tf_RegistryStaticInit, _tfRegistryInit); \ 173 static void _Tf_RegistryFunction(KEY_TYPE*, TAG*) 178 #define TF_REGISTRY_DEFINE(KEY_TYPE, NAME) \ 179 static void TF_PP_CAT(_Tf_RegistryFunction, NAME)(KEY_TYPE*, void*); \ 180 ARCH_CONSTRUCTOR(TF_PP_CAT(_Tf_RegistryAdd, NAME), \ 181 TF_REGISTRY_PRIORITY, KEY_TYPE*) \ 183 Tf_RegistryInit::Add(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME), \ 184 (void(*)(KEY_TYPE*, void*)) \ 185 TF_PP_CAT(_Tf_RegistryFunction, NAME), \ 186 TF_PP_STRINGIZE(KEY_TYPE)); \ 188 _ARCH_ENSURE_PER_LIB_INIT(Tf_RegistryStaticInit, _tfRegistryInit); \ 189 static void TF_PP_CAT(_Tf_RegistryFunction, NAME)(KEY_TYPE*, void*) 219 #define TF_REGISTRY_FUNCTION(KEY_TYPE) \ 220 TF_REGISTRY_DEFINE(KEY_TYPE, __LINE__) 260 #define TF_REGISTRY_FUNCTION_WITH_TAG(KEY_TYPE, TAG) \ 261 TF_REGISTRY_DEFINE(KEY_TYPE, TF_PP_CAT(TAG, __LINE__)) 263 PXR_NAMESPACE_CLOSE_SCOPE
265 #endif // PXR_BASE_TF_REGISTRY_MANAGER_H static TF_API TfRegistryManager & GetInstance()
Return the singleton TfRegistryManager instance.
TF_API bool AddFunctionForUnload(const UnloadFunctionType &)
Add an action to be performed at code unload time.
Define function attributes.
void UnsubscribeFrom()
Cancel any previous subscriptions to service T.
void SubscribeTo()
Request that any initialization for service T be performed.
static TF_API void RunUnloadersAtExit()
Run unload functions program exit time.
Manage initialization of registries.