HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
staticTokens.h File Reference
#include "pxr/pxr.h"
#include "pxr/base/tf/preprocessorUtilsLite.h"
#include "pxr/base/tf/staticData.h"
#include "pxr/base/tf/token.h"
#include <vector>
#include <hboost/preprocessor/seq/enum.hpp>
#include <hboost/preprocessor/seq/filter.hpp>
#include <hboost/preprocessor/seq/for_each.hpp>
+ Include dependency graph for staticTokens.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _TF_DECLARE_PUBLIC_TOKENS3(key, eiapi, seq)
 
#define _TF_DECLARE_PUBLIC_TOKENS2(key, seq)
 
#define _TF_DECLARE_PUBLIC_TOKENS(N)   _TF_DECLARE_PUBLIC_TOKENS##N
 
#define _TF_DECLARE_PUBLIC_TOKENS_EVAL(N)   _TF_DECLARE_PUBLIC_TOKENS(N)
 
#define _TF_DECLARE_PUBLIC_TOKENS_EXPAND(x)   x
 
#define TF_DECLARE_PUBLIC_TOKENS(...)
 
#define TF_DEFINE_PUBLIC_TOKENS(key, seq)
 
#define TF_DEFINE_PRIVATE_TOKENS(key, seq)
 
#define _TF_TOKENS_STRUCT_NAME_PRIVATE(key)   TF_PP_CAT(key, _PrivateStaticTokenType)
 
#define _TF_TOKENS_STRUCT_NAME(key)   TF_PP_CAT(key, _StaticTokenType)
 
#define _TF_TOKENS_DECLARE_MEMBER(unused, elem)
 
#define _TF_TOKENS_DECLARE_TOKEN_MEMBERS(seq)   TF_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_MEMBER, ~, seq)
 
#define _TF_TOKENS_FORWARD_ARRAY(elem)   TF_PP_TUPLE_ELEM(0, elem),
 
#define _TF_TOKENS_DECLARE_ARRAY_MEMBER_IMPL(identifier,...)
 
#define _TF_TOKENS_DECLARE_ARRAY_MEMBER(r, data, elem)
 
#define _TF_TOKENS_DECLARE_ARRAY_MEMBERS(seq)   HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_ARRAY_MEMBER, ~, seq)
 
#define _TF_TOKENS_FORWARD_TOKEN(unused, elem)   TF_PP_TUPLE_ELEM(0, elem),
 
#define _TF_TOKENS_DECLARE_ALL_TOKENS(seq)
 
#define _TF_TOKENS_DECLARE_MEMBERS(seq)
 
#define _TF_TOKENS_EXPAND_ARRAY_ELEMENTS(seq)
 
#define _TF_DECLARE_TOKENS3(key, seq, eiapi)
 
#define _TF_DECLARE_TOKENS2(key, seq)
 
#define _TF_TOKENS_IS_ARRAY(s, data, elem)
 
#define _TF_TOKENS_IS_NOT_ARRAY(s, data, elem)   _TF_PP_IFF(_TF_TOKENS_IS_ARRAY(s, data, elem), 0, 1)
 
#define _TF_TOKENS_APPEND_ARRAY_ELEMENTS(r, data, elem)   TF_PP_TUPLE_ELEM(0, TF_PP_TUPLE_ELEM(1, elem))
 
#define _TF_DEFINE_TOKENS(key)
 

Detailed Description

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:

#define MF_TOKENS \. <--- please ignore '.'
(transform) \.
(moves) \.
// Syntax when string name differs from symbol.
((foo, "bar"))
// Syntax when defining an array of tokens. Note that the tokens can
// be used either with amountTs[i] or directly as tx, ty, tz.
((amountTs, ( (tx) (ty) (tz) )))
TF_DECLARE_PUBLIC_TOKENS(MfTokens, MF_TOKENS);

In cpp file:

TF_DEFINE_PUBLIC_TOKENS(MfTokens, MF_TOKENS);

Access the token by using the key as though it were a pointer, like this:

MfTokens->transform;

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.

Macro Definition Documentation

#define _TF_DECLARE_PUBLIC_TOKENS (   N)    _TF_DECLARE_PUBLIC_TOKENS##N

Definition at line 101 of file staticTokens.h.

#define _TF_DECLARE_PUBLIC_TOKENS2 (   key,
  seq 
)
Value:
#define _TF_DECLARE_TOKENS2(key, seq)
Definition: staticTokens.h:207

Definition at line 98 of file staticTokens.h.

#define _TF_DECLARE_PUBLIC_TOKENS3 (   key,
  eiapi,
  seq 
)
Value:
_TF_DECLARE_TOKENS3(key, seq, eiapi) \
#define _TF_DECLARE_TOKENS3(key, seq, eiapi)
Definition: staticTokens.h:200

Definition at line 95 of file staticTokens.h.

#define _TF_DECLARE_PUBLIC_TOKENS_EVAL (   N)    _TF_DECLARE_PUBLIC_TOKENS(N)

Definition at line 102 of file staticTokens.h.

#define _TF_DECLARE_PUBLIC_TOKENS_EXPAND (   x)    x

Definition at line 103 of file staticTokens.h.

#define _TF_DECLARE_TOKENS2 (   key,
  seq 
)
Value:
struct _TF_TOKENS_STRUCT_NAME(key) { \
~_TF_TOKENS_STRUCT_NAME(key)(); \
};
#define _TF_TOKENS_STRUCT_NAME(key)
Definition: staticTokens.h:142
#define _TF_TOKENS_DECLARE_MEMBERS(seq)
Definition: staticTokens.h:178

Definition at line 207 of file staticTokens.h.

#define _TF_DECLARE_TOKENS3 (   key,
  seq,
  eiapi 
)
Value:
struct _TF_TOKENS_STRUCT_NAME(key) { \
eiapi _TF_TOKENS_STRUCT_NAME(key)(); \
eiapi ~_TF_TOKENS_STRUCT_NAME(key)(); \
};
#define _TF_TOKENS_STRUCT_NAME(key)
Definition: staticTokens.h:142
#define _TF_TOKENS_DECLARE_MEMBERS(seq)
Definition: staticTokens.h:178

Definition at line 200 of file staticTokens.h.

#define _TF_DEFINE_TOKENS (   key)
Value:
#define _TF_TOKENS_STRUCT_NAME(key)
Definition: staticTokens.h:142

Definition at line 237 of file staticTokens.h.

#define _TF_TOKENS_APPEND_ARRAY_ELEMENTS (   r,
  data,
  elem 
)    TF_PP_TUPLE_ELEM(0, TF_PP_TUPLE_ELEM(1, elem))

Definition at line 229 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_ALL_TOKENS (   seq)
Value:
std::vector<TfToken> allTokens = \
#define _TF_TOKENS_FORWARD_TOKEN(unused, elem)
Definition: staticTokens.h:171
#define TF_PP_SEQ_FOR_EACH(_macro, data, seq)

Definition at line 172 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_ARRAY_MEMBER (   r,
  data,
  elem 
)
Value:
TF_PP_TUPLE_ELEM(0, elem), \
HBOOST_PP_SEQ_ENUM(TF_PP_EAT_PARENS(TF_PP_TUPLE_ELEM(1, elem))))
#define TF_PP_TUPLE_ELEM(index, tuple)
Expands to the 'index' element of a non-empty 'tuple'.
#define TF_PP_EAT_PARENS(...)
#define _TF_TOKENS_DECLARE_ARRAY_MEMBER_IMPL(identifier,...)
Definition: staticTokens.h:161

Definition at line 164 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_ARRAY_MEMBER_IMPL (   identifier,
  ... 
)
Value:
TfToken identifier[TF_PP_VARIADIC_SIZE(__VA_ARGS__)] = { \
#define TF_PP_VARIADIC_SIZE(...)
Definition: token.h:87
#define TF_PP_FOR_EACH(x,...)
#define _TF_TOKENS_FORWARD_ARRAY(elem)
Definition: staticTokens.h:160

Definition at line 161 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_ARRAY_MEMBERS (   seq)    HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_ARRAY_MEMBER, ~, seq)

Definition at line 168 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_MEMBER (   unused,
  elem 
)
Value:
TF_PP_TUPLE_ELEM(0, elem), elem){ \
#define TF_PP_STRINGIZE(x)
Expand and convert the argument to a string, using a most minimal macro.
#define _TF_PP_IFF(c, t, f)
#define TF_PP_IS_TUPLE(arg)
Definition: token.h:87
#define TF_PP_TUPLE_ELEM(index, tuple)
Expands to the 'index' element of a non-empty 'tuple'.

Definition at line 151 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_MEMBERS (   seq)
Value:
HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_NOT_ARRAY, ~, seq) \
) \
HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_ARRAY, ~, seq)) \
HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_NOT_ARRAY, ~, seq) \
)
#define _TF_TOKENS_IS_NOT_ARRAY(s, data, elem)
Definition: staticTokens.h:224
#define _TF_TOKENS_DECLARE_TOKEN_MEMBERS(seq)
Definition: staticTokens.h:157
#define _TF_TOKENS_IS_ARRAY(s, data, elem)
Definition: staticTokens.h:220
#define _TF_TOKENS_DECLARE_ARRAY_MEMBERS(seq)
Definition: staticTokens.h:168
#define _TF_TOKENS_DECLARE_ALL_TOKENS(seq)
Definition: staticTokens.h:172
#define _TF_TOKENS_EXPAND_ARRAY_ELEMENTS(seq)
Definition: staticTokens.h:193

Definition at line 178 of file staticTokens.h.

#define _TF_TOKENS_DECLARE_TOKEN_MEMBERS (   seq)    TF_PP_SEQ_FOR_EACH(_TF_TOKENS_DECLARE_MEMBER, ~, seq)

Definition at line 157 of file staticTokens.h.

#define _TF_TOKENS_EXPAND_ARRAY_ELEMENTS (   seq)
Value:
HBOOST_PP_SEQ_FOR_EACH(_TF_TOKENS_APPEND_ARRAY_ELEMENTS, \
~, \
HBOOST_PP_SEQ_FILTER(_TF_TOKENS_IS_ARRAY, ~, seq)) \
#define _TF_TOKENS_IS_ARRAY(s, data, elem)
Definition: staticTokens.h:220
#define _TF_TOKENS_APPEND_ARRAY_ELEMENTS(r, data, elem)
Definition: staticTokens.h:229

Definition at line 193 of file staticTokens.h.

#define _TF_TOKENS_FORWARD_ARRAY (   elem)    TF_PP_TUPLE_ELEM(0, elem),

Definition at line 160 of file staticTokens.h.

#define _TF_TOKENS_FORWARD_TOKEN (   unused,
  elem 
)    TF_PP_TUPLE_ELEM(0, elem),

Definition at line 171 of file staticTokens.h.

#define _TF_TOKENS_IS_ARRAY (   s,
  data,
  elem 
)
Value:
#define _TF_PP_IFF(c, t, f)
#define TF_PP_IS_TUPLE(arg)
#define TF_PP_TUPLE_ELEM(index, tuple)
Expands to the 'index' element of a non-empty 'tuple'.

Definition at line 220 of file staticTokens.h.

#define _TF_TOKENS_IS_NOT_ARRAY (   s,
  data,
  elem 
)    _TF_PP_IFF(_TF_TOKENS_IS_ARRAY(s, data, elem), 0, 1)

Definition at line 224 of file staticTokens.h.

#define _TF_TOKENS_STRUCT_NAME (   key)    TF_PP_CAT(key, _StaticTokenType)

Definition at line 142 of file staticTokens.h.

#define _TF_TOKENS_STRUCT_NAME_PRIVATE (   key)    TF_PP_CAT(key, _PrivateStaticTokenType)

Definition at line 135 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 108 of file staticTokens.h.

#define TF_DEFINE_PRIVATE_TOKENS (   key,
  seq 
)

Macro to define private tokens.

Definition at line 119 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 113 of file staticTokens.h.