|
OpenAssetIO
An abstract API for generalising interactions between a host application and an asset management system
|
A transport-level container for data exchange between a host and a manager. More...
#include <TraitsData.hpp>
Public Types | |
| using | Ptr = TraitsDataPtr |
| using | ConstPtr = TraitsDataConstPtr |
Public Member Functions | |
| ~TraitsData () | |
| Defaulted destructor. More... | |
| TraitsData & | operator= (const TraitsData &)=delete |
| Explicitly deleted copy assignment. More... | |
| TraitsData (TraitsData &&) noexcept=delete | |
| Explicitly deleted move construction. More... | |
| TraitsData & | operator= (TraitsData &&) noexcept=delete |
| Explicitly deleted move assignment. More... | |
| trait::TraitSet | traitSet () const |
| Return the trait IDs held by the instance. More... | |
| bool | hasTrait (const trait::TraitId &traitId) const |
| Return whether this instance has the given trait. More... | |
| void | addTrait (const trait::TraitId &traitId) |
| Add the specified trait to this instance. More... | |
| void | addTraits (const trait::TraitSet &traitSet) |
| Add the specified traits to this instance. More... | |
| bool | getTraitProperty (trait::property::Value *out, const trait::TraitId &traitId, const trait::property::Key &propertyKey) const |
| Get the value of a given trait property, if the property has been set. More... | |
| void | setTraitProperty (const trait::TraitId &traitId, const trait::property::Key &propertyKey, trait::property::Value propertyValue) |
| Set the value of given trait property. More... | |
| trait::property::KeySet | traitPropertyKeys (const trait::TraitId &traitId) const |
| Returns the properties set for a given trait. More... | |
| bool | operator== (const TraitsData &other) const |
| Compares instances for equality based on their trait and property values. More... | |
| bool | operator!= (const TraitsData &other) const |
| Compares instances for non-equality based on their trait and property values. More... | |
Static Public Member Functions | |
| static TraitsDataPtr | make () |
| Construct an empty instance, with no traits. More... | |
| static TraitsDataPtr | make (const trait::TraitSet &traitSet) |
| Construct such that this instance has the given set of traits. More... | |
| static TraitsDataPtr | make (const TraitsDataConstPtr &other) |
| Construct such that this instance is a deep copy of the other. More... | |
A transport-level container for data exchange between a host and a manager.
The Specification system combines one or more traits into a Trait Set to classify concepts within the API. Traits may define a number of simple-typed properties, allowing them to be used to exchange data between interested parties.
A key requirement of the traits system is to be fully run-time extensible. Additional specifications and traits can be defined as required by any particular API integration.
This is accomplished by breaking the system into two components:
TraitsData is the transport-layer container that holds a Trait Set, and any values set for the properties of these traits. It has no semantic understanding of the data, providing simple "by name" set/get of traits and their properties.
This allows easy serialization and exchange of this data between languages and sub-systems using the low-level introspection functionality provided by this class.
As generic access to the container's data (based on "well-known-strings") is inherently unstable. Instances of this class should generally be wrapped in one of the specialized specification or Trait derived "views" at runtime by a host or manager to ensure consistent access to the correct keys.
Trait property keys are always strings. Property values are strings, integers, floating point, or booleans. Any of a trait's properties can be legitimately left unset - it is up to the consumer (host or manager, depending on the API method) to decide how this should be handled.
| using ConstPtr = TraitsDataConstPtr |
| using Ptr = TraitsDataPtr |
| ~TraitsData | ( | ) |
Defaulted destructor.
|
deletenoexcept |
Explicitly deleted move construction.
| void addTrait | ( | const trait::TraitId & | traitId | ) |
Add the specified trait to this instance.
If this instance already has this trait, it is a no-op.
| traitId | ID of the trait to add. |
| void addTraits | ( | const trait::TraitSet & | traitSet | ) |
Add the specified traits to this instance.
If this instance already has any of the supplied traits, they are skipped.
| traitSet | A trait set with the traits to add. |
| bool getTraitProperty | ( | trait::property::Value * | out, |
| const trait::TraitId & | traitId, | ||
| const trait::property::Key & | propertyKey | ||
| ) | const |
Get the value of a given trait property, if the property has been set.
| [out] | out | Storage for result, only written to if the property is set. |
| traitId | ID of trait to query. | |
| propertyKey | Key of trait's property to query. |
true if value was found, false if it is unset. | <tt>std::out_of_range</tt> | if this instance does not have this trait. |
| bool hasTrait | ( | const trait::TraitId & | traitId | ) | const |
Return whether this instance has the given trait.
| traitId | ID of trait to check for. |
true if trait is present, false otherwise.
|
static |
Construct an empty instance, with no traits.
|
static |
Construct such that this instance has the given set of traits.
| traitSet | The constituent traits IDs. |
|
static |
Construct such that this instance is a deep copy of the other.
| other | The instance to copy. |
| bool operator!= | ( | const TraitsData & | other | ) | const |
Compares instances for non-equality based on their trait and property values.
| other | The instance to compare to. |
|
delete |
Explicitly deleted copy assignment.
|
deletenoexcept |
Explicitly deleted move assignment.
| bool operator== | ( | const TraitsData & | other | ) | const |
Compares instances for equality based on their trait and property values.
| other | The instance to compare to. |
| void setTraitProperty | ( | const trait::TraitId & | traitId, |
| const trait::property::Key & | propertyKey, | ||
| trait::property::Value | propertyValue | ||
| ) |
Set the value of given trait property.
If the instance does not yet have this trait, it will be added by this call.
| traitId | ID of trait to update. |
| propertyKey | Key of property to set. |
| propertyValue | Value to set. |
| trait::property::KeySet traitPropertyKeys | ( | const trait::TraitId & | traitId | ) | const |
Returns the properties set for a given trait.
If the trait has not been given to this instance, or the trait has no properties set, then it will return an empty set.
| trait::TraitSet traitSet | ( | ) | const |
Return the trait IDs held by the instance.
Copyright 2013-2023 The Foundry Visionmongers Ltd. OpenAssetIO is released under the Apache 2.0 License