Dev Essential
Loading...
Searching...
No Matches
time_function.h
Go to the documentation of this file.
1
19
20#ifndef _MAPPING_TIME_MODULE_HEADER
21#define _MAPPING_TIME_MODULE_HEADER
22
24
25#include <memory>
26
27namespace ddl {
28namespace mapping {
29
35class SimulationTimeFunction : public MapperElementBase<Function> {
36public:
44 SimTimeSource() = default;
48 virtual ~SimTimeSource() = default;
53 virtual std::chrono::nanoseconds getCurrentSimTime() const = 0;
54 };
55
56 SimulationTimeFunction() = delete;
63 SimulationTimeFunction(std::string name,
64 Properties properties,
65 std::shared_ptr<SimTimeSource> sim_time_source);
66
68 std::shared_ptr<Function::Callable> getCallable() const override;
72 enum class Resolution : uint8_t { us = 0, ms = 1, ns = 2, s = 3 };
73
74private:
75 std::shared_ptr<SimTimeSource> _sim_time_source;
76 Resolution _resolution = Resolution::us;
77};
78
82class SimulationTimeFunctionFactory : public FunctionFactory {
83public:
84 SimulationTimeFunctionFactory() = delete;
90 std::shared_ptr<SimulationTimeFunction::SimTimeSource> sim_time_source)
91 : _sim_time_source(std::move(sim_time_source))
92 {
93 }
94
95 std::string getType() const override
96 {
97 return "simulation_time";
98 }
99
101 {
102 return {{"resolution", {"us"}}};
103 }
104
105 std::shared_ptr<Function> make(std::string name, Properties properties) const override
106 {
107 return std::make_shared<SimulationTimeFunction>(
108 name, std::move(properties), _sim_time_source);
109 }
110
111private:
112 std::shared_ptr<SimulationTimeFunction::SimTimeSource> _sim_time_source;
113};
114
115} // namespace mapping
116} // namespace ddl
117#endif // _MAPPING_TIME_MODULE_HEADER
std::unordered_map< std::string, ParameterDescription > Description
Definition mapper_interfaces.h:593
MapperElementBase(std::string name, Properties properties)
Definition mapper_base_types.h:43
SimulationTimeFunctionFactory(std::shared_ptr< SimulationTimeFunction::SimTimeSource > sim_time_source)
CTOR of factory.
Definition time_function.h:89
std::shared_ptr< Function > make(std::string name, Properties properties) const override
Factory create function which creates a Source, Target or Function instance with a name and intialize...
Definition time_function.h:105
std::string getType() const override
Get the Type as string.
Definition time_function.h:95
Properties getDefaultProperties() const override
Get the default properties to initialize the Source, Target or Function with.
Definition time_function.h:100
std::shared_ptr< Function::Callable > getCallable() const override
Get a Function Callable.
Resolution
The resolution of the value that is returned by a function call.
Definition time_function.h:72
SimulationTimeFunction(std::string name, Properties properties, std::shared_ptr< SimTimeSource > sim_time_source)
CTOR.
Function::Description getDescription() const override
Get the parameter descriptions.
definition of the mapping namespace
Definition ddl.h:50
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
SpecificMapperFactory< Function > FunctionFactory
A Function factory to create a Function.
Definition mapper_interfaces.h:610
definition of the ddl namespace
Definition codec.h:21
virtual std::chrono::nanoseconds getCurrentSimTime() const =0
Get the Current Sim Time.