HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
schemaTypeRegistration.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
8 #define PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
9 
10 #include "pxr/pxr.h"
12 #include "pxr/usd/sdf/listOp.h"
13 #include "pxr/usd/sdf/path.h"
14 #include "pxr/usd/sdf/schema.h"
15 #include "pxr/usd/sdf/types.h"
16 #include "pxr/base/vt/dictionary.h"
17 #include "pxr/base/vt/value.h"
18 #include "pxr/base/ts/spline.h"
19 
20 #include "pxr/base/tf/enum.h"
21 #include "pxr/base/tf/token.h"
22 
23 #include <string>
24 #include <vector>
25 
27 
28 // Defines the built-in scene description fields supplied by Sdf as
29 // well as their C++ value types. SdfSchema supplies additional information
30 // about these fields, such as their default value and validation functions.
31 //
32 // XXX: bug 123508
33 // StartFrame and EndFrame should be migrated to Sd.
34 //
35 #define _SDF_FIELDS \
36 ((SdfFieldKeys->Active, bool)) \
37 ((SdfFieldKeys->AllowedTokens, VtTokenArray)) \
38 ((SdfFieldKeys->AssetInfo, VtDictionary)) \
39 ((SdfFieldKeys->ColorConfiguration, SdfAssetPath)) \
40 ((SdfFieldKeys->ColorManagementSystem, TfToken)) \
41 ((SdfFieldKeys->ColorSpace, TfToken)) \
42 ((SdfFieldKeys->Comment, std::string)) \
43 ((SdfFieldKeys->ConnectionPaths, SdfPathListOp)) \
44 ((SdfFieldKeys->Custom, bool)) \
45 ((SdfFieldKeys->CustomData, VtDictionary)) \
46 ((SdfFieldKeys->CustomLayerData, VtDictionary)) \
47 ((SdfFieldKeys->Default, VtValue)) \
48 ((SdfFieldKeys->DefaultPrim, TfToken)) \
49 ((SdfFieldKeys->DisplayGroup, std::string)) \
50 ((SdfFieldKeys->DisplayGroupOrder, VtStringArray)) \
51 ((SdfFieldKeys->DisplayName, std::string)) \
52 ((SdfFieldKeys->DisplayUnit, TfEnum)) \
53 ((SdfFieldKeys->Documentation, std::string)) \
54 ((SdfFieldKeys->EndFrame, double)) \
55 ((SdfFieldKeys->EndTimeCode, double)) \
56 ((SdfFieldKeys->ExpressionVariables, VtDictionary)) \
57 ((SdfFieldKeys->FramePrecision, int)) \
58 ((SdfFieldKeys->FramesPerSecond, double)) \
59 ((SdfFieldKeys->Hidden, bool)) \
60 ((SdfFieldKeys->HasOwnedSubLayers, bool)) \
61 ((SdfFieldKeys->InheritPaths, SdfPathListOp)) \
62 ((SdfFieldKeys->Instanceable, bool)) \
63 ((SdfFieldKeys->Kind, TfToken)) \
64 ((SdfFieldKeys->LayerRelocates, SdfRelocates)) \
65 ((SdfFieldKeys->Owner, std::string)) \
66 ((SdfFieldKeys->PrimOrder, std::vector<TfToken>)) \
67 ((SdfFieldKeys->NoLoadHint, bool)) \
68 ((SdfFieldKeys->Payload, SdfPayloadListOp)) \
69 ((SdfFieldKeys->Permission, SdfPermission)) \
70 ((SdfFieldKeys->Prefix, std::string)) \
71 ((SdfFieldKeys->PrefixSubstitutions, VtDictionary)) \
72 ((SdfFieldKeys->PropertyOrder, std::vector<TfToken>)) \
73 ((SdfFieldKeys->References, SdfReferenceListOp)) \
74 ((SdfFieldKeys->SessionOwner, std::string)) \
75 ((SdfFieldKeys->TargetPaths, SdfPathListOp)) \
76 ((SdfFieldKeys->TimeSamples, SdfTimeSampleMap)) \
77 ((SdfFieldKeys->Relocates, SdfRelocatesMap)) \
78 ((SdfFieldKeys->Specializes, SdfPathListOp)) \
79 ((SdfFieldKeys->Specifier, SdfSpecifier)) \
80 ((SdfFieldKeys->Spline, TsSpline)) \
81 ((SdfFieldKeys->StartFrame, double)) \
82 ((SdfFieldKeys->StartTimeCode, double)) \
83 ((SdfFieldKeys->SubLayers, std::vector<std::string>)) \
84 ((SdfFieldKeys->SubLayerOffsets, std::vector<SdfLayerOffset>)) \
85 ((SdfFieldKeys->Suffix, std::string)) \
86 ((SdfFieldKeys->SuffixSubstitutions, VtDictionary)) \
87 ((SdfFieldKeys->SymmetricPeer, std::string)) \
88 ((SdfFieldKeys->SymmetryArgs, VtDictionary)) \
89 ((SdfFieldKeys->SymmetryArguments, VtDictionary)) \
90 ((SdfFieldKeys->SymmetryFunction, TfToken)) \
91 ((SdfFieldKeys->TimeCodesPerSecond, double)) \
92 ((SdfFieldKeys->TypeName, TfToken)) \
93 ((SdfFieldKeys->VariantSetNames, SdfStringListOp)) \
94 ((SdfFieldKeys->VariantSelection, SdfVariantSelectionMap)) \
95 ((SdfFieldKeys->Variability, SdfVariability)) \
96 ((SdfChildrenKeys->ConnectionChildren, std::vector<SdfPath>)) \
97 ((SdfChildrenKeys->ExpressionChildren, std::vector<TfToken>)) \
98 ((SdfChildrenKeys->MapperArgChildren, std::vector<TfToken>)) \
99 ((SdfChildrenKeys->MapperChildren, std::vector<SdfPath>)) \
100 ((SdfChildrenKeys->PrimChildren, std::vector<TfToken>)) \
101 ((SdfChildrenKeys->PropertyChildren, std::vector<TfToken>)) \
102 ((SdfChildrenKeys->RelationshipTargetChildren, std::vector<SdfPath>)) \
103 ((SdfChildrenKeys->VariantChildren, std::vector<TfToken>)) \
104 ((SdfChildrenKeys->VariantSetChildren, std::vector<TfToken>))
105 
106 #define _SDF_FIELDS_NAME(tup) TF_PP_TUPLE_ELEM(0, tup)
107 #define _SDF_FIELDS_TYPE(tup) TF_PP_TUPLE_ELEM(1, tup)
108 
109 /// Registers each built-in Sd field along with its C++ value type with
110 /// \p reg. \p reg can be any type that has a member function:
111 /// template <class T> void RegisterField(const TfToken&);
112 ///
113 /// This function will be invoked for each (field, type) pair. The template
114 /// type T will be the C++ value type and the TfToken will be the field name.
115 template <class Registrar>
116 inline void
117 SdfRegisterFields(Registrar* reg)
118 {
119 #define _SDF_REGISTER_FIELDS(unused, elem) \
120  reg->template RegisterField< _SDF_FIELDS_TYPE(elem) >(_SDF_FIELDS_NAME(elem));
121 
123 #undef _SDF_REGISTER_FIELDS
124 }
125 
126 /// Registers all possible C++ value types for built-in fields with \p reg.
127 /// This is the set of C++ types that are used by built-in fields and could
128 /// be returned from an SdfAbstractData container. \p reg can be any type that
129 /// has a member function:
130 /// template <class T> void RegisterType();
131 ///
132 /// This function will be invoked for each C++ value type, which will be
133 /// given to the function as the template type T. Note that this function may
134 /// be called with the same T multiple times.
135 template <class Registrar>
136 inline void
137 SdfRegisterTypes(Registrar* reg)
138 {
139  // Register all of the C++ value types from the field list above.
140 #define _SDF_REGISTER_TYPES(unused, elem) \
141  reg->template RegisterType< _SDF_FIELDS_TYPE(elem) >();
142 
144 #undef _SDF_REGISTER_TYPES
145 
146  // Also register all of the C++ value types for value types.
147 #define _SDF_REGISTER_VALUE_TYPES(unused, elem) \
148  { \
149  reg->template RegisterType<SDF_VALUE_CPP_TYPE(elem)>(); \
150  reg->template RegisterType<SDF_VALUE_CPP_ARRAY_TYPE(elem)>(); \
151  }
153 #undef _SDF_REGISTER_VALUE_TYPES
154 
155  // Also register all of the C++ list op types supported for
156  // generic plugin metadata.
157  reg->template RegisterType<SdfIntListOp>();
158  reg->template RegisterType<SdfInt64ListOp>();
159  reg->template RegisterType<SdfUIntListOp>();
160  reg->template RegisterType<SdfUInt64ListOp>();
161  reg->template RegisterType<SdfStringListOp>();
162  reg->template RegisterType<SdfTokenListOp>();
163  reg->template RegisterType<SdfValueBlock>();
164 }
165 
167 
168 #endif // PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
#define _SDF_REGISTER_VALUE_TYPES(unused, elem)
void SdfRegisterFields(Registrar *reg)
#define _SDF_REGISTER_FIELDS(unused, elem)
#define _SDF_REGISTER_TYPES(unused, elem)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define TF_PP_SEQ_FOR_EACH(_macro, data, seq)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
void SdfRegisterTypes(Registrar *reg)
#define SDF_VALUE_TYPES
Definition: types.h:362
#define _SDF_FIELDS