20#ifndef _MAPPING_INTERFACES_HEADER
21#define _MAPPING_INTERFACES_HEADER
27#include <unordered_map>
60 static_assert(std::is_arithmetic_v<T>,
61 "Only arithmetic types are supported to retrieve the value with getValue<T>");
62 value_reference = std::visit([](
auto&& variant_content) {
return static_cast<T
>(variant_content); }, value);
73 static_assert(std::is_arithmetic_v<T>,
74 "Only arithmetic types are supported to retrieve the value with getValue<T>");
75 return std::visit([](
auto&& variant_content) {
return static_cast<T
>(variant_content); }, value);
99 virtual std::optional<ValueVariant>
getValue()
const = 0;
106 template <
typename T>
109 if (
const auto untyped_value =
getValue())
121 template <
typename T>
124 if (
const auto untyped_value =
getValue())
130 value_reference = default_value;
140 template <
typename T>
153 template <
typename T>
170 virtual std::optional<ValueVariant>
getValue(
size_t array_pos)
const = 0;
196 virtual void initialize(std::shared_ptr<const SourceValue> value_source) = 0;
240 Property(std::string value, std::string type) : _value(std::move(value)), _type(std::move(type))
250 std::enable_if_t<std::is_unsigned<T>::value && !std::is_same<T, bool>::value,
bool> =
true>
251 Property(T value) : _value(std::to_string(value)), _type(
"unsigned")
259 template <
typename T,
260 std::enable_if_t<std::is_integral<T>::value && std::is_signed<T>::value,
bool> =
true>
261 Property(T value) : _value(std::to_string(value)), _type(
"signed")
269 template <typename T, std::enable_if_t<std::is_floating_point<T>::value,
bool> =
true>
270 Property(T value) : _value(std::to_string(value)), _type(
"float")
278 template <typename T, std::enable_if_t<std::is_same<T, bool>::value,
bool> =
true>
279 Property(T value) : _value((value ?
"true" :
"false")), _type(
"bool")
287 Property(std::string_view string_value) : _value(std::string(string_value)), _type(
"string")
343 Properties result_properties(properties_left);
344 for (
const auto& current_right: properties_right) {
345 result_properties.insert_or_assign(current_right.first, current_right.second);
347 return result_properties;
363 virtual const std::string&
getName()
const = 0;
413 virtual std::shared_ptr<const SourceValue>
getValue(
414 const std::string& value_name)
const = 0;
488template<
typename ElementType>
498 virtual std::shared_ptr<ElementType>
make(std::string name,
Properties properties)
const = 0;
521 virtual std::shared_ptr<TargetValue>
getValue(
const std::string& value_name)
const = 0;
587 virtual std::shared_ptr<const SourceValue>
initialize(
const std::unordered_map<std::string, std::shared_ptr<const SourceValue>>& parameters) = 0;
593 using Description = std::unordered_map<std::string, ParameterDescription>;
628 virtual bool updateTime(std::chrono::nanoseconds source_value_time,
629 uint64_t source_value_update_counter,
630 const std::shared_ptr<const SourceValue>& source_value) = 0;
634 virtual std::optional<std::chrono::nanoseconds>
getTime()
const = 0;
646 virtual void update([[maybe_unused]]std::chrono::nanoseconds trigger_time) = 0;
660 virtual void update([[maybe_unused]] std::chrono::nanoseconds trigger_time,
Source Value base class that represents an array.
Definition mapper_interfaces.h:163
virtual size_t getArraySize() const =0
Returns the array size of the SourceValue.
virtual std::optional< ValueVariant > getValue(size_t array_pos) const =0
Get the value as optional variant.
Trigger interface to trigger the assignments of a specific target together with a update time strateg...
Definition mapper_interfaces.h:653
virtual void update(std::chrono::nanoseconds trigger_time, TimeStrategy *time_strategy)=0
indicates an update of target or a source
Trigger interface to trigger the assignments of a specific target.
Definition mapper_interfaces.h:640
virtual void update(std::chrono::nanoseconds trigger_time)=0
indicates an update of target or a source
Function caller.
Definition mapper_interfaces.h:576
virtual std::shared_ptr< const SourceValue > initialize(const std::unordered_map< std::string, std::shared_ptr< const SourceValue > > ¶meters)=0
Initializes the callable with named parameter source value references.
virtual ~Callable()=default
DTOR.
Mapping Function base class.
Definition mapper_interfaces.h:561
virtual Description getDescription() const =0
Get the parameter descriptions.
virtual std::shared_ptr< Callable > getCallable() const =0
Get a Function Callable.
std::unordered_map< std::string, ParameterDescription > Description
Definition mapper_interfaces.h:593
Mapper Element.
Definition mapper_interfaces.h:353
virtual const Properties & getProperties() const =0
Get the Properties.
virtual const std::string & getName() const =0
Get the Name.
virtual ~MapperElement()=default
DTOR.
A mapper factory to create Source, Target or Function.
Definition mapper_interfaces.h:466
virtual Properties getDefaultProperties() const =0
Get the default properties to initialize the Source, Target or Function with.
virtual std::string getType() const =0
Get the Type as string.
virtual ~MapperFactory()=default
DTOR.
Source memory base class for sources representing a continuous memory buffer.
Definition mapper_interfaces.h:447
virtual size_t getExpectedDataSize() const =0
Get the expected data size in bytes.
virtual void updateMemory(std::shared_ptr< const Memory > memory)=0
Update the sources memory buffer.
Memory Target base class that represents a continuous memory buffer.
Definition mapper_interfaces.h:527
virtual void updateMemory(std::shared_ptr< Memory > memory)=0
Sets the target's memory buffer where to set the values to.
virtual size_t getExpectedDataSize() const =0
Get the expected data size of the buffer.
~MemoryTarget() override=default
DTOR.
void reset() override
resets the current memory buffer
Definition mapper_interfaces.h:547
Memory base class for sources and targets representing a continous memory buffer.
Definition mapper_interfaces.h:420
virtual const void * getPtr() const =0
Get the readable pointer of the buffer.
virtual void * getPtr()=0
Get the writable pointer of the buffer.
virtual ~Memory()=default
DTOR.
virtual size_t getSize() const =0
Get the Size in bytes of the buffer.
Value getter to retrieve a value with plain type content.
Definition mapper_interfaces.h:93
void getValueRef(T &value_reference) const
Get the value.
Definition mapper_interfaces.h:107
T getValueOrDefault(T default_value) const
Get the value or the default value if not set.
Definition mapper_interfaces.h:141
T getValue() const
Get the value.
Definition mapper_interfaces.h:154
virtual std::optional< ValueVariant > getValue() const =0
Get the value as arithmetic type.
void getValueOrDefaultRef(T &value_reference, T default_value) const
Get the value or the default value if not set.
Definition mapper_interfaces.h:122
Property class representing a pair of value and its type.
Definition mapper_interfaces.h:208
Property(T value)
CTOR for unsigned integer value (uint8-uint64) and "unsigned" type.
Definition mapper_interfaces.h:251
const std::string & getValue() const
Get the value as string.
Definition mapper_interfaces.h:295
const std::string & getType() const
Get the value type as string.
Definition mapper_interfaces.h:304
Property & operator=(const Property &)=default
copy assignment
Property(const Property &)=default
copy CTOR
Property(std::string_view string_value)
CTOR for string value and "string" type.
Definition mapper_interfaces.h:287
Property & operator=(Property &&)=default
move assignment
Property(Property &&)=default
move CTOR
Property(std::string value, std::string type)
CTOR.
Definition mapper_interfaces.h:240
Source Value base class.
Definition mapper_interfaces.h:82
virtual ~SourceValue()
DTOR.
Definition mapper_interfaces.h:87
Mapping Source base class.
Definition mapper_interfaces.h:401
virtual std::vector< std::string > getAllValues() const =0
Get all value names.
virtual std::shared_ptr< const SourceValue > getValue(const std::string &value_name) const =0
Get the value source with a certain name.
A specific mapper factory to create Source, Target or Function.
Definition mapper_interfaces.h:490
virtual std::shared_ptr< ElementType > make(std::string name, Properties properties) const =0
Factory create function which creates a Source, Target or Function instance with a name and intialize...
Value setter to set a value.
Definition mapper_interfaces.h:182
virtual ~TargetValue()
DTOR.
Definition mapper_interfaces.h:187
virtual void initialize(std::shared_ptr< const SourceValue > value_source)=0
Sets the value source at initializing time to bind the value_source as source of the target.
Mapping Target base class.
Definition mapper_interfaces.h:509
virtual std::shared_ptr< TargetValue > getValue(const std::string &value_name) const =0
Get the value Target with a certain name.
virtual std::vector< std::string > getAllValues() const =0
Get all value names.
Definition mapper_interfaces.h:615
virtual std::optional< std::chrono::nanoseconds > getTime() const =0
virtual bool updateTime(std::chrono::nanoseconds source_value_time, uint64_t source_value_update_counter, const std::shared_ptr< const SourceValue > &source_value)=0
Updateable interface class.
Definition mapper_interfaces.h:374
virtual void updateBegin(std::chrono::nanoseconds)
Function callback interface that is called before a value will be updated.
Definition mapper_interfaces.h:379
virtual void updateEnd()
Function callback interface that is called after a value was updated.
Definition mapper_interfaces.h:386
virtual void reset()
Function callback interface that is called if a value is about to be reset.
Definition mapper_interfaces.h:393
definition of the mapping namespace
Definition ddl.h:50
SpecificMapperFactory< Source > SourceFactory
A Source factory to create a Source.
Definition mapper_interfaces.h:504
std::unordered_map< std::string, Property > Properties
Properties class as set of key - property value pairs This proerties are used to adjust the readers a...
Definition mapper_interfaces.h:331
bool operator==(const MapAssignment &a, const MapAssignment &b)
compares the Assignments
Definition map_assignment.h:184
SpecificMapperFactory< Target > TargetFactory
A Target factory to create a Target.
Definition mapper_interfaces.h:556
SpecificMapperFactory< Function > FunctionFactory
A Function factory to create a Function.
Definition mapper_interfaces.h:610
Properties operator+(const Properties &properties_left, const Properties &properties_right)
Add operator for properties.
Definition mapper_interfaces.h:341
void getValueRef(const ValueVariant &value, T &value_reference)
Get the value from a variant as plain type T.
Definition mapper_interfaces.h:58
std::variant< uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double, bool > ValueVariant
Variant Value to retrieve a plain type value of a source.
Definition mapper_interfaces.h:39
T getValue(const ValueVariant &value)
Get the value.
Definition mapper_interfaces.h:71
definition of the ddl namespace
Definition codec.h:21
Parameter Description.
Definition mapper_interfaces.h:566
std::optional< std::string > default_value
if optional, the default value of the parameter
Definition mapper_interfaces.h:570