|
nmealib 0.0.4
NMEA 0183/NMEA 2000 parsing library
|
Strongly typed numeric wrapper for NMEA 2000 custom data types. More...
#include <dataTypes.h>
Public Types | |
| using | RawType = typename Traits::RawType |
| Raw external type. | |
| using | TargetType = typename Traits::TargetType |
| Target type for higher-level fields that expect a specific physical type. | |
Public Member Functions | |
| constexpr bool | isValid () const noexcept |
| Checks whether the stored value is within configured bounds. | |
| constexpr TargetType | getValue () const noexcept |
| Returns the normalized physical value. | |
| RawType | getRaw () const noexcept |
| Converts physical value to raw integer representation. | |
| std::string | toString () const |
| Converts the value to a fixed-point string. | |
| constexpr bool | operator== (const DataType &other) const noexcept |
| constexpr bool | operator!= (const DataType &other) const noexcept |
| constexpr bool | operator< (const DataType &other) const noexcept |
| constexpr bool | operator<= (const DataType &other) const noexcept |
| constexpr bool | operator> (const DataType &other) const noexcept |
| constexpr bool | operator>= (const DataType &other) const noexcept |
Static Public Member Functions | |
| static DataType | fromValue (TargetType value) |
| Constructs from a physical value. | |
| static constexpr DataType | fromRaw (RawType raw) noexcept |
| Constructs from a raw value. | |
Static Public Attributes | |
| static constexpr double | MIN = Traits::MIN |
| Minimum representable value for this type. | |
| static constexpr double | MAX = Traits::MAX |
| Maximum representable value for this type. | |
| static constexpr double | RESOLUTION = Traits::RESOLUTION |
| Resolution (least significant physical unit step). | |
Strongly typed numeric wrapper for NMEA 2000 custom data types.
This template models NMEA 2000 custom numeric types where a physical value is represented with:
MIN, MAX),RESOLUTION),Internally, values are stored as double and normalized to the configured resolution in the constructor.
| Traits | Traits type defining bounds and resolution. |
Traits must define:
Definition at line 56 of file dataTypes.h.
| using nmealib::nmea2000::DataType< Traits >::RawType = typename Traits::RawType |
Raw external type.
Definition at line 65 of file dataTypes.h.
| using nmealib::nmea2000::DataType< Traits >::TargetType = typename Traits::TargetType |
Target type for higher-level fields that expect a specific physical type.
Definition at line 67 of file dataTypes.h.
|
inlinestaticconstexprnoexcept |
Constructs from a raw value.
The raw value is converted to physical units by multiplying with RESOLUTION.
| raw | Raw integer value representing the physical quantity. |
Definition at line 97 of file dataTypes.h.
|
inlinestatic |
Constructs from a physical value.
The input is clamped to [MIN, MAX] and rounded to the nearest multiple of RESOLUTION.
| value | Physical value. |
Definition at line 77 of file dataTypes.h.
|
inlinenoexcept |
Converts physical value to raw integer representation.
The conversion follows: raw = round(value / RESOLUTION).
Definition at line 128 of file dataTypes.h.
|
inlineconstexprnoexcept |
Returns the normalized physical value.
Definition at line 113 of file dataTypes.h.
|
inlineconstexprnoexcept |
Checks whether the stored value is within configured bounds.
true if MIN <= value <= MAX, otherwise false. Definition at line 105 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 153 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 156 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 159 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 150 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 162 of file dataTypes.h.
|
inlineconstexprnoexcept |
Definition at line 165 of file dataTypes.h.
|
inline |
Converts the value to a fixed-point string.
The number of decimal digits is derived from RESOLUTION.
Definition at line 139 of file dataTypes.h.
|
staticconstexpr |
Maximum representable value for this type.
Definition at line 61 of file dataTypes.h.
|
staticconstexpr |
Minimum representable value for this type.
Definition at line 59 of file dataTypes.h.
|
staticconstexpr |
Resolution (least significant physical unit step).
Definition at line 63 of file dataTypes.h.