ADTF  3.18.3
source.h
Go to the documentation of this file.
1 
15 #ifndef DDL_MAPPING_RT_SOURCE_HEADER
16 #define DDL_MAPPING_RT_SOURCE_HEADER
17 
18 #include <a_util/result.h>
19 #include <ddl/codec/codec_factory.h>
23 
24 #include <memory>
25 
26 namespace ddl {
27 namespace mapping {
28 namespace rt {
30 struct AssignmentStruct {
31  size_t buffer_size;
32  uint32_t type32;
33  uintptr_t element_ptr_offset;
34 
35  AssignmentStruct() : buffer_size(0), type32(0), element_ptr_offset(static_cast<uintptr_t>(-1))
36  {
37  }
38 
39  bool operator==(const AssignmentStruct& other) const
40  {
41  return (element_ptr_offset == other.element_ptr_offset);
42  }
43 };
45 
46 } // namespace rt
47 } // namespace mapping
48 } // namespace ddl
49 
50 namespace ddl {
51 namespace mapping {
52 namespace rt {
53 class TriggerBase;
54 class Target;
55 class TargetElement;
60 class Source : public ISignalListener {
61 public: // types
62 #if defined(__GNUC__) && (__GNUC__ == 5) && defined(__QNX__)
63 #pragma GCC diagnostic ignored \
64  "-Wattributes" // standard type attributes are ignored when used in templates
65 #endif
66 
67  // Map of source elements and a vector of target elements
69  typedef std::vector<std::pair<AssignmentStruct, TargetElementList>> Assignments;
70  typedef std::vector<std::pair<TriggerBase*, AssignmentStruct>> Triggers;
71  typedef std::vector<uint8_t> MemoryBuffer;
72  typedef std::set<const Target*> TargetRefList;
74 
75 #if defined(__GNUC__) && (__GNUC__ == 5) && defined(__QNX__)
76 #pragma GCC diagnostic warning \
77  "-Wattributes" // standard type attributes are ignored when used in templates
78 #endif
79 
80 public:
86 
90  Source(const Source&) = delete;
91 
96  Source& operator=(const Source&) = delete;
97 
102 
111  const std::string& type_description);
112 
121  const std::string& source_element,
122  TargetElement* target_element);
123 
131 
138 
143  const std::string& getTypeName() const;
144 
149  const Assignments& getAssigmentList() const;
150 
157  a_util::result::Result onSampleReceived(const void* data, size_t size);
158 
159 private:
160  IMappingEnvironment& _env;
161  handle_t _handle;
162  std::string _name;
163  std::string _type_name;
164  std::string _type_description;
165  Assignments _assignments;
166  TargetRefList _targets;
167  std::unique_ptr<ddl::codec::CodecFactory> _codec_factory;
168  TypeMap _type_map;
169  TargetElementList _received_elements;
170  Triggers _triggers;
171 };
172 
174 typedef std::map<std::string, Source*> SourceMap;
175 
176 } // namespace rt
177 } // namespace mapping
178 } // namespace ddl
179 
180 #endif // DDL_MAPPING_RT_SOURCE_HEADER
A common result class usable as return value throughout.
MapConfiguration is the central class of the mapping::dd namespace.
MapSource represents a mapping source from the configuration file.
Definition: map_source.h:31
Mapping environment interface class This in combination with ISignalListener forms the functionality ...
Signal listener interface class.
the engine source
Definition: source.h:60
const std::string & getTypeName() const
Getter for the source type.
a_util::result::Result create(const mapping::MapSource &map_source, const std::string &type_description)
Creation method to fill the object with data.
a_util::result::Result addTrigger(const MapConfiguration &map_config, TriggerBase *trigger)
Method to add a new trigger to the intern trigger list.
a_util::result::Result removeAssignmentsFor(const Target *target)
Method to remove all elements of a target from the intern assignment list.
const Assignments & getAssigmentList() const
Getter for the assignment list.
a_util::result::Result addAssignment(const ddl::mapping::MapConfiguration &map_config, const std::string &source_element, TargetElement *target_element)
Method to add a new pair of source element and target element to the intern assignment list.
Source & operator=(const Source &)=delete
no copy assignment operator
Source(IMappingEnvironment &env)
CTOR.
a_util::result::Result onSampleReceived(const void *data, size_t size)
Method to handle a sample when it is received.
Source(const Source &)=delete
no copy CTOR
TargetElement represents a single signal element in the target.
Definition: element.h:59
Target represents a mapped target signal in the runtime api.
Definition: target.h:34
base class representing a trigger
Definition: trigger.h:24
WRITER_TYPE & trigger(WRITER_TYPE &oWriter)
Global function template to trigger a writers sample stream manually.
std::vector< TargetElement * > TargetElementList
the targets element list
Definition: element.h:133
std::map< std::string, Source * > SourceMap
Public composite types used in the mapping::rt namespace.
Definition: source.h:174
bool operator==(const MapAssignment &a, const MapAssignment &b)
compares the Assignments
std::map< std::string, uint8_t > TypeMap
String -> Datatype Enum Map.
Definition: element.h:32
Common include for component a_util::result.