Data types
The Huxon language provide several common data types to be used for creating applications. All the data types are located within the hux namespace.
When developing applications it is important not to make any assumption on the number of bytes for types such as int. Indeed, the code written with the Huxon language might be compiled and deployed on systems ranging from low-power embedded devices to high-end servers over which the number of bytes used by int differs.
Whenever possible the Huxon common data types should be used.
Note
The output data of a processing node should always use Huxon common data types to avoid size mismatches between code deployed on remote nodes.
Huxon language also offers hux::tuple
as an alternative to std::tuple. The main benefit of using
hux::tuple
is that an hux::tuple
made of trivially copyable types is itself trivially copyable.
All outputs of processing nodes and channels are required to be trivially copyable.
-
namespace hux
Typedefs
Functions
-
template<class ...Types>
constexpr hux::tuple<typename std::unwrap_ref_decay<Types>::type...> make_tuple(Types&&... args) Constructs an hux::tuple object of the appropriate type to contain the elements specified in args.
- Template Parameters
Types – the types of each argument to store within the hux::tuple
- Parameters
args – list of elements that the constructed hux::tuple shall contain
- Returns
a hux::tuple object of the appropriate type to hold args
-
template<size_t I, class ...Types>
constexpr hux::tuple_element<I, hux::tuple<Types...>>::type &get(hux::tuple<Types...> &tpl) noexcept Retrieves a reference to the Ith element of an hux::tuple tpl.
- Template Parameters
I – position of an element in the hux::tuple, with 0 as the position of the first element
Types – types of the elements in the hux::tuple (generally obtained implicitly from tpl)
- Parameters
&tpl – an hux::tuple object with more than I elements
- Returns
a reference to the index-th element of the input tuple
-
template<size_t I, class ...Types>
constexpr hux::tuple_element<I, hux::tuple<Types...>>::type &&get(hux::tuple<Types...> &&tpl) noexcept
-
template<size_t I, class ...Types>
constexpr hux::tuple_element<I, hux::tuple<Types...>>::type const &get(const hux::tuple<Types...> &tpl) noexcept
-
template<size_t I, class ...Types>
constexpr hux::tuple_element<I, hux::tuple<Types...>>::type const &&get(const tuple<Types...> &&tpl) noexcept
-
template<class F, class Tuple>
constexpr decltype(auto) apply(F &&f, Tuple &&t) Invokes the Callable object f with a hux::tuple of arguments.
- Template Parameters
F – the callable object type
Tuple – the hux::tuple type
- Parameters
f – Callable object fo be invoked
t – hux::tuple whose elements to be used as arguments to f
- Returns
The value returned by f.
-
template<size_t max_length>
class string - #include <types.hpp>
Class template hux::string to store constant string data with fixed-size memory allocation.
hux::string type is used to conveniently access string-like data from sensor sources. strings longer than max_length characters will be automatically trimmed to max_length characters.
- Template Parameters
max_length – the maximum number of characters that the string can hold
Public Functions
-
inline const char *c_str() const
Returns a pointer to an array that contains a null-terminated sequence of characters (i.e., a C-string) representing the current value of the hux::string object.
- Returns
A pointer to the c-string representation of the hux::string object’s value.
-
inline string(const char *char_array)
Constructs a string object starting from a constant char string array.
-
inline string()
Constructs an empty string.
-
template<class ...Types>
class tuple : public hux::__tuple_impl<std::make_index_sequence<sizeof...(Types)>, Types...> - #include <types.hpp>
Class template hux::tuple is a fixed-size collection of heterogeneous values.
hux::tuple provides functionalities similar to std::tuple with the additional feature of being trivially copyable when all the contained types are trivially copyable as well (see: std::is_trivially_copyable). This allows the usage of hux::tuple as an output type for channels and processing nodes created with: HUX_DECLARE_CHANNEL, HUX_DECLARE_PROCESSING and HUX_DECLARE_STATEFUL_PROCESSING.
- Template Parameters
Types – the types of each hux::tuple container element
Public Functions
-
template<size_t I>
inline constexpr auto &get() Retrieves a reference to the Ith element of the hux::tuple.
- Template Parameters
I – position of an element in the hux::tuple, with 0 as the position of the first element
- Returns
a reference to the index-th element of the input tuple
-
template<size_t I>
inline constexpr const auto &get() const Retrieves a const reference to the Ith element of the hux::tuple.
- Template Parameters
I – position of an element in the hux::tuple, with 0 as the position of the first element
- Returns
a const reference to the index-th element of the input tuple
-
template<size_t I, class T>
class tuple_element - #include <types.hpp>
Class template designed to access the type of the Ith element in a hux::tuple.
It is a simple class with a single member type, tuple_element::type, defined as an alias of the type of the Ith element in a tuple of type T.
- Template Parameters
I – order number of the element within the hux::tuple (zero-based)
T – hux::tuple type for which the type of the tuple element is to be obtained
-
template<class T>
class tuple_size - #include <types.hpp>
Class template designed to access the number of elements in a hux::tuple (as a constexpr)
It is a simple class with a tuple_size::value member containing the number of elements within the hux::tuple.
- Template Parameters
T – hux::tuple type for which the tuple size is obtained
-
template<class ...Types>