Loading...
Searching...
No Matches
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
125 SDF_API
127
130 SDF_API
131 void SetColorSpace(const TfToken &colorSpace);
132
134 SDF_API
135 bool HasColorSpace() const;
136
138 SDF_API
140
144
148 SDF_API
150
152
156 SDF_API
157 SdfTimeSampleMap GetTimeSampleMap() const;
158
159 SDF_API
160 std::set<double> ListTimeSamples() const;
161
162 SDF_API
163 size_t GetNumTimeSamples() const;
164
165 SDF_API
166 bool GetBracketingTimeSamples(double time, double* tLower,
167 double* tUpper) const;
168
169 SDF_API
170 bool QueryTimeSample(double time, VtValue *value=NULL) const;
171 SDF_API
172 bool QueryTimeSample(double time, SdfAbstractDataValue *value) const;
173
174 template <class T>
175 bool QueryTimeSample(double time, T* data) const
176 {
177 if (!data) {
178 return QueryTimeSample(time);
179 }
180
181 SdfAbstractDataTypedValue<T> outValue(data);
182 const bool hasValue = QueryTimeSample(
183 time, static_cast<SdfAbstractDataValue *>(&outValue));
184
185 if (std::is_same<T, SdfValueBlock>::value) {
186 return hasValue && outValue.isValueBlock;
187 }
188
189 return hasValue && (!outValue.isValueBlock);
190 }
191
192 SDF_API
193 void SetTimeSample(double time, const VtValue & value);
194 SDF_API
195 void SetTimeSample(double time, const SdfAbstractDataConstValue& value);
196
197 template <class T>
198 void SetTimeSample(double time, const T& value)
199 {
200 const SdfAbstractDataConstTypedValue<T> inValue(&value);
201 const SdfAbstractDataConstValue& untypedInValue = inValue;
202 return SetTimeSample(time, untypedInValue);
203 }
204
205 SDF_API
206 void EraseTimeSample(double time);
207
209};
210
222SDF_API
223SdfAttributeSpecHandle
225 const SdfLayerHandle &layer,
226 const SdfPath &attrPath,
227 const SdfValueTypeName &typeName,
228 SdfVariability variability = SdfVariabilityVarying,
229 bool isCustom = false);
230
244SDF_API
245bool
247 const SdfLayerHandle &layer,
248 const SdfPath &attrPath,
249 const SdfValueTypeName &typeName,
250 SdfVariability variability = SdfVariabilityVarying,
251 bool isCustom = false);
252
253PXR_NAMESPACE_CLOSE_SCOPE
254
255#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:572
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:530
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:476
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:417
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