This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
declareSpec.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_DECLARE_SPEC_H
8#define PXR_USD_SDF_DECLARE_SPEC_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/sdf/api.h"
15#include "pxr/base/tf/type.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
19class SdfSpec;
20
40#define SDF_DECLARE_ABSTRACT_SPEC(SpecType, BaseSpecType) \
41public: \
42 SpecType() { } \
43 SpecType(const SpecType& spec) \
44 : BaseSpecType(spec) { } \
45 explicit SpecType(const Sdf_IdentityRefPtr& identity) \
46 : BaseSpecType(identity) { } \
47protected: \
48 friend struct Sdf_CastAccess; \
49 explicit SpecType(const SdfSpec& spec) \
50 : BaseSpecType(spec) { } \
51
52#define SDF_DEFINE_ABSTRACT_SPEC(SchemaType, SpecType, BaseSpecType) \
53TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
54{ \
55 TfType::Define<SpecType, TfType::Bases<BaseSpecType> >(); \
56} \
57TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
58{ \
59 SdfSpecTypeRegistration::RegisterAbstractSpecType< \
60 SchemaType, SpecType>(); \
61}
62
63// ------------------------------------------------------------
64
65#define SDF_DECLARE_SPEC(SpecType, BaseSpecType) \
66 SDF_DECLARE_ABSTRACT_SPEC(SpecType, BaseSpecType) \
67
68#define SDF_DEFINE_SPEC(SchemaType, SpecTypeEnum, SpecType, BaseSpecType) \
69TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
70{ \
71 TfType::Define<SpecType, TfType::Bases<BaseSpecType> >(); \
72} \
73TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
74{ \
75 SdfSpecTypeRegistration::RegisterSpecType<SchemaType, SpecType> \
76 (SpecTypeEnum); \
77}
78
79// ------------------------------------------------------------
80// Special set of macros for SdfSpec only.
81
82#define SDF_DECLARE_BASE_SPEC(SpecType) \
83public: \
84 SpecType() { } \
85 SpecType(const SpecType& spec) : _id(spec._id) { } \
86 explicit SpecType(const Sdf_IdentityRefPtr& id) : _id(id) { } \
87
88#define SDF_DEFINE_BASE_SPEC(SchemaType, SpecType) \
89TF_REGISTRY_FUNCTION_WITH_TAG(TfType, Type) \
90{ \
91 TfType::Define<SpecType>(); \
92} \
93TF_REGISTRY_FUNCTION_WITH_TAG(SdfSpecTypeRegistration, Registration) \
94{ \
95 SdfSpecTypeRegistration::RegisterAbstractSpecType< \
96 SchemaType, SpecType>(); \
97}
98
99PXR_NAMESPACE_CLOSE_SCOPE
100
101#endif // PXR_USD_SDF_DECLARE_SPEC_H
Base class for all Sdf spec classes.
Definition: spec.h:33