Bifrost SDK
Bifrost SDK documentation
Bifrost::PropertyGuard< T > Class Template Reference

This class is a RAII guard for a Bifrost::Object property. More...

#include <GeoPropertyGuard.h>

Public Member Functions

 PropertyGuard ()=default
 Creates an invalid guard. More...
 
 ~PropertyGuard ()
 Destroyes the guard and sets the property value back into the Object. More...
 
 PropertyGuard (const PropertyGuard &)=delete
 Copy constructor is deleted. More...
 
PropertyGuardoperator= (const PropertyGuard &)=delete
 
 PropertyGuard (PropertyGuard &&io) noexcept
 Moving a guard is allowed. More...
 
PropertyGuardoperator= (PropertyGuard &&io) noexcept
 Moving a guard is allowed. More...
 
 operator bool () const noexcept
 Check if this PropertyGuard has acquired a property. More...
 
const T & operator* () const noexcept
 Returns the value of the property. More...
 
T & operator* () noexcept
 Returns the value of the property. noexcept More...
 
const T * operator-> () const noexcept
 Returns a pointer to the property. More...
 
T * operator-> () noexcept
 Returns a pointer to the property. noexcept More...
 

Friends

PropertyGuard< T > createPropGuard (Bifrost::Object &, Amino::StringView)
 Create a PropertyGuard for the given object and property name. More...
 

Detailed Description

template<typename T>
class Bifrost::PropertyGuard< T >

This class is a RAII guard for a Bifrost::Object property.

Template Parameters
TThe data type of the property.

This class is used to extract, modify and then set back a property value within a Bifrost::object. This is the preferred method to modify a property of an Object since extracting the property does not increase its reference count, and thus if there are no other references to the value, it will be modified in-place and no copy-on-write will occur. See Amino::Ptr for more details on reference counting.

Do not construct a PropertyGuard directly. Use Bifrost::createPropGuard instead.

Definition at line 147 of file GeoPropertyGuard.h.

Constructor & Destructor Documentation

◆ PropertyGuard() [1/3]

template<typename T >
Bifrost::PropertyGuard< T >::PropertyGuard ( )
default

Creates an invalid guard.

◆ ~PropertyGuard()

template<typename T >
Bifrost::PropertyGuard< T >::~PropertyGuard ( )
inline

Destroyes the guard and sets the property value back into the Object.

Definition at line 153 of file GeoPropertyGuard.h.

References Bifrost::Object::setProperty().

◆ PropertyGuard() [2/3]

template<typename T >
Bifrost::PropertyGuard< T >::PropertyGuard ( const PropertyGuard< T > &  )
delete

Copy constructor is deleted.

◆ PropertyGuard() [3/3]

template<typename T >
Bifrost::PropertyGuard< T >::PropertyGuard ( PropertyGuard< T > &&  io)
inlinenoexcept

Moving a guard is allowed.

Definition at line 164 of file GeoPropertyGuard.h.

Member Function Documentation

◆ operator bool()

template<typename T >
Bifrost::PropertyGuard< T >::operator bool ( ) const
inlineexplicitnoexcept

Check if this PropertyGuard has acquired a property.

Definition at line 183 of file GeoPropertyGuard.h.

◆ operator*() [1/2]

template<typename T >
const T & Bifrost::PropertyGuard< T >::operator* ( ) const
inlinenoexcept

Returns the value of the property.

Definition at line 186 of file GeoPropertyGuard.h.

◆ operator*() [2/2]

template<typename T >
T & Bifrost::PropertyGuard< T >::operator* ( )
inlinenoexcept

Returns the value of the property. noexcept

noexcept

Definition at line 192 of file GeoPropertyGuard.h.

◆ operator->() [1/2]

template<typename T >
const T * Bifrost::PropertyGuard< T >::operator-> ( ) const
inlinenoexcept

Returns a pointer to the property.

Definition at line 198 of file GeoPropertyGuard.h.

◆ operator->() [2/2]

template<typename T >
T * Bifrost::PropertyGuard< T >::operator-> ( )
inlinenoexcept

Returns a pointer to the property. noexcept

noexcept

Definition at line 204 of file GeoPropertyGuard.h.

◆ operator=() [1/2]

template<typename T >
PropertyGuard & Bifrost::PropertyGuard< T >::operator= ( const PropertyGuard< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
PropertyGuard & Bifrost::PropertyGuard< T >::operator= ( PropertyGuard< T > &&  io)
inlinenoexcept

Moving a guard is allowed.

Definition at line 172 of file GeoPropertyGuard.h.

Friends And Related Function Documentation

◆ createPropGuard

template<typename T >
PropertyGuard< T > createPropGuard ( Bifrost::Object object,
Amino::StringView  propertyName 
)
friend

Create a PropertyGuard for the given object and property name.

Parameters
[in,out]objectThe input object.
[in]propertyNameThe name of the property to extract.
Returns
A PropertyGuard RAII class that extracts the property with type T and name propertyName from object and sets the property back when the guard is destructed.

Definition at line 122 of file GeoPropertyGuard.h.