HDK
|
#include "pxr/pxr.h"
#include "pxr/base/tf/preprocessorUtils.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"
#include "pxr/base/tf/staticData.h"
#include "pxr/base/tf/token.h"
#include <vector>
#include <hboost/preprocessor/cat.hpp>
#include <hboost/preprocessor/control/iif.hpp>
#include <hboost/preprocessor/control/expr_iif.hpp>
#include <hboost/preprocessor/logical/and.hpp>
#include <hboost/preprocessor/logical/not.hpp>
#include <hboost/preprocessor/punctuation/comma_if.hpp>
#include <hboost/preprocessor/seq/filter.hpp>
#include <hboost/preprocessor/seq/for_each.hpp>
#include <hboost/preprocessor/seq/for_each_i.hpp>
#include <hboost/preprocessor/seq/size.hpp>
#include <hboost/preprocessor/seq/push_back.hpp>
#include <hboost/preprocessor/tuple/elem.hpp>
Go to the source code of this file.
This file defines some macros that are useful for declaring and using static TfTokens. Typically, using static TfTokens is either cumbersome, unsafe, or slow. These macros aim to solve many of the common problems.
The following is an example of how they can be used.
In header file:
In cpp file:
Access the token by using the key as though it were a pointer, like this:
An additional member, allTokens, is a std::vector<TfToken> populated with all of the generated token members.
There are PUBLIC and PRIVATE versions of the macros. The PRIVATE ones are intended to be used when the tokens will only be used in a single .cpp file, in which case they can be made file static. In the case of the PRIVATE, you only need to use the DEFINE macro.
Definition in file staticTokens.h.
#define _TF_DECLARE_PUBLIC_TOKENS | ( | N | ) | _TF_DECLARE_PUBLIC_TOKENS##N |
Definition at line 111 of file staticTokens.h.
#define _TF_DECLARE_PUBLIC_TOKENS2 | ( | key, | |
seq | |||
) |
Definition at line 108 of file staticTokens.h.
#define _TF_DECLARE_PUBLIC_TOKENS3 | ( | key, | |
eiapi, | |||
seq | |||
) |
Definition at line 105 of file staticTokens.h.
#define _TF_DECLARE_PUBLIC_TOKENS_EVAL | ( | N | ) | _TF_DECLARE_PUBLIC_TOKENS(N) |
Definition at line 112 of file staticTokens.h.
Definition at line 113 of file staticTokens.h.
#define _TF_DECLARE_TOKENS2 | ( | key, | |
seq | |||
) |
Definition at line 202 of file staticTokens.h.
#define _TF_DECLARE_TOKENS3 | ( | key, | |
seq, | |||
eiapi | |||
) |
Definition at line 195 of file staticTokens.h.
#define _TF_DEFINE_TOKENS | ( | key, | |
seq | |||
) |
Definition at line 282 of file staticTokens.h.
#define _TF_TOKENS_APPEND_ARRAY_ELEMENTS | ( | r, | |
data, | |||
elem | |||
) | HBOOST_PP_TUPLE_ELEM(1, 0, HBOOST_PP_TUPLE_ELEM(2, 1, elem)) |
Definition at line 270 of file staticTokens.h.
Definition at line 233 of file staticTokens.h.
Definition at line 239 of file staticTokens.h.
#define _TF_TOKENS_ASSIGN_ARRAY_SEQ | ( | seq | ) | HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_DEFINE_ARRAY_MEMBERS, ~, seq) |
Definition at line 250 of file staticTokens.h.
#define _TF_TOKENS_BUILD_ALLTOKENS_VECTOR | ( | seq | ) | HBOOST_PP_SEQ_FOR_EACH_I(_TF_TOKENS_APPEND_MEMBER, ~, seq) |
Definition at line 242 of file staticTokens.h.
Definition at line 171 of file staticTokens.h.
#define _TF_TOKENS_DECLARE_MEMBERS | ( | seq | ) |
Definition at line 180 of file staticTokens.h.
Definition at line 227 of file staticTokens.h.
Definition at line 253 of file staticTokens.h.
Definition at line 214 of file staticTokens.h.
#define _TF_TOKENS_EXPAND_ARRAY_ELEMENTS | ( | seq | ) |
Definition at line 188 of file staticTokens.h.
#define _TF_TOKENS_INITIALIZE_MEMBER | ( | elem | ) | elem(TF_PP_STRINGIZE(elem), TfToken::Immortal) |
Definition at line 224 of file staticTokens.h.
#define _TF_TOKENS_INITIALIZE_MEMBER_TUPLE | ( | elem | ) |
Definition at line 220 of file staticTokens.h.
#define _TF_TOKENS_INITIALIZE_SEQ | ( | seq | ) | HBOOST_PP_SEQ_FOR_EACH_I(_TF_TOKENS_DEFINE_MEMBER, ~, seq) |
Definition at line 247 of file staticTokens.h.
Definition at line 261 of file staticTokens.h.
#define _TF_TOKENS_IS_NOT_ARRAY | ( | s, | |
data, | |||
elem | |||
) | HBOOST_PP_NOT(_TF_TOKENS_IS_ARRAY(s, data, elem)) |
Definition at line 265 of file staticTokens.h.
#define _TF_TOKENS_STRUCT_NAME | ( | key | ) | HBOOST_PP_CAT(key, _StaticTokenType) |
Definition at line 162 of file staticTokens.h.
#define _TF_TOKENS_STRUCT_NAME_PRIVATE | ( | key | ) | HBOOST_PP_CAT(key, _PrivateStaticTokenType) |
Definition at line 155 of file staticTokens.h.
#define TF_DECLARE_PUBLIC_TOKENS | ( | ... | ) |
Macro to define public tokens. This declares a list of tokens that can be used globally. Use in conjunction with TF_DEFINE_PUBLIC_TOKENS.
Definition at line 118 of file staticTokens.h.
#define TF_DEFINE_PRIVATE_TOKENS | ( | key, | |
seq | |||
) |
Macro to define private tokens.
Definition at line 129 of file staticTokens.h.
#define TF_DEFINE_PUBLIC_TOKENS | ( | key, | |
seq | |||
) |
Macro to define public tokens. Use in conjunction with TF_DECLARE_PUBLIC_TOKENS.
Definition at line 123 of file staticTokens.h.