HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfRegistryManager Class Reference

#include <registryManager.h>

Public Types

typedef void(* RegistrationFunctionType )(void *, void *)
 
typedef std::function< void()> UnloadFunctionType
 

Public Member Functions

template<class T >
void SubscribeTo ()
 
template<class T >
void UnsubscribeFrom ()
 
TF_API bool AddFunctionForUnload (const UnloadFunctionType &)
 

Static Public Member Functions

static TF_API TfRegistryManagerGetInstance ()
 Return the singleton TfRegistryManager instance. More...
 
static TF_API void RunUnloadersAtExit ()
 

Detailed Description

Manage initialization of registries.

See page_tf_RegistryManager for a detailed description.

Definition at line 48 of file registryManager.h.

Member Typedef Documentation

typedef void(* TfRegistryManager::RegistrationFunctionType)(void *, void *)

Definition at line 54 of file registryManager.h.

typedef std::function<void ()> TfRegistryManager::UnloadFunctionType

Definition at line 55 of file registryManager.h.

Member Function Documentation

TF_API bool TfRegistryManager::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 TF_API TfRegistryManager& TfRegistryManager::GetInstance ( )
static

Return the singleton TfRegistryManager instance.

static TF_API void TfRegistryManager::RunUnloadersAtExit ( )
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.

template<class T >
void TfRegistryManager::SubscribeTo ( )
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 68 of file registryManager.h.

template<class T >
void TfRegistryManager::UnsubscribeFrom ( )
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 77 of file registryManager.h.


The documentation for this class was generated from the following file: