All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
schemaTypeRegistration.h
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 
42 PXR_NAMESPACE_OPEN_SCOPE
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->FramePrecision, int)) \
73 ((SdfFieldKeys->FramesPerSecond, double)) \
74 ((SdfFieldKeys->Hidden, bool)) \
75 ((SdfFieldKeys->HasOwnedSubLayers, bool)) \
76 ((SdfFieldKeys->InheritPaths, SdfPathListOp)) \
77 ((SdfFieldKeys->Instanceable, bool)) \
78 ((SdfFieldKeys->Kind, TfToken)) \
79 ((SdfFieldKeys->Owner, std::string)) \
80 ((SdfFieldKeys->PrimOrder, std::vector<TfToken>)) \
81 ((SdfFieldKeys->NoLoadHint, bool)) \
82 ((SdfFieldKeys->Payload, SdfPayloadListOp)) \
83 ((SdfFieldKeys->Permission, SdfPermission)) \
84 ((SdfFieldKeys->Prefix, std::string)) \
85 ((SdfFieldKeys->PrefixSubstitutions, VtDictionary)) \
86 ((SdfFieldKeys->PropertyOrder, std::vector<TfToken>)) \
87 ((SdfFieldKeys->References, SdfReferenceListOp)) \
88 ((SdfFieldKeys->SessionOwner, std::string)) \
89 ((SdfFieldKeys->TargetPaths, SdfPathListOp)) \
90 ((SdfFieldKeys->TimeSamples, SdfTimeSampleMap)) \
91 ((SdfFieldKeys->Relocates, SdfRelocatesMap)) \
92 ((SdfFieldKeys->Specializes, SdfPathListOp)) \
93 ((SdfFieldKeys->Specifier, SdfSpecifier)) \
94 ((SdfFieldKeys->StartFrame, double)) \
95 ((SdfFieldKeys->StartTimeCode, double)) \
96 ((SdfFieldKeys->SubLayers, std::vector<std::string>)) \
97 ((SdfFieldKeys->SubLayerOffsets, std::vector<SdfLayerOffset>)) \
98 ((SdfFieldKeys->Suffix, std::string)) \
99 ((SdfFieldKeys->SuffixSubstitutions, VtDictionary)) \
100 ((SdfFieldKeys->SymmetricPeer, std::string)) \
101 ((SdfFieldKeys->SymmetryArgs, VtDictionary)) \
102 ((SdfFieldKeys->SymmetryArguments, VtDictionary)) \
103 ((SdfFieldKeys->SymmetryFunction, TfToken)) \
104 ((SdfFieldKeys->TimeCodesPerSecond, double)) \
105 ((SdfFieldKeys->TypeName, TfToken)) \
106 ((SdfFieldKeys->VariantSetNames, SdfStringListOp)) \
107 ((SdfFieldKeys->VariantSelection, SdfVariantSelectionMap)) \
108 ((SdfFieldKeys->Variability, SdfVariability)) \
109 ((SdfChildrenKeys->ConnectionChildren, std::vector<SdfPath>)) \
110 ((SdfChildrenKeys->ExpressionChildren, std::vector<TfToken>)) \
111 ((SdfChildrenKeys->MapperArgChildren, std::vector<TfToken>)) \
112 ((SdfChildrenKeys->MapperChildren, std::vector<SdfPath>)) \
113 ((SdfChildrenKeys->PrimChildren, std::vector<TfToken>)) \
114 ((SdfChildrenKeys->PropertyChildren, std::vector<TfToken>)) \
115 ((SdfChildrenKeys->RelationshipTargetChildren, std::vector<SdfPath>)) \
116 ((SdfChildrenKeys->VariantChildren, std::vector<TfToken>)) \
117 ((SdfChildrenKeys->VariantSetChildren, std::vector<TfToken>))
118 
119 #define _SDF_FIELDS_NAME(tup) BOOST_PP_TUPLE_ELEM(2, 0, tup)
120 #define _SDF_FIELDS_TYPE(tup) BOOST_PP_TUPLE_ELEM(2, 1, tup)
121 
128 template <class Registrar>
129 inline void
130 SdfRegisterFields(Registrar* reg)
131 {
132 #define _SDF_REGISTER_FIELDS(r, unused, elem) \
133  reg->template RegisterField< _SDF_FIELDS_TYPE(elem) >(_SDF_FIELDS_NAME(elem));
134 
135  BOOST_PP_SEQ_FOR_EACH(_SDF_REGISTER_FIELDS, ~, _SDF_FIELDS)
136 #undef _SDF_REGISTER_FIELDS
137 }
138 
148 template <class Registrar>
149 inline void
150 SdfRegisterTypes(Registrar* reg)
151 {
152  // Register all of the C++ value types from the field list above.
153 #define _SDF_REGISTER_TYPES(r, unused, elem) \
154  reg->template RegisterType< _SDF_FIELDS_TYPE(elem) >();
155 
156  BOOST_PP_SEQ_FOR_EACH(_SDF_REGISTER_TYPES, ~, _SDF_FIELDS)
157 #undef _SDF_REGISTER_TYPES
158 
159  // Also register all of the C++ value types for value types.
160 #define _SDF_REGISTER_VALUE_TYPES(r, unused, elem) \
161  { \
162  reg->template RegisterType<SDF_VALUE_CPP_TYPE(elem)>(); \
163  reg->template RegisterType<SDF_VALUE_CPP_ARRAY_TYPE(elem)>(); \
164  }
165  BOOST_PP_SEQ_FOR_EACH(_SDF_REGISTER_VALUE_TYPES, ~, SDF_VALUE_TYPES)
166 #undef _SDF_REGISTER_VALUE_TYPES
167 
168  // Also register all of the C++ list op types supported for
169  // generic plugin metadata.
170  reg->template RegisterType<SdfIntListOp>();
171  reg->template RegisterType<SdfInt64ListOp>();
172  reg->template RegisterType<SdfUIntListOp>();
173  reg->template RegisterType<SdfUInt64ListOp>();
174  reg->template RegisterType<SdfStringListOp>();
175  reg->template RegisterType<SdfTokenListOp>();
176  reg->template RegisterType<SdfValueBlock>();
177 }
178 
179 PXR_NAMESPACE_CLOSE_SCOPE
180 
181 #endif // PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
Basic Sdf data types.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...