dds-fmu 0.5.1
DDS-FMU communication integration
visitors.hpp
1#pragma once
2
3/*
4 Copyright 2023, SINTEF Ocean
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8*/
9
10namespace ddsfmu {
11
15namespace detail {
16
17
21template<typename OutType, typename InType>
22void reader_visitor(OutType& out, const eprosima::xtypes::ReadableDynamicDataRef& cref) {
23 out = static_cast<OutType>(cref.value<InType>()); // should use numeric_cast
24}
25
29template<typename InType, typename OutType>
30void writer_visitor(const InType& in, eprosima::xtypes::WritableDynamicDataRef& ref) {
31 ref.value(static_cast<OutType>(in)); // should use numeric_cast
32}
33
34template<>
35inline void reader_visitor<std::string, char>(
36 std::string& out, const eprosima::xtypes::ReadableDynamicDataRef& cref) {
37 out = std::string(1, cref.value<char>());
38}
39
40template<>
41inline void writer_visitor<std::string, char>(
42 const std::string& in, eprosima::xtypes::WritableDynamicDataRef& ref) {
43 ref.value(in[0]);
44}
45
46}
47}
void writer_visitor(const InType &in, eprosima::xtypes::WritableDynamicDataRef &ref)
A writer visitor sends a value to an xtypes data reference.
Definition: visitors.hpp:30
void reader_visitor(OutType &out, const eprosima::xtypes::ReadableDynamicDataRef &cref)
A reader visitor retrieves a value from an xtypes data reference.
Definition: visitors.hpp:22
Definition: auxiliaries.cpp:26