|
Go to the source code of this file.
Classes | |
class | TfRegistryManager |
Manage initialization of registries. More... | |
Macros | |
#define | TF_REGISTRY_PRIORITY 100 |
#define | TF_REGISTRY_DEFINE_WITH_TYPE(KEY_TYPE, TAG) |
#define | TF_REGISTRY_DEFINE(KEY_TYPE, NAME) |
#define | TF_REGISTRY_FUNCTION(KEY_TYPE) |
Define a function that is called on demand by TfRegistryManager . | |
#define | TF_REGISTRY_FUNCTION_WITH_TAG(KEY_TYPE, TAG) |
Define a function that is called on demand by TfRegistryManager . | |
#define TF_REGISTRY_DEFINE | ( | KEY_TYPE, | |
NAME | |||
) |
Definition at line 161 of file registryManager.h.
#define TF_REGISTRY_DEFINE_WITH_TYPE | ( | KEY_TYPE, | |
TAG | |||
) |
Definition at line 146 of file registryManager.h.
#define TF_REGISTRY_FUNCTION | ( | KEY_TYPE | ) |
Define a function that is called on demand by TfRegistryManager
.
This is a simpler form of TF_REGISTRY_FUNCTION_WITH_TAG() that provides a tag for you, based on the MFB package, file name, and line number being compiled. For most cases (private registry functions inside .cpp files) this should do.
A very common use is to symbolically define enum names (see TfEnum
):
Definition at line 202 of file registryManager.h.
#define TF_REGISTRY_FUNCTION_WITH_TAG | ( | KEY_TYPE, | |
TAG | |||
) |
Define a function that is called on demand by TfRegistryManager
.
Here is an example of using this macro:
Given the above, a call to TfRegistryManager::SubscribeTo<XyzRegistry>()
will cause the above function to be immediately run. (If the above function has not yet been loaded, but is loaded in the future, it will be run then.) The second type, MyType
, is unimportant, but cannot be repeated with the first type (i.e. there can be at most one call to TF_REGISTRY_FUNCTION()
for a given pair of types).
In contrast to the typical static-constructor design, the code within a TF_REGISTRY_FUNCTION() function is (usually) not run before main(); specifically, it is not run unless and until a call to SubscribeTo<T>() occurs. This is important: if there are no subscribers, the code may never be run.
Note two restrictions: the type-names KEY_TYPE
and TAG
passed to this macro must be untemplated, and not qualified with a namespace. (Translation: the name as given must consist solely of letters and numbers: no "\<", "\>" or ":" characters are allowed.) KEY_TYPE may be inside a namespace but must not be explicitly qualified; you must use 'using namespace <foo>::KEY_TYPE' before calling this macro. Every use of TF_REGISTRY_FUNCTION()
must use a different pair for KEY_TYPE
and TAG
or a multiply defined symbol will result at link time. Note that this means the same KEY_TYPE in two or more namespaces may not be registered in more than one namespace.
Definition at line 243 of file registryManager.h.
#define TF_REGISTRY_PRIORITY 100 |
Definition at line 138 of file registryManager.h.