![]() |
|
A non-owning type-erased view of a mutable lvalue, interoperating with VtValue. More...
#include <valueRef.h>
Inheritance diagram for VtMutableValueRef:Public Member Functions | |
| VtMutableValueRef ()=default | |
| Default ctor gives empty VtMutableValueRef. | |
| template<class T > | |
| VtMutableValueRef (T &obj) | |
| template<class T > | |
| VtMutableValueRef & | operator= (T &&obj) |
| Assign to the viewed value. | |
| template<class T > | |
| VtMutableValueRef & | UncheckedAssign (T &&obj) |
| template<class T > | |
| void | Swap (T &rhs) |
| Swap the viewed value with rhs. | |
| template<class T > | |
| void | UncheckedSwap (T &rhs) |
| Swap the viewed value with rhs. | |
| template<class T , class Fn > | |
| bool | Mutate (Fn &&mutateFn) |
If this value holds an object of type T, invoke mutateFn, passing it a non-const reference to the viewed object and return true. | |
| template<class T , class Fn > | |
| void | UncheckedMutate (Fn &&mutateFn) |
Invoke mutateFn, passing it a non-const reference to the viewed object which must be of type T. | |
Public Member Functions inherited from VtValueRef | |
| VtValueRef () | |
| Default ctor gives empty VtValueRef. | |
| VtValueRef (VtValueRef const &)=default | |
| VtValueRef (VtValueRef &&)=default | |
| template<class T > | |
| VtValueRef (T &&obj, std::enable_if_t< !std::is_same_v< std::decay_t< T >, VtValueRef > &&!std::is_same_v< std::decay_t< T >, VtValue > > *=0) | |
Implicitly convert or construct a VtValueRef referring to obj. | |
| VtValueRef & | operator= (VtValueRef const &ref)=default |
| Rebind to view the same object as another VtValueRef. | |
| VtValueRef & | operator= (VtValueRef &&ref)=default |
| template<class T > | |
| VtValueRef & | operator= (T &&)=delete |
| template<class T > | |
| bool | IsHolding () const |
Return true if this value is viewing an object of type T, false otherwise. | |
| bool | IsRValue () const |
Return true if this refers to an rvalue, and thus can be Remove()d by a move construction operation instead of a copy. | |
| VT_API bool | IsArrayValued () const |
| Return true if this views a VtArray instance, false otherwise. | |
| VT_API bool | IsArrayEditValued () const |
| Return true if this views a VtArrayEdit instance, false otherwise. | |
| size_t | GetArraySize () const |
| Return the number of elements in the viewed value if IsArrayValued(), return 0 otherwise. | |
| std::type_info const & | GetTypeid () const |
| Return the typeid of the type viewed by this value. | |
| std::type_info const & | GetElementTypeid () const |
| If this value views a VtArray or VtArrayEdit instance, return the typeid of its element type. | |
| VT_API TfType | GetType () const |
| Returns the TfType of the type viewed by this value. | |
| VT_API std::string | GetTypeName () const |
| Return the type name of the viewed typeid. | |
| int | GetKnownValueTypeIndex () const |
| Return VtKnownValueTypeIndex<T> for the viewed type T. | |
| template<class T > | |
| _TypeInfoFor< T >::GetObjResultType | UncheckedGet () const |
| Return a const reference to the viewed object if the viewed object is of type T. | |
| template<class T > | |
| _TypeInfoFor< T >::GetObjResultType | Get () const |
| Return a const reference to the viewed object if the viewed object is of type T. | |
| template<class T > | |
| T | GetWithDefault (T const &def=T()) const |
| Return a copy of the viewed object if the viewed object is of type T. | |
| template<class T > | |
| T | Remove () |
Return a move-constructed (if the viewed object is an rvalue) or copy-constructed T instance from the viewed object. | |
| template<class T > | |
| T | UncheckedRemove () |
Return a move-constructed (if the viewed object is an rvalue) or copy-constructed T instance from the viewed object. | |
| bool | IsEmpty () const |
| Returns true iff this value is empty. | |
| VT_API | operator VtValue () const |
| Implicitly convert to a VtValue by copying the viewed object. | |
| VT_API bool | CanHash () const |
| Return true if the viewed object provides a hash implementation. | |
| VT_API size_t | GetHash () const |
| Return a hash code for the viewed object by calling VtHashValue() on it. | |
| bool | CanComposeOver () const |
| Return true if this value holds a type that has been declared at compile time to support composing over other types. | |
| bool | CanTransform () const |
| Return true if this value holds a type that has been declared to support value transforms at compile time. | |
| bool | operator== (const VtValueRef &rhs) const |
| Test two values for equality. | |
| bool | operator!= (const VtValueRef &rhs) const |
Additional Inherited Members | |
Protected Types inherited from VtValueRef | |
| template<class T > | |
| using | _ArrayHelper = TfConditionalType< VtIsArray< T >::value, _IsArrayHelper< T >, TfConditionalType< VtIsArrayEdit< T >::value, _IsArrayEditHelper< T >, _NonArrayHelper< T > > > |
| template<class T > | |
| using | _TypeInfoFor = _TypeInfoImpl< std::decay_t< T >, std::is_reference_v< T > &&std::is_const_v< T > > |
Protected Member Functions inherited from VtValueRef | |
| VT_API size_t | _GetNumElements () const |
| template<class T > | |
| bool | _TypeIs () const |
| template<class T > | |
| _TypeInfoFor< T >::GetMutableObjResultType | _GetMutable () |
| template<class T > | |
| _TypeInfoFor< T >::GetObjResultType | _Get () const |
| VT_API void const * | _FailGet (Vt_DefaultValueHolder(*factory)(), std::type_info const &queryType) const |
| VT_API void | _FailRemove (std::type_info const &) |
| VT_API TfPyObjWrapper | _GetPythonObject () const |
Protected Attributes inherited from VtValueRef | |
| _RefdObjPtr | _ptr |
| _TypeInfo const * | _info |
A non-owning type-erased view of a mutable lvalue, interoperating with VtValue.
Since VtMutableValueRef is non-owning it must not persist beyond the lifetime of the value it views, and so it is typically best used as a function argument or an automatic variable.
Ordinary typed values are implicitly convertible to VtMutableValueRef. This makes it convenient to use when writing a function that can take an object of any type. Since it's non-owning, it is relatively light-weight, incurring no heap allocations or reference counting operations.
Definition at line 661 of file valueRef.h.
|
default |
Default ctor gives empty VtMutableValueRef.
|
inline |
Definition at line 668 of file valueRef.h.
|
inline |
If this value holds an object of type T, invoke mutateFn, passing it a non-const reference to the viewed object and return true.
Otherwise do nothing and return false.
Definition at line 731 of file valueRef.h.
|
inline |
Assign to the viewed value.
Definition at line 672 of file valueRef.h.
|
inline |
Swap the viewed value with rhs.
If this value is holding a T, make an unqualified call to swap(<viewed-value>, rhs). If this value is not holding a T, replace the viewed value with a value-initialized T instance first, then swap.
Definition at line 700 of file valueRef.h.
|
inline |
Definition at line 686 of file valueRef.h.
|
inline |
Invoke mutateFn, passing it a non-const reference to the viewed object which must be of type T.
If the viewed object is not of type T, this function invokes undefined behavior.
Definition at line 746 of file valueRef.h.
|
inline |
Swap the viewed value with rhs.
This VtValue must be holding an object of type T. If it does not, this invokes undefined behavior. Use Swap() if this VtValue is not known to contain an object of type T.
Definition at line 718 of file valueRef.h.