Loading...
Searching...
No Matches
declareSpec.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_DECLARE_SPEC_H
25#define PXR_USD_SDF_DECLARE_SPEC_H
26
27#include "pxr/pxr.h"
28#include "pxr/usd/sdf/api.h"
32#include "pxr/base/tf/type.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
36class SdfSpec;
37
57#define SDF_DECLARE_ABSTRACT_SPEC(SpecType, BaseSpecType) \
58public: \
59 SpecType() { } \
60 SpecType(const SpecType& spec) \
61 : BaseSpecType(spec) { } \
62 explicit SpecType(const Sdf_IdentityRefPtr& identity) \
63 : BaseSpecType(identity) { } \
64protected: \
65 friend struct Sdf_CastAccess; \
66 explicit SpecType(const SdfSpec& spec) \
67 : BaseSpecType(spec) { } \
68
69#define SDF_DEFINE_ABSTRACT_SPEC(SchemaType, SpecType, BaseSpecType) \
70TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
71{ \
72 TfType::Define<SpecType, TfType::Bases<BaseSpecType> >(); \
73} \
74TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
75{ \
76 SdfSpecTypeRegistration::RegisterAbstractSpecType< \
77 SchemaType, SpecType>(); \
78}
79
80// ------------------------------------------------------------
81
82#define SDF_DECLARE_SPEC(SpecType, BaseSpecType) \
83 SDF_DECLARE_ABSTRACT_SPEC(SpecType, BaseSpecType) \
84
85#define SDF_DEFINE_SPEC(SchemaType, SpecTypeEnum, SpecType, BaseSpecType) \
86TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
87{ \
88 TfType::Define<SpecType, TfType::Bases<BaseSpecType> >(); \
89} \
90TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
91{ \
92 SdfSpecTypeRegistration::RegisterSpecType<SchemaType, SpecType> \
93 (SpecTypeEnum); \
94}
95
96// ------------------------------------------------------------
97// Special set of macros for SdfSpec only.
98
99#define SDF_DECLARE_BASE_SPEC(SpecType) \
100public: \
101 SpecType() { } \
102 SpecType(const SpecType& spec) : _id(spec._id) { } \
103 explicit SpecType(const Sdf_IdentityRefPtr& id) : _id(id) { } \
104
105#define SDF_DEFINE_BASE_SPEC(SchemaType, SpecType) \
106TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
107{ \
108 TfType::Define<SpecType>(); \
109} \
110TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
111{ \
112 SdfSpecTypeRegistration::RegisterAbstractSpecType< \
113 SchemaType, SpecType>(); \
114}
115
116PXR_NAMESPACE_CLOSE_SCOPE
117
118#endif // PXR_USD_SDF_DECLARE_SPEC_H
Base class for all Sdf spec classes.
Definition: spec.h:50