|
Manage initialization of registries. More...
#include <registryManager.h>
Public Types | |
typedef void(* | RegistrationFunctionType) (void *, void *) |
typedef std::function< void()> | UnloadFunctionType |
Public Member Functions | |
template<class T > | |
void | SubscribeTo () |
Request that any initialization for service T be performed. | |
template<class T > | |
void | UnsubscribeFrom () |
Cancel any previous subscriptions to service T . | |
TF_API bool | AddFunctionForUnload (const UnloadFunctionType &) |
Add an action to be performed at code unload time. | |
Static Public Member Functions | |
static TF_API TfRegistryManager & | GetInstance () |
Return the singleton TfRegistryManager instance. | |
static TF_API void | RunUnloadersAtExit () |
Run unload functions program exit time. | |
Manage initialization of registries.
See The TfRegistryManager Registry Initialization System for a detailed description.
Definition at line 31 of file registryManager.h.
typedef void(* RegistrationFunctionType) (void *, void *) |
Definition at line 37 of file registryManager.h.
typedef std::function<void ()> UnloadFunctionType |
Definition at line 38 of file registryManager.h.
TF_API bool AddFunctionForUnload | ( | const UnloadFunctionType & | ) |
Add an action to be performed at code unload time.
When a TF_REGISTRY_FUNCTION()
is run, it often needs to register an inverse action to be taken when the code containing that function is unloaded. For example, a plugin that adds information to a registry will typically want to remove that information when the registry is unloaded.
Calling AddFunctionForUnload()
requests that the given function be run if the code from which the function is called is unloaded. However, this is detectable only if this call is made from within the call chain of some TF_REGISTRY_FUNCTION()
function. In this case, AddFunctionForUnload()
returns true. Otherwise, false is returned and the function is never run.
Note however that by default, no unload functions are run when code is being unloaded because exit() has been called. This is an optimization, because most registries don't need to be deconstructed at exit time. This behavior can be changed by calling RunUnloadersAtExit()
.
|
static |
Return the singleton TfRegistryManager
instance.
|
static |
Run unload functions program exit time.
The functions added by AddFunctionForUnload()
are normally not run when a program exits. For debugging purposes (e.g. checking for memory leaks) it may be desirable to run the functions even at program exit time. This call will force functions to be run at program exit time.
Note that this call does not cause construction of the singleton TfRegistryManager
object if it does not already exist.
|
inline |
Request that any initialization for service T
be performed.
Calling SubscribeTo<T>()
causes all existing TF_REGISTRY_FUNCTION()
functions of type T
to be run. Once this call is made, when new code is dynamically loaded then any TF_REGISTRY_FUNCTION()
functions of type T
in the new code will automatically be run when the code is loaded.
Definition at line 51 of file registryManager.h.
|
inline |
Cancel any previous subscriptions to service T
.
After this call, newly added code will no longer have TF_REGISTRY_FUNCTION()
functions of type T
run.
Definition at line 60 of file registryManager.h.