xentara-cpp-control v1.0.1
The Xentara C++ Control Framework
Loading...
Searching...
No Matches
xentara::Input< Type > Class Template Referencefinal

An class that represents a single input for a control. More...

#include <xentara/Input.hpp>

Public Member Functions

 Input ()
 Constructor.
 
 Input (const Element &dataPoint)
 Constructor with datapoint Element.
 
auto operator= (const Element &dataPoint) -> Input &
 Assignment operator that sets the data point to read from.
 
auto read (RunContext &context) const -> Type
 Reads a value from the data point.
 

Related Symbols

(Note that these are not member symbols.)

using BooleanInput = Input< bool >
 A type alias for an input that reads the data point as a C++ bool.
 
using SCharInput = Input< signed char >
 A type alias for an input that reads the data point as an signed char.
 
using UCharInput = Input< unsigned char >
 A type alias for an input that reads the data point as an unsigned char.
 
using ShortInput = Input< short >
 A type alias for an input that reads the data point as a short.
 
using UShortInput = Input< unsigned short >
 A type alias for an input that reads the data point as an unsigned short.
 
using IntInput = Input< int >
 A type alias for an input that reads the data point as an integer.
 
using UIntInput = Input< unsigned int >
 A type alias for an input that reads the data point as an unsigned integer.
 
using LongInput = Input< long >
 A type alias for an input that reads the data point as a long.
 
using ULongInput = Input< unsigned long >
 A type alias for an input that reads the data point as an unsigned long.
 
using LongLongInput = Input< long long >
 A type alias for an input that reads the data point as a long long.
 
using ULongLongInput = Input< unsigned long long >
 A type alias for an input that reads the data point as an unsigned long long.
 
using FloatInput = Input< float >
 A type alias for an input that reads the data point as a float.
 
using DoubleInput = Input< double >
 A type alias for an input that reads the data point as a double.
 
using UInt8Input = Input< std::uint8_t >
 A type alias for an input that reads the data point as a 8 bit unsigned integer.
 
using UInt16Input = Input< std::uint16_t >
 A type alias for an input that reads the data point as a 16 bit unsigned integer.
 
using UInt32Input = Input< std::uint32_t >
 A type alias for an input that reads the data point as a 32 bit unsigned integer.
 
using UInt64Input = Input< std::uint64_t >
 A type alias for an input that reads the data point as a 64 bit unsigned integer.
 
using Int8Input = Input< std::int8_t >
 A type alias for an input that reads the data point as a 8 bit signed integer.
 
using Int16Input = Input< std::int16_t >
 A type alias for an input that reads the data point as a 16 bit signed integer.
 
using Int32Input = Input< std::int32_t >
 A type alias for an input that reads the data point as a 32 bit signed integer.
 
using Int64Input = Input< std::int64_t >
 A type alias for an input that reads the data point as a 64 bit signed integer.
 
using Float32Input = Input< float >
 A type alias for an input that reads the data point as a 32 bit floating point.
 
using Float64Input = Input< double >
 A type alias for an input that reads the data point as a 64 bit floating point.
 
using StringInput = Input< std::string >
 A type alias for an input that reads the data point as a string.
 
using WStringInput = Input< std::wstring >
 A type alias for an input that reads the data point as a wstring.
 
using U8StringInput = Input< std::u8string >
 A type alias for an input that reads the data point as a u8string.
 
using U16StringInput = Input< std::u16string >
 A type alias for an input that reads the data point as a u16string.
 
using U32StringInput = Input< std::u32string >
 A type alias for an input that reads the data point as a u32string.
 
using UUIDInput = Input< xentara::utils::core::Uuid >
 A type alias for an input that reads the data point as a UUID.
 
using TimePointInput = Input< std::chrono::system_clock::time_point >
 A type alias for an input that reads the data point as a time point.
 

Detailed Description

template<typename Type>
class xentara::Input< Type >

An class that represents a single input for a control.

This class is used to define the inputs for your control code. You must declare one member of this class in your control class for each input your control code needs to read. The input must then be attached to an actual Xentara data point in the initialize() callback of your control class using the element assignment operator.

Template Parameters
TypeThe C++ type for the read value.

Constructor & Destructor Documentation

◆ Input() [1/2]

template<typename Type >
xentara::Input< Type >::Input ( )

Constructor.

◆ Input() [2/2]

template<typename Type >
xentara::Input< Type >::Input ( const Element dataPoint)

Constructor with datapoint Element.

Parameters
dataPointThe data point to read from. This can be a data point returned by Config::getDataPoint() or Model::findDataPoint().
Exceptions
std::runtime_errorThe requested element is not a data point in the Xentara model tree
std::runtime_errorThe requested element has quality read handle error
std::runtime_errorThe requested element has value read handle error

Member Function Documentation

◆ operator=()

template<typename Type >
auto xentara::Input< Type >::operator= ( const Element dataPoint) -> Input &

Assignment operator that sets the data point to read from.

Parameters
dataPointThe data point to read from. This can be a data point returned by Config::getDataPoint() or Model::findDataPoint().
Returns
A reference to this object
Exceptions
std::runtime_errorThe requested element is not a data point in the Xentara model tree
std::runtime_errorThe requested element has quality read handle error
std::runtime_errorThe requested element has value read handle error

◆ read()

template<typename Type >
auto xentara::Input< Type >::read ( RunContext context) const -> Type

Reads a value from the data point.

The read value will be converted to the type specified by the Type template parameter, if possible. If the value cannot be converted, the function will set the type mismatch error in the run context.

The read function first checks the quality of the input. If the quality is bad, it will set the BadQuality error in the context and do nothing further. If the quality is not bad, it tries to read the value of the datapoint. If there is any error such as OutOfRange or TypeMismatch and so on, it will set the error code in the context and do nothing further. A default Type() will be returned in case of error. After read function, you need to check for error in the context.

Parameters
contextThe run context passed to the step() callback of your control class.
Returns
The value read from the data point element.

Friends And Related Symbol Documentation

◆ BooleanInput

template<typename Type >
using BooleanInput = Input<bool>
related

A type alias for an input that reads the data point as a C++ bool.

◆ DoubleInput

template<typename Type >
using DoubleInput = Input<double>
related

A type alias for an input that reads the data point as a double.

◆ Float32Input

template<typename Type >
using Float32Input = Input<float>
related

A type alias for an input that reads the data point as a 32 bit floating point.

◆ Float64Input

template<typename Type >
using Float64Input = Input<double>
related

A type alias for an input that reads the data point as a 64 bit floating point.

◆ FloatInput

template<typename Type >
using FloatInput = Input<float>
related

A type alias for an input that reads the data point as a float.

◆ Int16Input

template<typename Type >
using Int16Input = Input<std::int16_t>
related

A type alias for an input that reads the data point as a 16 bit signed integer.

◆ Int32Input

template<typename Type >
using Int32Input = Input<std::int32_t>
related

A type alias for an input that reads the data point as a 32 bit signed integer.

◆ Int64Input

template<typename Type >
using Int64Input = Input<std::int64_t>
related

A type alias for an input that reads the data point as a 64 bit signed integer.

◆ Int8Input

template<typename Type >
using Int8Input = Input<std::int8_t>
related

A type alias for an input that reads the data point as a 8 bit signed integer.

◆ IntInput

template<typename Type >
using IntInput = Input<int>
related

A type alias for an input that reads the data point as an integer.

◆ LongInput

template<typename Type >
using LongInput = Input<long>
related

A type alias for an input that reads the data point as a long.

◆ LongLongInput

template<typename Type >
using LongLongInput = Input<long long>
related

A type alias for an input that reads the data point as a long long.

◆ SCharInput

template<typename Type >
using SCharInput = Input<signed char>
related

A type alias for an input that reads the data point as an signed char.

◆ ShortInput

template<typename Type >
using ShortInput = Input<short>
related

A type alias for an input that reads the data point as a short.

◆ StringInput

template<typename Type >
using StringInput = Input<std::string>
related

A type alias for an input that reads the data point as a string.

◆ TimePointInput

template<typename Type >
using TimePointInput = Input<std::chrono::system_clock::time_point>
related

A type alias for an input that reads the data point as a time point.

◆ U16StringInput

template<typename Type >
using U16StringInput = Input<std::u16string>
related

A type alias for an input that reads the data point as a u16string.

◆ U32StringInput

template<typename Type >
using U32StringInput = Input<std::u32string>
related

A type alias for an input that reads the data point as a u32string.

◆ U8StringInput

template<typename Type >
using U8StringInput = Input<std::u8string>
related

A type alias for an input that reads the data point as a u8string.

◆ UCharInput

template<typename Type >
using UCharInput = Input<unsigned char>
related

A type alias for an input that reads the data point as an unsigned char.

◆ UInt16Input

template<typename Type >
using UInt16Input = Input<std::uint16_t>
related

A type alias for an input that reads the data point as a 16 bit unsigned integer.

◆ UInt32Input

template<typename Type >
using UInt32Input = Input<std::uint32_t>
related

A type alias for an input that reads the data point as a 32 bit unsigned integer.

◆ UInt64Input

template<typename Type >
using UInt64Input = Input<std::uint64_t>
related

A type alias for an input that reads the data point as a 64 bit unsigned integer.

◆ UInt8Input

template<typename Type >
using UInt8Input = Input<std::uint8_t>
related

A type alias for an input that reads the data point as a 8 bit unsigned integer.

◆ UIntInput

template<typename Type >
using UIntInput = Input<unsigned int>
related

A type alias for an input that reads the data point as an unsigned integer.

◆ ULongInput

template<typename Type >
using ULongInput = Input<unsigned long>
related

A type alias for an input that reads the data point as an unsigned long.

◆ ULongLongInput

template<typename Type >
using ULongLongInput = Input<unsigned long long>
related

A type alias for an input that reads the data point as an unsigned long long.

◆ UShortInput

template<typename Type >
using UShortInput = Input<unsigned short>
related

A type alias for an input that reads the data point as an unsigned short.

◆ UUIDInput

A type alias for an input that reads the data point as a UUID.

◆ WStringInput

template<typename Type >
using WStringInput = Input<std::wstring>
related

A type alias for an input that reads the data point as a wstring.