xentara-plugin v2.0.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::model::Attribute Class Referencefinal

A Xentara attribute. More...

#include <xentara/model/Attribute.hpp>

Classes

class  Role
 A built-in attribute role. More...
 

Public Types

enum class  Access { ReadOnly , WriteOnly , ReadWrite }
 An Access type for an attribute. More...
 

Public Member Functions

constexpr Attribute (const Role &role, Access access, std::reference_wrapper< const data::DataType > dataType)
 Constructor for attributes with built-in roles.
 
constexpr Attribute (const utils::core::Uuid &uuid, std::string_view name, Access access, std::reference_wrapper< const data::DataType > dataType, io::Directions ioDirections={})
 Constructor for custom attributes.
 
auto name () const -> const std::string_view &
 Gets the name.
 
auto uuid () const -> const utils::core::Uuid &
 Gets the UUID.
 
auto access () const -> Access
 Gets the access modes.
 
auto dataType () const -> const data::DataType &
 Gets the data type.
 
auto ioDirections () const -> io::Directions
 Gets the relevant I/O directions.
 
auto setAccess (Access access) -> void
 Sets the access modes.
 
auto setDataType (std::reference_wrapper< const data::DataType > dataType) -> void
 Sets the data type.
 
auto setIoDirections (io::Directions ioDirections) -> void
 Sets the relevant I/O directions.
 
auto operator== (const Attribute &rhs) const -> bool
 Checks whether a reference refers to this attribute.
 
template<utils::tools::EqualityComparableWithExcept< std::string_view, Attribute > String>
auto operator== (const String &rhs) const -> bool
 Checks the name of the attribute.
 
template<utils::tools::EqualityComparableWithExcept< utils::core::Uuid, Attribute > UUID>
auto operator== (const UUID &rhs) const -> bool
 Checks the UUID of the attribute.
 
auto operator== (const Role &rhs) const -> bool
 Checks the role of the attribute.
 

Static Public Member Functions

Deprecated Functions
template<std::equality_comparable_with< std::string_view > String, typename... Attributes>
static auto resolve (const String &name, const Attribute &firstAttribute, const Attributes &... moreAttributes) -> const Attribute *
 deprecated Checks the name of a list of attributes and returns the first one that matches
 

Static Public Attributes

Standard Attributes
static const Attribute kPrimaryKey
 The attribute for the primary key of an element.
 
static const Attribute kName
 The attribute for the name of an element.
 
static const Attribute kUuid
 The attribute for the UUID of an element.
 
static const Attribute kType
 The attribute for the type (class) of an element.
 
static const Attribute kCategory
 The attribute for the element category of an element.
 
static const Attribute kSourceTime
 The attribute for the time stamp of a value provided by the data source, like the device.
 
static const Attribute kUpdateTime
 The attribute for the update time stamp of a value.
 
static const Attribute kChangeTime
 The attribute for the change time stamp of a value.
 
static const Attribute kWriteTime
 The attribute for the time stamp of the last attempted write operation of an output.
 
static const Attribute kQuality
 The attribute for the quality of a value.
 
static const Attribute kDeviceState
 The attribute for the state of a device.
 
Standard Roles
static const Role kValue
 The role for a value.
 
static const Role kError
 The standard name for an error.
 
static const Role kWriteError
 The standard name for a write error.
 
Standard Names
static const std::string_view kAddress
 The standard name for an address.
 
static const std::string_view kOffset
 The standard name for an offset.
 
static const std::string_view kLength
 The standard name for a length.
 
static const std::string_view kChannel
 The standard name for a channel.
 
static const std::string_view kDataType
 The role for a data type.
 
Deprecated Constants
static constexpr Access ReadOnly
 deprecated Unscoped access to Access::ReadOnly
 
static constexpr Access WriteOnly
 deprecated Unscoped access to Access::WriteOnly
 
static constexpr Access ReadWrite
 deprecated Unscoped access to Access::ReadWrite
 

Detailed Description

A Xentara attribute.

Note
This class merely identifies the attribute, it does not represent the attribute of an individual element. To access the attribute of a specific Xentara element, use the the class ElementAttribute.
See also
ElementAttribute
Attributes in the Xentara user manual
Examples
PublishingConfigAttributes.cpp.

Member Enumeration Documentation

◆ Access

An Access type for an attribute.

Enumerator
ReadOnly 

The attribute supports reading only.

WriteOnly 

The attribute supports writing only.

ReadWrite 

The attribute supports reading and writing.

Constructor & Destructor Documentation

◆ Attribute() [1/2]

constexpr xentara::model::Attribute::Attribute ( const Role role,
Access  access,
std::reference_wrapper< const data::DataType dataType 
)
constexpr

Constructor for attributes with built-in roles.

Parameters
roleThe role of the attribute.
accessThe possible access modes for the attribute
dataTypeThe data type of the attribute

◆ Attribute() [2/2]

constexpr xentara::model::Attribute::Attribute ( const utils::core::Uuid uuid,
std::string_view  name,
Access  access,
std::reference_wrapper< const data::DataType dataType,
io::Directions  ioDirections = {} 
)
constexpr

Constructor for custom attributes.

Parameters
uuidThe UUID of the attribute
nameThe name of the attribute, in UTF-8 encoding. The string data the view references to is not copied. It must remain valid for the lifetime of the plugin.

To keep naming conventions as consistent as possible between plugins, Xentara provides a set of predefined attribute names. All things being equal, you should prefer using one of the predefines names. If the documentation, the specification, or common usage for your plugin use different nomenclature, however, you should prefer that over the standard names.

If your attribute references another element, you sould use the name of the element. If your attribute references an I/O device, for example, you should use xentara::io::ComponentClass::kDevice as the name.

Parameters
accessThe possible access modes for the attribute
dataTypeThe data type of the attribute
ioDirections

The relevant I/O directions.

The I/O directions are used for I/O attributes to specify whether a data point should inherit this attribute from its attached input and/or output. If the directions contain the flag io::Direction::Input, then the data point will inherit this attribute from its input. If the directions contain the flag io::Direction::Output, then the data point will inherit this attribute from its output. If you do not set either flag (the default), then the attribute will not be considered an I/O attribute and will not be inherited by any data points.

Member Function Documentation

◆ access()

auto xentara::model::Attribute::access ( ) const -> Access

Gets the access modes.

◆ dataType()

auto xentara::model::Attribute::dataType ( ) const -> const data::DataType &

Gets the data type.

◆ ioDirections()

auto xentara::model::Attribute::ioDirections ( ) const -> io::Directions

Gets the relevant I/O directions.

Returns
The I/O directions. The I/O directions are used for I/O attributes to specify whether a data point should inherit this attribute from its attached input and/or output.

◆ name()

auto xentara::model::Attribute::name ( ) const -> const std::string_view &

Gets the name.

Returns
The name, in UTF-8 encoding

◆ operator==() [1/4]

auto xentara::model::Attribute::operator== ( const Attribute rhs) const -> bool

Checks whether a reference refers to this attribute.

This operator checks the identity of the objects, not the properties. The operator returns true only if the rhs refers to the same object as this. It is equivalent to this == std::addressof(rhs).

Returns
Returns true if the attribute has the given name.

◆ operator==() [2/4]

auto xentara::model::Attribute::operator== ( const Role rhs) const -> bool

Checks the role of the attribute.

This is a convenience operator you can use to check the UUID of an attribute. It is equivalent to uuid() == rhs.uuid().

Returns
Returns true if the attribute has the same UUID as the role.

◆ operator==() [3/4]

template<utils::tools::EqualityComparableWithExcept< std::string_view, Attribute > String>
auto xentara::model::Attribute::operator== ( const String &  rhs) const -> bool

Checks the name of the attribute.

This is a convenience operator you can use to check the name of an attribute. It is equivalent to name() == rhs.

Returns
Returns true if the attribute has the given name.

◆ operator==() [4/4]

template<utils::tools::EqualityComparableWithExcept< utils::core::Uuid, Attribute > UUID>
auto xentara::model::Attribute::operator== ( const UUID &  rhs) const -> bool

Checks the UUID of the attribute.

This is a convenience operator you can use to check the UUID of an attribute. It is equivalent to uuid() == rhs.

Returns
Returns true if the attribute has the given UUID.

◆ resolve()

template<std::equality_comparable_with< std::string_view > String, typename... Attributes>
static auto xentara::model::Attribute::resolve ( const String &  name,
const Attribute firstAttribute,
const Attributes &...  moreAttributes 
) -> const Attribute *
static

deprecated Checks the name of a list of attributes and returns the first one that matches

Deprecated:
This function is no longer used

◆ setAccess()

auto xentara::model::Attribute::setAccess ( Access  access) -> void

Sets the access modes.

◆ setDataType()

auto xentara::model::Attribute::setDataType ( std::reference_wrapper< const data::DataType dataType) -> void

Sets the data type.

◆ setIoDirections()

auto xentara::model::Attribute::setIoDirections ( io::Directions  ioDirections) -> void

Sets the relevant I/O directions.

Parameters
ioDirectionsThe desired I/O directions. The I/O directions are used for I/O attributes to specify whether a data point should inherit this attribute from its attached input and/or output.

◆ uuid()

auto xentara::model::Attribute::uuid ( ) const -> const utils::core::Uuid &

Gets the UUID.

Member Data Documentation

◆ kAddress

const std::string_view xentara::model::Attribute::kAddress
static

The standard name for an address.

◆ kCategory

const Attribute xentara::model::Attribute::kCategory
static

The attribute for the element category of an element.

◆ kChangeTime

const Attribute xentara::model::Attribute::kChangeTime
static

The attribute for the change time stamp of a value.

◆ kChannel

const std::string_view xentara::model::Attribute::kChannel
static

The standard name for a channel.

◆ kDataType

const std::string_view xentara::model::Attribute::kDataType
static

The role for a data type.

◆ kDeviceState

const Attribute xentara::model::Attribute::kDeviceState
static

The attribute for the state of a device.

◆ kError

const Role xentara::model::Attribute::kError
static

The standard name for an error.

◆ kLength

const std::string_view xentara::model::Attribute::kLength
static

The standard name for a length.

◆ kName

const Attribute xentara::model::Attribute::kName
static

The attribute for the name of an element.

◆ kOffset

const std::string_view xentara::model::Attribute::kOffset
static

The standard name for an offset.

◆ kPrimaryKey

const Attribute xentara::model::Attribute::kPrimaryKey
static

The attribute for the primary key of an element.

◆ kQuality

const Attribute xentara::model::Attribute::kQuality
static

The attribute for the quality of a value.

◆ kSourceTime

const Attribute xentara::model::Attribute::kSourceTime
static

The attribute for the time stamp of a value provided by the data source, like the device.

◆ kType

const Attribute xentara::model::Attribute::kType
static

The attribute for the type (class) of an element.

◆ kUpdateTime

const Attribute xentara::model::Attribute::kUpdateTime
static

The attribute for the update time stamp of a value.

◆ kUuid

const Attribute xentara::model::Attribute::kUuid
static

The attribute for the UUID of an element.

◆ kValue

const Role xentara::model::Attribute::kValue
static

The role for a value.

◆ kWriteError

const Role xentara::model::Attribute::kWriteError
static

The standard name for a write error.

◆ kWriteTime

const Attribute xentara::model::Attribute::kWriteTime
static

The attribute for the time stamp of the last attempted write operation of an output.

◆ ReadOnly

constexpr Access xentara::model::Attribute::ReadOnly
staticconstexpr

deprecated Unscoped access to Access::ReadOnly

Deprecated:
This is a backwards compatibility constant to account for the formerly unscoped enum Attribute::Access

◆ ReadWrite

constexpr Access xentara::model::Attribute::ReadWrite
staticconstexpr

deprecated Unscoped access to Access::ReadWrite

Deprecated:
This is a backwards compatibility constant to account for the formerly unscoped enum Attribute::Access

◆ WriteOnly

constexpr Access xentara::model::Attribute::WriteOnly
staticconstexpr

deprecated Unscoped access to Access::WriteOnly

Deprecated:
This is a backwards compatibility constant to account for the formerly unscoped enum Attribute::Access