16#ifndef BIFROST_GEOMETRY_GEO_PROPERTY_GUARD_H
17#define BIFROST_GEOMETRY_GEO_PROPERTY_GUARD_H
64class DataGeoPropertyGuard;
66class RangeGeoPropertyGuard;
117 auto any =
object.getProperty(propertyName);
123 return hasProperty<T>(
object, propertyName)
131 return createPropGuard<Amino::Ptr<T>>(object, propertyName);
154 if (m_object !=
nullptr) {
155 m_object->
setProperty(m_propertyName, std::move(m_property));
165 : m_object(std::exchange(io.m_object,
nullptr))
166 , m_propertyName(std::move(io.m_propertyName))
167 , m_property(std::move(io.m_property))
175 m_object = std::exchange(io.m_object,
nullptr);
176 m_propertyName = std::move(io.m_propertyName);
177 m_property = std::move(io.m_property);
183 explicit operator bool() const noexcept {
return m_object !=
nullptr; }
187 assert(m_object !=
nullptr);
193 assert(m_object !=
nullptr);
199 assert(m_object !=
nullptr);
205 assert(m_object !=
nullptr);
213 : m_object(&object), m_propertyName(
std::move(propertyName)) {
215 m_property = Amino::any_cast<T>(std::move(any));
230 if (m_object !=
nullptr) {
231 m_object->
setProperty(m_propertyName, std::move(m_property));
239 : m_object(std::exchange(io.m_object,
nullptr))
240 , m_propertyName(std::move(io.m_propertyName))
241 , m_property(std::move(io.m_property))
248 m_object = std::exchange(io.m_object,
nullptr);
249 m_propertyName = std::move(io.m_propertyName);
250 m_property = std::move(io.m_property);
255 explicit operator bool() const noexcept {
return m_object !=
nullptr; }
258 assert(m_object !=
nullptr);
263 assert(m_object !=
nullptr);
268 assert(m_object !=
nullptr);
269 return m_property.get();
273 assert(m_object !=
nullptr);
274 return m_property.get();
283 : m_object(&object), m_propertyName(
std::move(propertyName)) {
285 auto constProp = Amino::any_cast<Amino::Ptr<T>>(std::move(any));
286 m_property = constProp.toMutable();
304 if (!propObj)
return false;
307 auto dataArray = Bifrost::Geometry::getDataGeoPropValues<T>(geometry, property);
308 return dataArray !=
nullptr;
345 explicit operator bool() const noexcept {
return static_cast<bool>(m_property); }
411 return hasDataGeoProperty<T>(geometry, propertyName)
445 explicit operator bool() const noexcept {
return static_cast<bool>(m_property); }
A resizable container of contiguous elements.
Smart pointers used to allow custom user classes (opaque classes) to be used within Amino graphs....
String view class (similar to std::string_view)
Definition of macros for symbol visibility.
#define BIFROST_GEOMETRY_DECL
Utility functions for manipulating Geometry Properties that conform to the geometry schema.
Bifrost object interface declaration.
Amino::Ptr< Bifrost::Object > BIFROST_GEOMETRY_DECL getDataGeoProperty(const Bifrost::Object &object, Amino::StringView property)
Get a geo property from an object, with the specified name.
Ptr(MutablePtr< T >) -> Ptr< T >
Deduction guide for Ptr.
PropertyGuard< Amino::Ptr< T > > createPtrPropGuard(Bifrost::Object &object, Amino::StringView propertyName)
Create a PropertyGuard for an Amino::Ptr<T> property.
bool hasProperty(const Bifrost::Object &object, Amino::StringView propertyName)
Check if an object has a property with type T and name propertyName.
PropertyGuard< T > createPropGuard(Bifrost::Object &object, Amino::StringView propertyName)
Create a PropertyGuard for the given object and property name.
bool hasDataGeoProperty(const Bifrost::Object &geometry, Amino::StringView property)
Check if a geometry object has a valid geo property with type T and name property.
DataGeoPropertyGuard< T > createDataGeoPropGuard(Bifrost::Object &geometry, Amino::StringView propertyName)
Create a DataGeoPropertyGuard for the specified geo property.
BIFROST_GEOMETRY_DECL Amino::String const sIndices
BIFROST_GEOMETRY_DECL Amino::String const sInterp
BIFROST_GEOMETRY_DECL bool hasRangeGeoProperty(const Bifrost::Object &geometry, Amino::StringView property)
Check if a geometry object has a valid Range geo property with name property.
BIFROST_GEOMETRY_DECL Amino::String const sData
BIFROST_GEOMETRY_DECL RangeGeoPropertyGuard createRangeGeoPropGuard(Bifrost::Object &geometry, Amino::StringView propertyName)
Create a RangeGeoPropertyGuard for the specified range geo property.
BIFROST_GEOMETRY_DECL Amino::String const sDependsOn
BIFROST_GEOMETRY_DECL Amino::String const sTarget
BIFROST_GEOMETRY_DECL Amino::String const sDefault
Generic value class that allows for storage of a value of any type.
TypeId type() const noexcept
Returns the TypeId of the value in this Any, or the TypeId of void if this Any does not have a value.
Define a Amino array of elements of type T.
Transient version of Amino::Ptr<T> which allows mutable access to the pointee.
The string class used by Amino.
String view class (similar to std::string_view).
This class is a RAII guard for a Bifrost::Object property.
PropertyGuard()=default
Creates an invalid guard.
PropertyGuard(PropertyGuard &&io) noexcept
Moving a guard is allowed.
T & operator*() noexcept
Returns the value of the property. noexcept
PropertyGuard(const PropertyGuard &)=delete
Copy constructor is deleted.
T * operator->() noexcept
Returns a pointer to the property. noexcept
~PropertyGuard()
Destroyes the guard and sets the property value back into the Object.
PropertyGuard & operator=(PropertyGuard &&io) noexcept
Moving a guard is allowed.
const T & operator*() const noexcept
Returns the value of the property.
PropertyGuard & operator=(const PropertyGuard &)=delete
const T * operator->() const noexcept
Returns a pointer to the property.
This class is a RAII guard for a Data geo property.
const Amino::Array< Amino::String > & dependsOn() const noexcept
Returns the value of the depends_on field in the geo property.
const Amino::Array< T > & data() const noexcept
Returns the data array of the geo property.
Amino::Array< T > & data() noexcept
Returns the data array of the geo property.
Amino::String & target() noexcept
Returns the target of the geo property.
Amino::Array< Amino::String > & dependsOn() noexcept
Returns the value of the depends_on field in the geo property.
const Bifrost::Geometry::Common::DataInterpolationMode & interpolationMode() const noexcept
Returns the interpolation_mode field in the geo property.
T & defaultValue() noexcept
Returns the default value of the geo property.
Bifrost::Geometry::Common::DataInterpolationMode & interpolationMode() noexcept
Returns the interpolation_mode field in the geo property.
const T & defaultValue() const noexcept
Returns the default value of the geo property.
const Amino::String & target() const noexcept
Returns the target of the geo property.
DataGeoPropertyGuard()=default
Constructor.
PropertyGuard & operator=(PropertyGuard &&io) noexcept
PropertyGuard(PropertyGuard &&io) noexcept
const T & operator*() const noexcept
T * operator->() noexcept
const T * operator->() const noexcept
PropertyGuard(const PropertyGuard &)=delete
PropertyGuard & operator=(const PropertyGuard &)=delete
This class is a RAII guard for a Range geo property.
const Amino::String & target() const noexcept
Returns the target of the geo property.
Amino::String & target() noexcept
Returns the target of the geo property.
const Amino::Array< Amino::String > & dependsOn() const noexcept
Returns the value of the depends_on field in the geo property.
Amino::Array< Bifrost::Geometry::Index > & indices() noexcept
Returns the index array of the geo property.
Amino::Array< Amino::String > & dependsOn() noexcept
Returns the value of the depends_on field in the geo property.
const Amino::Array< Bifrost::Geometry::Index > & indices() const noexcept
Returns the index array of the geo property.
RangeGeoPropertyGuard()=default
Constructor.
An interface for dictionary-like objects.
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.
virtual Amino::Any extractProperty(Amino::StringView key) noexcept=0
Extract a property. The property is removed and returned.