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
attributeSpec.h
Go to the documentation of this file.
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_ATTRIBUTE_SPEC_H
8#define PXR_USD_SDF_ATTRIBUTE_SPEC_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/sdf/api.h"
14#include "pxr/usd/sdf/declareSpec.h"
15#include "pxr/usd/sdf/path.h"
17#include "pxr/usd/sdf/types.h"
18#include "pxr/base/tf/enum.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
40{
41 SDF_DECLARE_SPEC(SdfAttributeSpec, SdfPropertySpec);
42
43public:
44 typedef SdfAttributeSpec This;
45 typedef SdfPropertySpec Parent;
46
50
55 SDF_API
56 static SdfAttributeSpecHandle
57 New(const SdfPrimSpecHandle& owner,
58 const std::string& name, const SdfValueTypeName& typeName,
59 SdfVariability variability = SdfVariabilityVarying,
60 bool custom = false);
61
63
66
71 SDF_API
73
75 SDF_API
76 bool HasConnectionPaths() const;
77
79 SDF_API
81
85
91 SDF_API
92 VtTokenArray GetAllowedTokens() const;
93
95 SDF_API
96 void SetAllowedTokens(const VtTokenArray& allowedTokens);
97
99 SDF_API
100 bool HasAllowedTokens() const;
101
103 SDF_API
105
107 SDF_API
109
111 SDF_API
112 void SetDisplayUnit(const TfEnum& displayUnit);
113
115 SDF_API
116 bool HasDisplayUnit() const;
117
119 SDF_API
121
124 SDF_API
126
129 SDF_API
130 void SetColorSpace(const TfToken &colorSpace);
131
133 SDF_API
134 bool HasColorSpace() const;
135
137 SDF_API
139
143
147 SDF_API
149
151
155 SDF_API
156 SdfTimeSampleMap GetTimeSampleMap() const;
157
158 SDF_API
159 std::set<double> ListTimeSamples() const;
160
161 SDF_API
162 size_t GetNumTimeSamples() const;
163
164 SDF_API
165 bool GetBracketingTimeSamples(double time, double* tLower,
166 double* tUpper) const;
167
168 SDF_API
169 bool QueryTimeSample(double time, VtValue *value=NULL) const;
170 SDF_API
171 bool QueryTimeSample(double time, SdfAbstractDataValue *value) const;
172
173 template <class T>
174 bool QueryTimeSample(double time, T* data) const
175 {
176 if (!data) {
177 return QueryTimeSample(time);
178 }
179
180 SdfAbstractDataTypedValue<T> outValue(data);
181 const bool hasValue = QueryTimeSample(
182 time, static_cast<SdfAbstractDataValue *>(&outValue));
183
184 if (std::is_same<T, SdfValueBlock>::value) {
185 return hasValue && outValue.isValueBlock;
186 }
187
188 return hasValue && (!outValue.isValueBlock);
189 }
190
191 SDF_API
192 void SetTimeSample(double time, const VtValue & value);
193 SDF_API
194 void SetTimeSample(double time, const SdfAbstractDataConstValue& value);
195
196 template <class T>
197 void SetTimeSample(double time, const T& value)
198 {
199 const SdfAbstractDataConstTypedValue<T> inValue(&value);
200 const SdfAbstractDataConstValue& untypedInValue = inValue;
201 return SetTimeSample(time, untypedInValue);
202 }
203
204 SDF_API
205 void EraseTimeSample(double time);
206
208};
209
221SDF_API
222SdfAttributeSpecHandle
224 const SdfLayerHandle &layer,
225 const SdfPath &attrPath,
226 const SdfValueTypeName &typeName,
227 SdfVariability variability = SdfVariabilityVarying,
228 bool isCustom = false);
229
243SDF_API
244bool
246 const SdfLayerHandle &layer,
247 const SdfPath &attrPath,
248 const SdfValueTypeName &typeName,
249 SdfVariability variability = SdfVariabilityVarying,
250 bool isCustom = false);
251
252PXR_NAMESPACE_CLOSE_SCOPE
253
254#endif // PXR_USD_SDF_ATTRIBUTE_SPEC_H
SDF_API SdfAttributeSpecHandle SdfCreatePrimAttributeInLayer(const SdfLayerHandle &layer, const SdfPath &attrPath, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool isCustom=false)
Convenience function to create an attributeSpec on a primSpec at the given path, and any necessary pa...
SDF_API bool SdfJustCreatePrimAttributeInLayer(const SdfLayerHandle &layer, const SdfPath &attrPath, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool isCustom=false)
Convenience function to create an attributeSpec on a primSpec at the given path, and any necessary pa...
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:554
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:512
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:458
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:399
A subclass of SdfPropertySpec that holds typed data.
Definition: attributeSpec.h:40
SDF_API void SetAllowedTokens(const VtTokenArray &allowedTokens)
Sets the allowed tokens metadata for this attribute.
SDF_API bool HasDisplayUnit() const
Returns true if a display unit is set for this attribute.
SDF_API void SetDisplayUnit(const TfEnum &displayUnit)
Sets the display unit of the attribute.
SDF_API void ClearConnectionPaths()
Clears the connection paths for this attribute.
SDF_API void SetColorSpace(const TfToken &colorSpace)
Sets the color-space in which a color or texture valued attribute is authored.
SDF_API TfToken GetRoleName() const
Returns the roleName for this attribute's typeName.
SDF_API TfToken GetColorSpace() const
Returns the color-space in which a color or texture valued attribute is authored.
SDF_API void ClearDisplayUnit()
Clears the display unit of the attribute.
SDF_API bool HasConnectionPaths() const
Returns true if any connection paths are set on this attribute.
SDF_API VtTokenArray GetAllowedTokens() const
Returns the allowed tokens metadata for this attribute.
static SDF_API SdfAttributeSpecHandle New(const SdfPrimSpecHandle &owner, const std::string &name, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying, bool custom=false)
Constructs a new prim attribute instance.
SDF_API bool HasAllowedTokens() const
Returns true if allowed tokens metadata is set for this attribute.
SDF_API SdfConnectionsProxy GetConnectionPathList() const
Returns a proxy for editing the attribute's connection paths.
SDF_API void ClearAllowedTokens()
Clears the allowed tokens metadata for this attribute.
SDF_API TfEnum GetDisplayUnit() const
Returns the display unit of the attribute.
SDF_API void ClearColorSpace()
Clears the colorSpace metadata value set on this attribute.
SDF_API bool HasColorSpace() const
Returns true if this attribute has a colorSpace value authored.
Represents a set of list editing operations.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Base class for SdfAttributeSpec and SdfRelationshipSpec.
Definition: propertySpec.h:43
Represents a value type name, i.e.
Definition: valueTypeName.h:71
An enum class that records both enum type and enum value.
Definition: enum.h:120
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:147
Basic Sdf data types.
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:156
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
Definition: types.h:277