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

A Xentara attribute. More...

#include <model/Attribute.hpp>

Classes

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

Public Types

enum  Category { Configuration , Setting , Information , State }
 Categories of attributes. More...
 
enum  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<std::equality_comparable_with< std::string_view > String>
auto operator== (const String &rhs) const -> bool
 Checks the name of the attribute.
 

Static Public Member 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 *
 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 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.
 

Detailed Description

A Xentara attribute.

This class merely identifies the attribute, it does not represent the attribute of an individual element. To access the attribute of an element, use the type alias xentara::model::AttributeReference

See also
AttributeReference
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.

◆ Category

Categories of attributes.

Enumerator
Configuration 

A configuration attribute.

Setting 

A setting that can be changed at runtime to influence the behaviour.

Information 

An attribute that contains miscellaneous information.

State 

An attribute that describes the current state.

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
ioDirectionsThe 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 I/O points. If the directions contain the flag io::Direction::Input, then the data point will inherit this attribute from its input I/O point. If the directions contain the flag io::Direction::Output, then the data point will inherit this attribute from its output I/O point. 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.

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 I/O points.

◆ name()

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

Gets the name.

Returns
The name, in UTF-8 encoding

◆ operator==() [1/2]

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/2]

template<std::equality_comparable_with< std::string_view > 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 when resolving it. It is equivalent to name() == rhs.

Returns
Returns true if the attribute has the given name.

◆ 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

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

This function can be used in xentara::io::Component::resolveAttribute(), xentara::io::Io::resolveAttribute(), xentara::io::IoBatch::resolveAttribute(), or xentara::process::Microservice::resolveAttribute() to resolve a list of attributes by name.

Parameters
nameThe name of the desired attribute, in UTF-8 encoding
firstAttributeThe first attribute to check
moreAttributesAdditional attributes to check
Returns
Returns the first attribute in the list that matches the given name, or nullptr if none of them match
Examples
PublishingConfigAttributes.cpp.

◆ 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 I/O points.

◆ 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.

◆ 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.

◆ 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.