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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
25 #define PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
26 
27 #include "pxr/pxr.h"
29 #include "pxr/usd/sdf/listOp.h"
30 #include "pxr/usd/sdf/path.h"
31 #include "pxr/usd/sdf/schema.h"
32 #include "pxr/usd/sdf/types.h"
33 #include "pxr/base/vt/dictionary.h"
34 #include "pxr/base/vt/value.h"
35 
36 #include "pxr/base/tf/enum.h"
37 #include "pxr/base/tf/token.h"
38 
39 #include <string>
40 #include <vector>
41 
43 
44 // Defines the built-in scene description fields supplied by Sdf as
45 // well as their C++ value types. SdfSchema supplies additional information
46 // about these fields, such as their default value and validation functions.
47 //
48 // XXX: bug 123508
49 // StartFrame and EndFrame should be migrated to Sd.
50 //
51 #define _SDF_FIELDS \
52 ((SdfFieldKeys->Active, bool)) \
53 ((SdfFieldKeys->AllowedTokens, VtTokenArray)) \
54 ((SdfFieldKeys->AssetInfo, VtDictionary)) \
55 ((SdfFieldKeys->ColorConfiguration, SdfAssetPath)) \
56 ((SdfFieldKeys->ColorManagementSystem, TfToken)) \
57 ((SdfFieldKeys->ColorSpace, TfToken)) \
58 ((SdfFieldKeys->Comment, std::string)) \
59 ((SdfFieldKeys->ConnectionPaths, SdfPathListOp)) \
60 ((SdfFieldKeys->Custom, bool)) \
61 ((SdfFieldKeys->CustomData, VtDictionary)) \
62 ((SdfFieldKeys->CustomLayerData, VtDictionary)) \
63 ((SdfFieldKeys->Default, VtValue)) \
64 ((SdfFieldKeys->DefaultPrim, TfToken)) \
65 ((SdfFieldKeys->DisplayGroup, std::string)) \
66 ((SdfFieldKeys->DisplayGroupOrder, VtStringArray)) \
67 ((SdfFieldKeys->DisplayName, std::string)) \
68 ((SdfFieldKeys->DisplayUnit, TfEnum)) \
69 ((SdfFieldKeys->Documentation, std::string)) \
70 ((SdfFieldKeys->EndFrame, double)) \
71 ((SdfFieldKeys->EndTimeCode, double)) \
72 ((SdfFieldKeys->ExpressionVariables, VtDictionary)) \
73 ((SdfFieldKeys->FramePrecision, int)) \
74 ((SdfFieldKeys->FramesPerSecond, double)) \
75 ((SdfFieldKeys->Hidden, bool)) \
76 ((SdfFieldKeys->HasOwnedSubLayers, bool)) \
77 ((SdfFieldKeys->InheritPaths, SdfPathListOp)) \
78 ((SdfFieldKeys->Instanceable, bool)) \
79 ((SdfFieldKeys->Kind, TfToken)) \
80 ((SdfFieldKeys->Owner, std::string)) \
81 ((SdfFieldKeys->PrimOrder, std::vector<TfToken>)) \
82 ((SdfFieldKeys->NoLoadHint, bool)) \
83 ((SdfFieldKeys->Payload, SdfPayloadListOp)) \
84 ((SdfFieldKeys->Permission, SdfPermission)) \
85 ((SdfFieldKeys->Prefix, std::string)) \
86 ((SdfFieldKeys->PrefixSubstitutions, VtDictionary)) \
87 ((SdfFieldKeys->PropertyOrder, std::vector<TfToken>)) \
88 ((SdfFieldKeys->References, SdfReferenceListOp)) \
89 ((SdfFieldKeys->SessionOwner, std::string)) \
90 ((SdfFieldKeys->TargetPaths, SdfPathListOp)) \
91 ((SdfFieldKeys->TimeSamples, SdfTimeSampleMap)) \
92 ((SdfFieldKeys->Relocates, SdfRelocatesMap)) \
93 ((SdfFieldKeys->Specializes, SdfPathListOp)) \
94 ((SdfFieldKeys->Specifier, SdfSpecifier)) \
95 ((SdfFieldKeys->StartFrame, double)) \
96 ((SdfFieldKeys->StartTimeCode, double)) \
97 ((SdfFieldKeys->SubLayers, std::vector<std::string>)) \
98 ((SdfFieldKeys->SubLayerOffsets, std::vector<SdfLayerOffset>)) \
99 ((SdfFieldKeys->Suffix, std::string)) \
100 ((SdfFieldKeys->SuffixSubstitutions, VtDictionary)) \
101 ((SdfFieldKeys->SymmetricPeer, std::string)) \
102 ((SdfFieldKeys->SymmetryArgs, VtDictionary)) \
103 ((SdfFieldKeys->SymmetryArguments, VtDictionary)) \
104 ((SdfFieldKeys->SymmetryFunction, TfToken)) \
105 ((SdfFieldKeys->TimeCodesPerSecond, double)) \
106 ((SdfFieldKeys->TypeName, TfToken)) \
107 ((SdfFieldKeys->VariantSetNames, SdfStringListOp)) \
108 ((SdfFieldKeys->VariantSelection, SdfVariantSelectionMap)) \
109 ((SdfFieldKeys->Variability, SdfVariability)) \
110 ((SdfChildrenKeys->ConnectionChildren, std::vector<SdfPath>)) \
111 ((SdfChildrenKeys->ExpressionChildren, std::vector<TfToken>)) \
112 ((SdfChildrenKeys->MapperArgChildren, std::vector<TfToken>)) \
113 ((SdfChildrenKeys->MapperChildren, std::vector<SdfPath>)) \
114 ((SdfChildrenKeys->PrimChildren, std::vector<TfToken>)) \
115 ((SdfChildrenKeys->PropertyChildren, std::vector<TfToken>)) \
116 ((SdfChildrenKeys->RelationshipTargetChildren, std::vector<SdfPath>)) \
117 ((SdfChildrenKeys->VariantChildren, std::vector<TfToken>)) \
118 ((SdfChildrenKeys->VariantSetChildren, std::vector<TfToken>))
119 
120 #define _SDF_FIELDS_NAME(tup) TF_PP_TUPLE_ELEM(0, tup)
121 #define _SDF_FIELDS_TYPE(tup) TF_PP_TUPLE_ELEM(1, tup)
122 
123 /// Registers each built-in Sd field along with its C++ value type with
124 /// \p reg. \p reg can be any type that has a member function:
125 /// template <class T> void RegisterField(const TfToken&);
126 ///
127 /// This function will be invoked for each (field, type) pair. The template
128 /// type T will be the C++ value type and the TfToken will be the field name.
129 template <class Registrar>
130 inline void
131 SdfRegisterFields(Registrar* reg)
132 {
133 #define _SDF_REGISTER_FIELDS(unused, elem) \
134  reg->template RegisterField< _SDF_FIELDS_TYPE(elem) >(_SDF_FIELDS_NAME(elem));
135 
137 #undef _SDF_REGISTER_FIELDS
138 }
139 
140 /// Registers all possible C++ value types for built-in fields with \p reg.
141 /// This is the set of C++ types that are used by built-in fields and could
142 /// be returned from an SdfAbstractData container. \p reg can be any type that
143 /// has a member function:
144 /// template <class T> void RegisterType();
145 ///
146 /// This function will be invoked for each C++ value type, which will be
147 /// given to the function as the template type T. Note that this function may
148 /// be called with the same T multiple times.
149 template <class Registrar>
150 inline void
151 SdfRegisterTypes(Registrar* reg)
152 {
153  // Register all of the C++ value types from the field list above.
154 #define _SDF_REGISTER_TYPES(unused, elem) \
155  reg->template RegisterType< _SDF_FIELDS_TYPE(elem) >();
156 
158 #undef _SDF_REGISTER_TYPES
159 
160  // Also register all of the C++ value types for value types.
161 #define _SDF_REGISTER_VALUE_TYPES(unused, elem) \
162  { \
163  reg->template RegisterType<SDF_VALUE_CPP_TYPE(elem)>(); \
164  reg->template RegisterType<SDF_VALUE_CPP_ARRAY_TYPE(elem)>(); \
165  }
167 #undef _SDF_REGISTER_VALUE_TYPES
168 
169  // Also register all of the C++ list op types supported for
170  // generic plugin metadata.
171  reg->template RegisterType<SdfIntListOp>();
172  reg->template RegisterType<SdfInt64ListOp>();
173  reg->template RegisterType<SdfUIntListOp>();
174  reg->template RegisterType<SdfUInt64ListOp>();
175  reg->template RegisterType<SdfStringListOp>();
176  reg->template RegisterType<SdfTokenListOp>();
177  reg->template RegisterType<SdfValueBlock>();
178 }
179 
181 
182 #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:1432
#define TF_PP_SEQ_FOR_EACH(_macro, data, seq)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
void SdfRegisterTypes(Registrar *reg)
#define SDF_VALUE_TYPES
Definition: types.h:372
#define _SDF_FIELDS