xentara-plugin v2.0.1
The Xentara Plugin Framework
Loading...
Searching...
No Matches
xentara::data Namespace Reference

Classes

class  DataType
 A custom type. More...
 
class  FixedValue
 A helper class that allows constructing read handles that return fixed values. More...
 
class  ReadHandle
 A handle for reading a data value. More...
 
class  WriteHandle
 A handle for writing a data value. More...
 

Typedefs

template<NativeType kNativeType, TypeUsage kUsage = TypeUsage::Get>
using NativeTypeToCppType = typename __opaque_find_native_cpp_type__< kNativeType, kUsage >::type
 The C++ type associated with a specific NativeType enum.
 
using Qualities = utils::core::Flags< Quality >
 A combination of different qualities.
 

Enumerations

enum class  NativeType {
  Boolean , Integer , UnsignedInteger , FloatingPoint ,
  String , WString , U8String , U16String ,
  U32String , TimePoint , Uuid , Quality ,
  ElementCategory , ErrorCode , Custom , None
}
 An enum describing different types of native C++ data used in read and write handles. More...
 
enum class  TypeUsage { Get , Put }
 usage for a type when converting between NativeType and C++ types More...
 
enum class  Quality : std::uint8_t { Good , Acceptable , Unreliable , Bad , internal }
 A Quality for a data point value. More...
 

Functions

template<typename CppType >
constexpr auto cppTypeToNativeType (TypeUsage usage=TypeUsage::Put) noexcept -> NativeType
 Find the correct NativeType enum to use for a C++ type.
 
template<utils::tools::CharType Char>
auto toBasicString (Quality quality) -> std::basic_string_view< Char >
 Converts a quality value to a string.
 
template auto toBasicString< char > (Quality quality) -> std::basic_string_view< char >
 
template auto toBasicString< wchar_t > (Quality quality) -> std::basic_string_view< wchar_t >
 
template auto toBasicString< char8_t > (Quality quality) -> std::basic_string_view< char8_t >
 
template auto toBasicString< char16_t > (Quality quality) -> std::basic_string_view< char16_t >
 
template auto toBasicString< char32_t > (Quality quality) -> std::basic_string_view< char32_t >
 
auto toString (Quality quality) -> std::string_view
 Converts a quality value to a string of type char
 
auto toWString (Quality quality) -> std::wstring_view
 Converts a quality value to a string of type wchar_t
 
auto toU8String (Quality quality) -> std::u8string_view
 Converts a quality value to a string of type char8_t
 
auto toU16String (Quality quality) -> std::u16string_view
 Converts a quality value to a string of type char16_t
 
auto toU32String (Quality quality) -> std::u32string_view
 Converts a number to a string of type char32_t
 
constexpr auto isBetter (Quality quality, Quality referenceQuality) noexcept -> bool
 Determines if one quality is better than another quality.
 
constexpr auto isWorse (Quality quality, Quality referenceQuality) noexcept -> bool
 Determines if one quality is worse than another quality.
 
template<std::convertible_to< Quality >... MoreQualities>
constexpr auto combine (Quality firstQuality, MoreQualities &&... moreQualities) noexcept -> Quality
 Picks the worse of a number of qualities.
 
constexpr auto isUsable (Quality quality) noexcept -> bool
 Determines if a quality is usable, i.e. if the corresponding value can be relied upon.
 
template<typename Error1 , typename Error2 >
constexpr auto selectError (Quality quality1, Error1 &&error1, Quality quality2, Error2 &&error2) -> std::common_type< Error1, Error2 >
 Selects one of two error messages depending on two corresponding qualities.
 
auto operator<< (std::ostream &stream, Quality quality) -> std::ostream &
 Stream insertion operator for qualities.
 
auto operator<< (utils::cbor::Encoder &encoder, Quality quality) -> utils::cbor::Encoder &
 Encodes a quality to a CBOR encoder.
 
auto operator>> (utils::cbor::Decoder &decoder, Quality &quality) -> utils::cbor::Decoder &
 Decodes a quality from a CBOR encoder.
 
template<class Type >
 FixedValue (Type) -> FixedValue< Type >
 Deduction guide for a fixed value passed by value.
 
template auto ReadHandle::read< std::string > () const -> utils::eh::expected< std::string, std::error_code >
 
template auto ReadHandle::read< std::wstring > () const -> utils::eh::expected< std::wstring, std::error_code >
 
template auto ReadHandle::read< std::u8string > () const -> utils::eh::expected< std::u8string, std::error_code >
 
template auto ReadHandle::read< std::u16string > () const -> utils::eh::expected< std::u16string, std::error_code >
 
template auto ReadHandle::read< std::u32string > () const -> utils::eh::expected< std::u32string, std::error_code >
 
template auto ReadHandle::read< std::chrono::system_clock::time_point > () const -> utils::eh::expected< std::chrono::system_clock::time_point, std::error_code >
 
template auto ReadHandle::read< utils::core::Uuid > () const -> utils::eh::expected< utils::core::Uuid, std::error_code >
 
template auto ReadHandle::read< model::ElementCategory > () const -> utils::eh::expected< model::ElementCategory, std::error_code >
 
template auto ReadHandle::read< std::error_code > () const -> utils::eh::expected< std::error_code, std::error_code >
 

Typedef Documentation

◆ NativeTypeToCppType

template<NativeType kNativeType, TypeUsage kUsage = TypeUsage::Get>
using xentara::data::NativeTypeToCppType = typedef typename __opaque_find_native_cpp_type__<kNativeType, kUsage>::type

The C++ type associated with a specific NativeType enum.

This type alias represents the C++ type associated with a particular NativeType value.

Special cases:

◆ Qualities

A combination of different qualities.

Include file
#include <xentara/data/Quality.hpp>

Enumeration Type Documentation

◆ NativeType

enum class xentara::data::NativeType
strong

An enum describing different types of native C++ data used in read and write handles.

This enum provides a hint as to the best C++ data type to use when calling ReadHandle::read() or WriteHandle::write().

See also
ReadHandle
WriteHandle
Enumerator
Boolean 

The best C++ type is bool

Integer 

The best C++ type is std::intmax_t.

UnsignedInteger 

The best C++ type is std::uintmax_t.

FloatingPoint 

The best C++ type is double

String 

The best C++ type is std::string for reading and std::string_view for writing.

WString 

The best C++ type is std::wstring for reading and std::wstring_view for writing.

U8String 

The best C++ type is std::u8string for reading and std::u8string_view for writing.

U16String 

The best C++ type is std::u16string for reading and std::u16string_view for writing.

U32String 

The best C++ type is std::u32string for reading and std::u32string_view for writing.

TimePoint 

The best C++ type is std::chrono::system_clock::time_point.

Uuid 

The best C++ type is xentara::utils::core::Uuid.

Quality 

The best C++ type is xentara::data::Quality.

ElementCategory 

The best C++ type is xentara::model::ElementCategory.

ErrorCode 

The best C++ type is std::error_code.

Custom 

The best C++ type is some custom type specific to some plugin.

This enum value denotes that the data is stored internally as some custom type specific to a plugin, like a custom enum type. 
None 

The handle is does not represent any data.

This type is used for error handles. Error handles are handles that never read or write any data, but always return an error
from [read()](@ref ReadHandle::read()) or [write(@ref ]WriteHandle::write()). 

◆ Quality

enum class xentara::data::Quality : std::uint8_t
strong

A Quality for a data point value.

Include file
#include <xentara/data/Quality.hpp>
See also
Data Quality in the Xentara user manual
Enumerator
Good 

The value was successfully acquired.

Values with this quality have been acquired in the normal way without any errors or issues.

Acceptable 

The value was acquired in an acceptable way, but some problem occurred.

Values with this quality were acquired successfully, but may have reduced precision or accuracy. This may be due to using an alternate, inferior data source, to some non-critical error situation, or because a sensor or such is operating under conditions where the accuracy is reduced.

Values with quality Quality::Acceptable can still be used as inputs to control circuits, simulations, etc., but the results may not be as good as when using values with quality Quality::Good.

Calculated or derived values that are based on values with this quality should themselves not be flagged with a quality better than Quality::Acceptable.

Unreliable 

There was a problem acquiring the value, and it should not be relied upon.

Values with this quality can used for informational purposes, but are not reliable enough for system critical uses, such as control ciruits, safety systems, etc.

Calculated or derived values that are based on values with this quality should themselves not be flagged with a quality better than Quality::Unreliable.

Bad 

The value could not be acquired correctly.

Values with this quality either could not be acquired at all, or a serious error was encountered, like exceeding the range of a sensor.

Calculated or derived values that are based on values with this quality should themselves be flagged as Quality::Bad. Expensive operations, such as executing FMUs or AI models, can be skipped altogether, and some default or fallback value used as the output instead (also with quality Quality::Bad, of course).

◆ TypeUsage

enum class xentara::data::TypeUsage
strong

usage for a type when converting between NativeType and C++ types

Enumerator
Get 

The type is used to get a value from a producer.

Put 

The type is used to pass a value to a consumer.

Function Documentation

◆ combine()

template<std::convertible_to< Quality >... MoreQualities>
constexpr auto xentara::data::combine ( Quality  firstQuality,
MoreQualities &&...  moreQualities 
) -> Quality
constexprnoexcept

Picks the worse of a number of qualities.

Parameters
firstQualityThe first quality to consider
moreQualitiesAny number of additional qualities to consider
Returns
The worst of all the qualities.
Include file
#include <xentara/data/Quality.hpp>

◆ cppTypeToNativeType()

template<typename CppType >
constexpr auto xentara::data::cppTypeToNativeType ( TypeUsage  usage = TypeUsage::Put) -> NativeType
constexprnoexcept

Find the correct NativeType enum to use for a C++ type.

This function returns the NativeType value that is used for a specific C++ type.

This template is available for all C++ types, not only the canonical native C++ type, as returned by NativeTypeToCppType. For non-canonical types, the function will return the best fitting native type.

If no suitable standard NativeType value is exists, then the function will return value NativeType::Custom.

Template Parameters
CppType

The C++ type to convert. References and cv-qualifiers are removed using std::remove_cvref before checking the type.

The type is not limited to the canonical native C++ type, as returned by NativeTypeToCppType, any C++ type can be used, and the best fitting NativeType value will be returned.

Parameters
usage

The usage for the C++ type. Specify TypeUsage::Get if you are reading the value from producer, and TypeUsage::Put if you are writing the value to a aconsumer. This will affect some types:

Returns
The best fitting native type, or NativeType::Custom if no suitable native type is found.
See also
NativeTypeToCppType

◆ FixedValue()

template<class Type >
xentara::data::FixedValue ( Type  ) -> FixedValue< Type >

Deduction guide for a fixed value passed by value.

◆ isBetter()

constexpr auto xentara::data::isBetter ( Quality  quality,
Quality  referenceQuality 
) -> bool
constexprnoexcept

Determines if one quality is better than another quality.

Parameters
qualityThe quality value to check
referenceQualityThe quality value to compare with
Returns
Returns true if quality is better than referenceQuality
Include file
#include <xentara/data/Quality.hpp>

◆ isUsable()

constexpr auto xentara::data::isUsable ( Quality  quality) -> bool
constexprnoexcept

Determines if a quality is usable, i.e. if the corresponding value can be relied upon.

Parameters
qualityThe quality value to check
Returns
Returns true if quality is Quality::Good or Quality::Acceptable.
Include file
#include <xentara/data/Quality.hpp>

◆ isWorse()

constexpr auto xentara::data::isWorse ( Quality  quality,
Quality  referenceQuality 
) -> bool
constexprnoexcept

Determines if one quality is worse than another quality.

Parameters
qualityThe quality value to check
referenceQualityThe quality value to compare with
Returns
Returns true if quality is worse than referenceQuality
Include file
#include <xentara/data/Quality.hpp>

◆ operator<<() [1/2]

auto xentara::data::operator<< ( std::ostream stream,
Quality  quality 
) -> std::ostream &

Stream insertion operator for qualities.

Parameters
streamThe stream
qualityThe quality value
Returns
The stream
Include file
#include <xentara/data/Quality.hpp>

◆ operator<<() [2/2]

auto xentara::data::operator<< ( utils::cbor::Encoder encoder,
Quality  quality 
) -> utils::cbor::Encoder &

Encodes a quality to a CBOR encoder.

Parameters
encoderThe encoder
qualityThe quality
Returns
A reference to the encoder

◆ operator>>()

auto xentara::data::operator>> ( utils::cbor::Decoder decoder,
Quality quality 
) -> utils::cbor::Decoder &

Decodes a quality from a CBOR encoder.

Parameters
decoderThe decoder
qualityThe quality
Returns
A reference to the decoder

◆ ReadHandle::read< model::ElementCategory >()

◆ ReadHandle::read< std::chrono::system_clock::time_point >()

template auto xentara::data::ReadHandle::read< std::chrono::system_clock::time_point > ( ) const -> utils::eh::expected< std::chrono::system_clock::time_point, std::error_code >
extern

◆ ReadHandle::read< std::error_code >()

◆ ReadHandle::read< std::string >()

◆ ReadHandle::read< std::u16string >()

◆ ReadHandle::read< std::u32string >()

◆ ReadHandle::read< std::u8string >()

◆ ReadHandle::read< std::wstring >()

◆ ReadHandle::read< utils::core::Uuid >()

◆ selectError()

template<typename Error1 , typename Error2 >
constexpr auto xentara::data::selectError ( Quality  quality1,
Error1 &&  error1,
Quality  quality2,
Error2 &&  error2 
) -> std::common_type<Error1, Error2>
constexpr

Selects one of two error messages depending on two corresponding qualities.

Parameters
quality1The quality that corresponds to error1
error1The error that corresponds to quality1
quality2The quality that corresponds to error2
error2The error that corresponds to quality2
Returns
Returns error2 if quality2 is worse than quality1, otherwise returns error1.
Include file
#include <xentara/data/Quality.hpp>

◆ toBasicString()

template<utils::tools::CharType Char>
auto xentara::data::toBasicString ( Quality  quality) -> std::basic_string_view< Char >

Converts a quality value to a string.

Parameters
qualityThe quality value
Returns
A string containing the quality as a UTF-8 text
Include file
#include <xentara/data/Quality.hpp>

◆ toBasicString< char >()

template auto xentara::data::toBasicString< char > ( Quality  quality) -> std::basic_string_view< char >
extern

◆ toBasicString< char16_t >()

template auto xentara::data::toBasicString< char16_t > ( Quality  quality) -> std::basic_string_view< char16_t >
extern

◆ toBasicString< char32_t >()

template auto xentara::data::toBasicString< char32_t > ( Quality  quality) -> std::basic_string_view< char32_t >
extern

◆ toBasicString< char8_t >()

template auto xentara::data::toBasicString< char8_t > ( Quality  quality) -> std::basic_string_view< char8_t >
extern

◆ toBasicString< wchar_t >()

template auto xentara::data::toBasicString< wchar_t > ( Quality  quality) -> std::basic_string_view< wchar_t >
extern

◆ toString()

auto xentara::data::toString ( Quality  quality) -> std::string_view

Converts a quality value to a string of type char

Parameters
qualityThe quality value
Returns
A string containing the quality
Include file
#include <xentara/data/Quality.hpp>

◆ toU16String()

auto xentara::data::toU16String ( Quality  quality) -> std::u16string_view

Converts a quality value to a string of type char16_t

Parameters
qualityThe quality value
Returns
A string containing the quality
Include file
#include <xentara/data/Quality.hpp>

◆ toU32String()

auto xentara::data::toU32String ( Quality  quality) -> std::u32string_view

Converts a number to a string of type char32_t

Parameters
qualityThe quality value
Returns
A string containing the quality
Include file
#include <xentara/data/Quality.hpp>

◆ toU8String()

auto xentara::data::toU8String ( Quality  quality) -> std::u8string_view

Converts a quality value to a string of type char8_t

Parameters
qualityThe quality value
Returns
A string containing the quality
Include file
#include <xentara/data/Quality.hpp>

◆ toWString()

auto xentara::data::toWString ( Quality  quality) -> std::wstring_view

Converts a quality value to a string of type wchar_t

Parameters
qualityThe quality value
Returns
A string containing the quality
Include file
#include <xentara/data/Quality.hpp>