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
19#include "pxr/base/tf/enum.h"
20#include "pxr/base/tf/token.h"
21
22#include <string>
23#include <vector>
24
25PXR_NAMESPACE_OPEN_SCOPE
26
27// Defines the built-in scene description fields supplied by Sdf as
28// well as their C++ value types. SdfSchema supplies additional information
29// about these fields, such as their default value and validation functions.
30//
31// XXX: bug 123508
32// StartFrame and EndFrame should be migrated to Sd.
33//
34#define _SDF_FIELDS \
35((SdfFieldKeys->Active, bool)) \
36((SdfFieldKeys->AllowedTokens, VtTokenArray)) \
37((SdfFieldKeys->AssetInfo, VtDictionary)) \
38((SdfFieldKeys->ColorConfiguration, SdfAssetPath)) \
39((SdfFieldKeys->ColorManagementSystem, TfToken)) \
40((SdfFieldKeys->ColorSpace, TfToken)) \
41((SdfFieldKeys->Comment, std::string)) \
42((SdfFieldKeys->ConnectionPaths, SdfPathListOp)) \
43((SdfFieldKeys->Custom, bool)) \
44((SdfFieldKeys->CustomData, VtDictionary)) \
45((SdfFieldKeys->CustomLayerData, VtDictionary)) \
46((SdfFieldKeys->Default, VtValue)) \
47((SdfFieldKeys->DefaultPrim, TfToken)) \
48((SdfFieldKeys->DisplayGroup, std::string)) \
49((SdfFieldKeys->DisplayGroupOrder, VtStringArray)) \
50((SdfFieldKeys->DisplayName, std::string)) \
51((SdfFieldKeys->DisplayUnit, TfEnum)) \
52((SdfFieldKeys->Documentation, std::string)) \
53((SdfFieldKeys->EndFrame, double)) \
54((SdfFieldKeys->EndTimeCode, double)) \
55((SdfFieldKeys->ExpressionVariables, VtDictionary)) \
56((SdfFieldKeys->FramePrecision, int)) \
57((SdfFieldKeys->FramesPerSecond, double)) \
58((SdfFieldKeys->Hidden, bool)) \
59((SdfFieldKeys->HasOwnedSubLayers, bool)) \
60((SdfFieldKeys->InheritPaths, SdfPathListOp)) \
61((SdfFieldKeys->Instanceable, bool)) \
62((SdfFieldKeys->Kind, TfToken)) \
63((SdfFieldKeys->LayerRelocates, SdfRelocates)) \
64((SdfFieldKeys->Owner, std::string)) \
65((SdfFieldKeys->PrimOrder, std::vector<TfToken>)) \
66((SdfFieldKeys->NoLoadHint, bool)) \
67((SdfFieldKeys->Payload, SdfPayloadListOp)) \
68((SdfFieldKeys->Permission, SdfPermission)) \
69((SdfFieldKeys->Prefix, std::string)) \
70((SdfFieldKeys->PrefixSubstitutions, VtDictionary)) \
71((SdfFieldKeys->PropertyOrder, std::vector<TfToken>)) \
72((SdfFieldKeys->References, SdfReferenceListOp)) \
73((SdfFieldKeys->SessionOwner, std::string)) \
74((SdfFieldKeys->TargetPaths, SdfPathListOp)) \
75((SdfFieldKeys->TimeSamples, SdfTimeSampleMap)) \
76((SdfFieldKeys->Relocates, SdfRelocatesMap)) \
77((SdfFieldKeys->Specializes, SdfPathListOp)) \
78((SdfFieldKeys->Specifier, SdfSpecifier)) \
79((SdfFieldKeys->StartFrame, double)) \
80((SdfFieldKeys->StartTimeCode, double)) \
81((SdfFieldKeys->SubLayers, std::vector<std::string>)) \
82((SdfFieldKeys->SubLayerOffsets, std::vector<SdfLayerOffset>)) \
83((SdfFieldKeys->Suffix, std::string)) \
84((SdfFieldKeys->SuffixSubstitutions, VtDictionary)) \
85((SdfFieldKeys->SymmetricPeer, std::string)) \
86((SdfFieldKeys->SymmetryArgs, VtDictionary)) \
87((SdfFieldKeys->SymmetryArguments, VtDictionary)) \
88((SdfFieldKeys->SymmetryFunction, TfToken)) \
89((SdfFieldKeys->TimeCodesPerSecond, double)) \
90((SdfFieldKeys->TypeName, TfToken)) \
91((SdfFieldKeys->VariantSetNames, SdfStringListOp)) \
92((SdfFieldKeys->VariantSelection, SdfVariantSelectionMap)) \
93((SdfFieldKeys->Variability, SdfVariability)) \
94((SdfChildrenKeys->ConnectionChildren, std::vector<SdfPath>)) \
95((SdfChildrenKeys->ExpressionChildren, std::vector<TfToken>)) \
96((SdfChildrenKeys->MapperArgChildren, std::vector<TfToken>)) \
97((SdfChildrenKeys->MapperChildren, std::vector<SdfPath>)) \
98((SdfChildrenKeys->PrimChildren, std::vector<TfToken>)) \
99((SdfChildrenKeys->PropertyChildren, std::vector<TfToken>)) \
100((SdfChildrenKeys->RelationshipTargetChildren, std::vector<SdfPath>)) \
101((SdfChildrenKeys->VariantChildren, std::vector<TfToken>)) \
102((SdfChildrenKeys->VariantSetChildren, std::vector<TfToken>))
103
104#define _SDF_FIELDS_NAME(tup) TF_PP_TUPLE_ELEM(0, tup)
105#define _SDF_FIELDS_TYPE(tup) TF_PP_TUPLE_ELEM(1, tup)
106
113template <class Registrar>
114inline void
115SdfRegisterFields(Registrar* reg)
116{
117#define _SDF_REGISTER_FIELDS(unused, elem) \
118 reg->template RegisterField< _SDF_FIELDS_TYPE(elem) >(_SDF_FIELDS_NAME(elem));
119
120 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_FIELDS, ~, _SDF_FIELDS)
121#undef _SDF_REGISTER_FIELDS
122}
123
133template <class Registrar>
134inline void
135SdfRegisterTypes(Registrar* reg)
136{
137 // Register all of the C++ value types from the field list above.
138#define _SDF_REGISTER_TYPES(unused, elem) \
139 reg->template RegisterType< _SDF_FIELDS_TYPE(elem) >();
140
141 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_TYPES, ~, _SDF_FIELDS)
142#undef _SDF_REGISTER_TYPES
143
144 // Also register all of the C++ value types for value types.
145#define _SDF_REGISTER_VALUE_TYPES(unused, elem) \
146 { \
147 reg->template RegisterType<SDF_VALUE_CPP_TYPE(elem)>(); \
148 reg->template RegisterType<SDF_VALUE_CPP_ARRAY_TYPE(elem)>(); \
149 }
150 TF_PP_SEQ_FOR_EACH(_SDF_REGISTER_VALUE_TYPES, ~, SDF_VALUE_TYPES)
151#undef _SDF_REGISTER_VALUE_TYPES
152
153 // Also register all of the C++ list op types supported for
154 // generic plugin metadata.
155 reg->template RegisterType<SdfIntListOp>();
156 reg->template RegisterType<SdfInt64ListOp>();
157 reg->template RegisterType<SdfUIntListOp>();
158 reg->template RegisterType<SdfUInt64ListOp>();
159 reg->template RegisterType<SdfStringListOp>();
160 reg->template RegisterType<SdfTokenListOp>();
161 reg->template RegisterType<SdfValueBlock>();
162}
163
164PXR_NAMESPACE_CLOSE_SCOPE
165
166#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.