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