Loading...
Searching...
No Matches
schemaTypeRegistration.h
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"
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
26PXR_NAMESPACE_OPEN_SCOPE
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->ArraySizeConstraint, int64_t)) \
39((SdfFieldKeys->AssetInfo, VtDictionary)) \
40((SdfFieldKeys->Clips, VtDictionary)) \
41((SdfFieldKeys->ClipSets, SdfStringListOp)) \
42((SdfFieldKeys->ColorConfiguration, SdfAssetPath)) \
43((SdfFieldKeys->ColorManagementSystem, TfToken)) \
44((SdfFieldKeys->ColorSpace, TfToken)) \
45((SdfFieldKeys->Comment, std::string)) \
46((SdfFieldKeys->ConnectionPaths, SdfPathListOp)) \
47((SdfFieldKeys->Custom, bool)) \
48((SdfFieldKeys->CustomData, VtDictionary)) \
49((SdfFieldKeys->CustomLayerData, VtDictionary)) \
50((SdfFieldKeys->Default, VtValue)) \
51((SdfFieldKeys->DefaultPrim, TfToken)) \
52((SdfFieldKeys->DisplayGroup, std::string)) \
53((SdfFieldKeys->DisplayGroupOrder, VtStringArray)) \
54((SdfFieldKeys->DisplayName, std::string)) \
55((SdfFieldKeys->DisplayUnit, TfEnum)) \
56((SdfFieldKeys->Documentation, std::string)) \
57((SdfFieldKeys->EndFrame, double)) \
58((SdfFieldKeys->EndTimeCode, double)) \
59((SdfFieldKeys->ExpressionVariables, VtDictionary)) \
60((SdfFieldKeys->FramePrecision, int)) \
61((SdfFieldKeys->FramesPerSecond, double)) \
62((SdfFieldKeys->Hidden, bool)) \
63((SdfFieldKeys->HasOwnedSubLayers, bool)) \
64((SdfFieldKeys->InheritPaths, SdfPathListOp)) \
65((SdfFieldKeys->Instanceable, bool)) \
66((SdfFieldKeys->Kind, TfToken)) \
67((SdfFieldKeys->LayerRelocates, SdfRelocates)) \
68((SdfFieldKeys->Limits, VtDictionary)) \
69((SdfFieldKeys->Owner, std::string)) \
70((SdfFieldKeys->PrimOrder, std::vector<TfToken>)) \
71((SdfFieldKeys->NoLoadHint, bool)) \
72((SdfFieldKeys->Payload, SdfPayloadListOp)) \
73((SdfFieldKeys->Permission, SdfPermission)) \
74((SdfFieldKeys->Prefix, std::string)) \
75((SdfFieldKeys->PrefixSubstitutions, VtDictionary)) \
76((SdfFieldKeys->PropertyOrder, std::vector<TfToken>)) \
77((SdfFieldKeys->References, SdfReferenceListOp)) \
78((SdfFieldKeys->SessionOwner, std::string)) \
79((SdfFieldKeys->TargetPaths, SdfPathListOp)) \
80((SdfFieldKeys->TimeSamples, SdfTimeSampleMap)) \
81((SdfFieldKeys->Relocates, SdfRelocatesMap)) \
82((SdfFieldKeys->Specializes, SdfPathListOp)) \
83((SdfFieldKeys->Specifier, SdfSpecifier)) \
84((SdfFieldKeys->Spline, TsSpline)) \
85((SdfFieldKeys->StartFrame, double)) \
86((SdfFieldKeys->StartTimeCode, double)) \
87((SdfFieldKeys->SubLayers, std::vector<std::string>)) \
88((SdfFieldKeys->SubLayerOffsets, std::vector<SdfLayerOffset>)) \
89((SdfFieldKeys->Suffix, std::string)) \
90((SdfFieldKeys->SuffixSubstitutions, VtDictionary)) \
91((SdfFieldKeys->SymmetricPeer, std::string)) \
92((SdfFieldKeys->SymmetryArgs, VtDictionary)) \
93((SdfFieldKeys->SymmetryArguments, VtDictionary)) \
94((SdfFieldKeys->SymmetryFunction, TfToken)) \
95((SdfFieldKeys->TimeCodesPerSecond, double)) \
96((SdfFieldKeys->TypeName, TfToken)) \
97((SdfFieldKeys->VariantSetNames, SdfStringListOp)) \
98((SdfFieldKeys->VariantSelection, SdfVariantSelectionMap)) \
99((SdfFieldKeys->Variability, SdfVariability)) \
100((SdfChildrenKeys->ConnectionChildren, std::vector<SdfPath>)) \
101((SdfChildrenKeys->ExpressionChildren, std::vector<TfToken>)) \
102((SdfChildrenKeys->MapperArgChildren, std::vector<TfToken>)) \
103((SdfChildrenKeys->MapperChildren, std::vector<SdfPath>)) \
104((SdfChildrenKeys->PrimChildren, std::vector<TfToken>)) \
105((SdfChildrenKeys->PropertyChildren, std::vector<TfToken>)) \
106((SdfChildrenKeys->RelationshipTargetChildren, std::vector<SdfPath>)) \
107((SdfChildrenKeys->VariantChildren, std::vector<TfToken>)) \
108((SdfChildrenKeys->VariantSetChildren, std::vector<TfToken>))
109
110#define _SDF_FIELDS_NAME(tup) TF_PP_TUPLE_ELEM(0, tup)
111#define _SDF_FIELDS_TYPE(tup) TF_PP_TUPLE_ELEM(1, tup)
112
119template <class Registrar>
120inline void
121SdfRegisterFields(Registrar* reg)
122{
123#define _SDF_REGISTER_FIELDS(unused, elem) \
124 reg->template RegisterField< _SDF_FIELDS_TYPE(elem) >(_SDF_FIELDS_NAME(elem));
125
126 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_FIELDS, ~, _SDF_FIELDS)
127#undef _SDF_REGISTER_FIELDS
128}
129
139template <class Registrar>
140inline void
141SdfRegisterTypes(Registrar* reg)
142{
143 // Register all of the C++ value types from the field list above.
144#define _SDF_REGISTER_TYPES(unused, elem) \
145 reg->template RegisterType< _SDF_FIELDS_TYPE(elem) >();
146
147 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_TYPES, ~, _SDF_FIELDS)
148#undef _SDF_REGISTER_TYPES
149
150 // Also register all of the C++ value types for value types.
151#define _SDF_REGISTER_VALUE_TYPES(unused, elem) \
152 { \
153 reg->template RegisterType<SDF_VALUE_CPP_TYPE(elem)>(); \
154 reg->template RegisterType<SDF_VALUE_CPP_ARRAY_TYPE(elem)>(); \
155 }
156 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_VALUE_TYPES, ~, SDF_VALUE_TYPES)
157#undef _SDF_REGISTER_VALUE_TYPES
158
159 // Also register all of the C++ list op types supported for
160 // generic plugin metadata.
161 reg->template RegisterType<SdfIntListOp>();
162 reg->template RegisterType<SdfInt64ListOp>();
163 reg->template RegisterType<SdfUIntListOp>();
164 reg->template RegisterType<SdfUInt64ListOp>();
165 reg->template RegisterType<SdfStringListOp>();
166 reg->template RegisterType<SdfTokenListOp>();
167 reg->template RegisterType<SdfValueBlock>();
168 reg->template RegisterType<SdfAnimationBlock>();
169}
170
171PXR_NAMESPACE_CLOSE_SCOPE
172
173#endif // PXR_USD_SDF_SCHEMA_TYPE_REGISTRATION_H
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
Basic Sdf data types.