8#ifndef PXR_USD_USD_ATTRIBUTE_LIMITS_H
9#define PXR_USD_USD_ATTRIBUTE_LIMITS_H
11#include "pxr/usd/usd/attribute.h"
15#include "pxr/base/vt/value.h"
20PXR_NAMESPACE_OPEN_SCOPE
22#define USD_LIMITS_KEYS \
25 ((Minimum, "minimum")) \
26 ((Maximum, "maximum"))
29 UsdLimitsKeys, USD_API, USD_LIMITS_KEYS);
220 return _invalidValuesDict;
232 return _conformedSubDict;
244 explicit operator bool()
const {
250 return _success == rhs._success &&
251 _invalidValuesDict == rhs._invalidValuesDict &&
252 _conformedSubDict == rhs._conformedSubDict &&
253 _attrPath == rhs._attrPath &&
254 _attrTypeName == rhs._attrTypeName;
259 return !(*
this == rhs);
269 const std::string& attrTypeName)
271 _invalidValuesDict(invalidValuesDict),
272 _conformedSubDict(conformedSubDict),
274 _attrTypeName(attrTypeName) {}
277 bool _success =
false;
281 std::string _attrTypeName;
318 template <
typename T>
319 std::optional<T>
Get(
const TfToken& key)
const;
324 template <
typename T>
325 T
GetOr(
const TfToken& key,
const T& defaultValue)
const;
329 template <
typename T>
335 template <
typename T>
341 template <
typename T>
348 template <
typename T>
354 template <
typename T>
360 template <
typename T>
367 template <
typename T>
407 explicit operator bool()
const {
413 return _attr == rhs._attr && _subDictKey == rhs._subDictKey;
418 return !(*
this == rhs);
431inline std::optional<T>
440 SdfFieldKeys->Limits,
441 _MakeKeyPath(_subDictKey, key),
452 const T& defaultValue)
const
460 SdfFieldKeys->Limits,
461 _MakeKeyPath(_subDictKey, key),
478inline std::optional<T>
481 return Get<T>(UsdLimitsKeys->Minimum);
488 return GetOr<T>(UsdLimitsKeys->Minimum, defaultValue);
495 return Set(UsdLimitsKeys->Minimum, value);
499inline std::optional<T>
502 return Get<T>(UsdLimitsKeys->Maximum);
509 return GetOr<T>(UsdLimitsKeys->Maximum, defaultValue);
516 return Set(UsdLimitsKeys->Maximum, value);
519PXR_NAMESPACE_CLOSE_SCOPE
A path value used to locate objects in layers or scenegraphs.
Token for efficient comparison, assignment, and hashing of known strings.
bool IsEmpty() const
Returns true iff this token contains the empty string "".
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Validation information for a limits sub-dictionary.
bool Success() const
Return whether validation was successful.
bool operator==(const ValidationResult &rhs) const
Equality operator.
bool operator!=(const ValidationResult &rhs) const
Inequality operator.
USD_API std::string GetErrorString() const
Return a formatted error string describing the keys and values in the invalid values dictionary.
const VtDictionary & GetConformedSubDict() const
Return the conformed limits sub-dictionary.
ValidationResult()=default
Construct an empty result.
const VtDictionary & GetInvalidValuesDict() const
Return a dictionary containing values from the source sub-dictionary that did not match (and could no...
Provides API for retrieving and authoring values within a particular sub-dictionary of the limits dic...
bool SetMinimum(const T &value)
Set the minimum value in the limits sub-dictionary.
bool operator==(const UsdAttributeLimits &rhs) const
Equality operator.
T GetMaximumOr(const T &defaultValue) const
Return the maximum value from the limits sub-dictionary.
USD_API bool ClearMinimum()
Clear the authored minimum value opinion in the limits sub-dictionary.
USD_API bool HasAuthoredMaximum() const
Return whether an authored maximum value opinion exists in the limits sub-dictionary.
USD_API bool IsValid() const
Return whether the limits object is valid.
USD_API bool SetMaximum(const VtValue &value)
This is an overloaded member function, provided for convenience. It differs from the above function o...
T GetOr(const TfToken &key, const T &defaultValue) const
Return the value encoded under key in the limits sub-dictionary.
USD_API UsdAttributeLimits(const UsdAttribute &attr, const TfToken &subDictKey)
Construct a limits object for the sub-dictionary given by subDictKey in attr's limits dictionary.
std::optional< T > Get(const TfToken &key) const
Return the value encoded under key in the limits sub-dictionary.
std::optional< T > GetMaximum() const
Return the maximum value from the limits sub-dictionary.
USD_API UsdAttribute GetAttribute() const
Return the limits object's attribute.
USD_API bool Set(const TfToken &key, const VtValue &value)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool Set(const VtDictionary &subDict)
Set the entire limits sub-dictionary to subDict.
USD_API bool SetMinimum(const VtValue &value)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API VtValue GetMinimum() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
T GetMinimumOr(const T &defaultValue) const
Return the minimum value from the limits sub-dictionary.
USD_API bool Clear()
Clear all authored opinions for the limits sub-dictionary at the current edit target.
bool operator!=(const UsdAttributeLimits &rhs) const
Inequality operator.
USD_API bool HasAuthored() const
Return whether any authored opinions exist for the limits sub-dictionary.
USD_API bool Clear(const TfToken &key)
Clear the authored opinion for key in the limits sub-dictionary.
std::optional< T > GetMinimum() const
Return the minimum value from the limits sub-dictionary.
USD_API VtValue GetMaximum() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool SetMaximum(const T &value)
Set the maximum value in the limits sub-dictionary.
USD_API VtValue Get(const TfToken &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool HasAuthoredMinimum() const
Return whether an authored minimum value opinion exists in the limits sub-dictionary.
USD_API bool HasAuthored(const TfToken &key) const
Return whether an authored opinion for key exists in the limits sub-dictionary.
USD_API bool Validate(const VtDictionary &subDict, ValidationResult *result=nullptr) const
Return whether subDict is a valid limits sub-dictionary.
USD_API TfToken GetSubDictKey() const
Return the sub-dictionary key the limits object is using.
UsdAttributeLimits()=default
Construct an invalid limits object.
USD_API bool ClearMaximum()
Clear the authored maximum value opinion in the limits sub-dictionary.
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
Resolve the requested dictionary sub-element keyPath of dictionary-valued metadatum named key into va...
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...