Bifrost SDK
Bifrost SDK documentation
Bifrost::Object Class Referenceabstract

An interface for dictionary-like objects. More...

#include <Object.h>

Classes

struct  Property
 A property in a Bifrost::Object. More...
 

Public Member Functions

 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
Interface description

This ifndef guard should not be used to lie to the CppParser!

virtual size_t size () const noexcept=0
 Returns the number of properties in the object. More...
 
virtual bool empty () const noexcept=0
 Check if this object is empty. More...
 
virtual bool hasProperty (Amino::StringView key) const noexcept=0
 Check if the property exists. More...
 
virtual Amino::Any getProperty (Amino::StringView key) const noexcept=0
 Get a property. More...
 
virtual Amino::Any extractProperty (Amino::StringView key) noexcept=0
 Extract a property. The property is removed and returned. More...
 
virtual bool eraseProperty (Amino::StringView key) noexcept=0
 Erase a property. More...
 
virtual void eraseAllProperties () noexcept=0
 Clear the object. After size() == 0 and empty() is true. More...
 
virtual Amino::Ptr< Amino::Array< Amino::String > > keys () const noexcept=0
 Get all of the keys stored in this object. More...
 
template<typename T >
bool setProperty (Amino::StringView key, T &&value) noexcept
 Set a property. Replace or add depending on if the property already exists or not in the object. More...
 
template<typename S , typename T >
std::enable_if< std::is_same< std::decay_t< S >, Amino::String >::value, bool >::type setProperty (S &&key, T &&value) noexcept
 Set a property. Replace or add depending on if the property already exists or not in the object. More...
 

Static Public Member Functions

static bool isA (Object const &object, Object const &prototype)
 Check if a given object contains all of the properties of the specified prototype. More...
 

Protected Member Functions

 Object (Object &&) noexcept=default
 Only subclasses allowed to use copy/move constructor/assignments. More...
 
 Object (Object const &)=default
 Only subclasses allowed to use copy/move constructor/assignments. More...
 
Objectoperator= (Object &&) noexcept=default
 Only subclasses allowed to use copy/move constructor/assignments. More...
 
Objectoperator= (Object const &)=default
 Only subclasses allowed to use copy/move constructor/assignments. More...
 
virtual bool setPropertyAny (Amino::StringView key, Amino::Any value) noexcept=0
 Set a property with an Amino::Any. More...
 
virtual bool setPropertyAny (Amino::String const &key, Amino::Any value) noexcept=0
 Set a property with an Amino::Any. More...
 

Detailed Description

An interface for dictionary-like objects.

The Object interface class specifies the methods to be implemented by a class that needs to be handled as a Object.

Classes that implement of this interface are assumed to:

Definition at line 59 of file Object.h.

Constructor & Destructor Documentation

◆ Object() [1/3]

Bifrost::Object::Object ( )

Constructor.

◆ ~Object()

virtual Bifrost::Object::~Object ( )
virtual

Destructor.

◆ Object() [2/3]

Bifrost::Object::Object ( Object &&  )
protecteddefaultnoexcept

Only subclasses allowed to use copy/move constructor/assignments.

The Object not is publicly copiable/movable because it's a pure virtual class. The copy/move constructor and assignments are still defaulted but protected, to allows subclasses to = default their copy/move constructor and assignments if they want to.

◆ Object() [3/3]

Bifrost::Object::Object ( Object const &  )
protecteddefault

Only subclasses allowed to use copy/move constructor/assignments.

The Object not is publicly copiable/movable because it's a pure virtual class. The copy/move constructor and assignments are still defaulted but protected, to allows subclasses to = default their copy/move constructor and assignments if they want to.

Member Function Documentation

◆ empty()

virtual bool Bifrost::Object::empty ( ) const
pure virtualnoexcept

Check if this object is empty.

Returns
True if empty, else False.

◆ eraseAllProperties()

virtual void Bifrost::Object::eraseAllProperties ( )
pure virtualnoexcept

Clear the object. After size() == 0 and empty() is true.

◆ eraseProperty()

virtual bool Bifrost::Object::eraseProperty ( Amino::StringView  key)
pure virtualnoexcept

Erase a property.

Parameters
[in]keyThe property's name
Returns
True if the property was erased (removed from the object)

◆ extractProperty()

virtual Amino::Any Bifrost::Object::extractProperty ( Amino::StringView  key)
pure virtualnoexcept

Extract a property. The property is removed and returned.

Parameters
[in]keyThe property's name to extract.
Returns
A non-empty Amino::Any if the property existed

◆ getProperty()

virtual Amino::Any Bifrost::Object::getProperty ( Amino::StringView  key) const
pure virtualnoexcept

Get a property.

Parameters
[in]keyThe property name to fetch
Returns
The property. The Amino::Any will be empty if no such property was found in the object or if the property was found but its associated value is an empty Amino::Any.

◆ hasProperty()

virtual bool Bifrost::Object::hasProperty ( Amino::StringView  key) const
pure virtualnoexcept

Check if the property exists.

Parameters
[in]keyThe property's name.
Returns
True if the property exists in the object.

◆ isA()

static bool Bifrost::Object::isA ( Object const &  object,
Object const &  prototype 
)
static

Check if a given object contains all of the properties of the specified prototype.

This check is recursive. If the prototype's value is an object, then isA is also called to check that the object's property contains all the property of the prototypes's property.

Parameters
[in]objectThe reference to the object to check if it matches the prototype.
[in]prototypeThe reference to the prototype object to compare with.
Returns
True if the object contains all of the properties that the prototype object contains; false otherwise.

Referenced by Bifrost::Geometry::findPrototype().

◆ keys()

virtual Amino::Ptr< Amino::Array< Amino::String > > Bifrost::Object::keys ( ) const
pure virtualnoexcept

Get all of the keys stored in this object.

Returns
Return a ptr to an array of the keys. See Ptr.h for more information.

◆ operator=() [1/2]

Object & Bifrost::Object::operator= ( Object &&  )
protecteddefaultnoexcept

Only subclasses allowed to use copy/move constructor/assignments.

The Object not is publicly copiable/movable because it's a pure virtual class. The copy/move constructor and assignments are still defaulted but protected, to allows subclasses to = default their copy/move constructor and assignments if they want to.

◆ operator=() [2/2]

Object & Bifrost::Object::operator= ( Object const &  )
protecteddefault

Only subclasses allowed to use copy/move constructor/assignments.

The Object not is publicly copiable/movable because it's a pure virtual class. The copy/move constructor and assignments are still defaulted but protected, to allows subclasses to = default their copy/move constructor and assignments if they want to.

◆ setProperty() [1/2]

template<typename T >
bool Bifrost::Object::setProperty ( Amino::StringView  key,
T &&  value 
)
noexcept

Set a property. Replace or add depending on if the property already exists or not in the object.

Parameters
[in]keyThe property's name.
[in]valueThe value of this property.

Referenced by Bifrost::Geometry::populateDataGeoProperty(), Bifrost::PropertyGuard< T >::~PropertyGuard(), and Bifrost::PropertyGuard< Amino::Ptr< T > >::~PropertyGuard().

◆ setProperty() [2/2]

template<typename S , typename T >
std::enable_if< std::is_same< std::decay_t< S >, Amino::String >::value, bool >::type Bifrost::Object::setProperty ( S &&  key,
T &&  value 
)
noexcept

Set a property. Replace or add depending on if the property already exists or not in the object.

Parameters
[in]keyThe property's name.
[in]valueThe value of this property.

◆ setPropertyAny() [1/2]

virtual bool Bifrost::Object::setPropertyAny ( Amino::String const &  key,
Amino::Any  value 
)
protectedpure virtualnoexcept

Set a property with an Amino::Any.

Prefer using setProperty instead of this method. Use this method only when the Amino::Any being passed in comes from getProperty(). For example when copying properties from one object to another.

Replace or add depending on if the property already exists or not in the object.

Parameters
[in]keyThe property's name.
[in]valueA Amino::Any.

◆ setPropertyAny() [2/2]

virtual bool Bifrost::Object::setPropertyAny ( Amino::StringView  key,
Amino::Any  value 
)
protectedpure virtualnoexcept

Set a property with an Amino::Any.

Prefer using setProperty instead of this method. Use this method only when the Amino::Any being passed in comes from getProperty(). For example when copying properties from one object to another.

Replace or add depending on if the property already exists or not in the object.

Parameters
[in]keyThe property's name.
[in]valueA Amino::Any.

◆ size()

virtual size_t Bifrost::Object::size ( ) const
pure virtualnoexcept

Returns the number of properties in the object.