7#ifndef PXR_BASE_TF_REGISTRY_MANAGER_H
8#define PXR_BASE_TF_REGISTRY_MANAGER_H
16#include "pxr/base/tf/preprocessorUtilsLite.h"
17#include "pxr/base/tf/api.h"
22PXR_NAMESPACE_OPEN_SCOPE
37 typedef void (*RegistrationFunctionType)(
void*,
void*);
38 typedef std::function<void ()> UnloadFunctionType;
52 _SubscribeTo(
typeid(T));
61 _UnsubscribeFrom(
typeid(T));
102 TF_API
void _SubscribeTo(
const std::type_info&);
103 TF_API
void _UnsubscribeFrom(
const std::type_info&);
106TF_API
void Tf_RegistryInitCtor(
char const *name);
107TF_API
void Tf_RegistryInitDtor(
char const *name);
110struct Tf_RegistryStaticInit {
111 Tf_RegistryStaticInit() {
112 Tf_RegistryInitCtor(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME));
114 ~Tf_RegistryStaticInit() {
115 Tf_RegistryInitDtor(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME));
123class Tf_RegistryInit {
125 TF_API
static void Add(
const char* libName,
126 TfRegistryManager::RegistrationFunctionType func,
127 const char* typeName);
128 template <
class T,
class U>
129 static void Add(
const char* libName,
130 void (*func)(T*, U*),
131 const char* typeName)
133 Add(libName,(TfRegistryManager::RegistrationFunctionType)func,typeName);
138#define TF_REGISTRY_PRIORITY 100
146#define TF_REGISTRY_DEFINE_WITH_TYPE(KEY_TYPE, TAG) \
147 static void _Tf_RegistryFunction(KEY_TYPE*, TAG*); \
148 ARCH_CONSTRUCTOR(TF_PP_CAT(_Tf_RegistryAdd, __LINE__), \
149 TF_REGISTRY_PRIORITY, KEY_TYPE*, TAG*) \
151 Tf_RegistryInit::Add(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME), \
152 (void(*)(KEY_TYPE*, TAG*))_Tf_RegistryFunction, \
153 TF_PP_STRINGIZE(KEY_TYPE)); \
155 _ARCH_ENSURE_PER_LIB_INIT(Tf_RegistryStaticInit, _tfRegistryInit); \
156 static void _Tf_RegistryFunction(KEY_TYPE*, TAG*)
161#define TF_REGISTRY_DEFINE(KEY_TYPE, NAME) \
162 static void TF_PP_CAT(_Tf_RegistryFunction, NAME)(KEY_TYPE*, void*); \
163 ARCH_CONSTRUCTOR(TF_PP_CAT(_Tf_RegistryAdd, NAME), \
164 TF_REGISTRY_PRIORITY, KEY_TYPE*) \
166 Tf_RegistryInit::Add(TF_PP_STRINGIZE(MFB_ALT_PACKAGE_NAME), \
167 (void(*)(KEY_TYPE*, void*)) \
168 TF_PP_CAT(_Tf_RegistryFunction, NAME), \
169 TF_PP_STRINGIZE(KEY_TYPE)); \
171 _ARCH_ENSURE_PER_LIB_INIT(Tf_RegistryStaticInit, _tfRegistryInit); \
172 static void TF_PP_CAT(_Tf_RegistryFunction, NAME)(KEY_TYPE*, void*)
202#define TF_REGISTRY_FUNCTION(KEY_TYPE) \
203 TF_REGISTRY_DEFINE(KEY_TYPE, __LINE__)
243#define TF_REGISTRY_FUNCTION_WITH_TAG(KEY_TYPE, TAG) \
244 TF_REGISTRY_DEFINE(KEY_TYPE, TF_PP_CAT(TAG, __LINE__))
246PXR_NAMESPACE_CLOSE_SCOPE
Define function attributes.
Manage initialization of registries.
TF_API bool AddFunctionForUnload(const UnloadFunctionType &)
Add an action to be performed at code unload time.
static TF_API void RunUnloadersAtExit()
Run unload functions program exit time.
void SubscribeTo()
Request that any initialization for service T be performed.
void UnsubscribeFrom()
Cancel any previous subscriptions to service T.
static TF_API TfRegistryManager & GetInstance()
Return the singleton TfRegistryManager instance.