Dev Essential
Loading...
Searching...
No Matches
target.h
Go to the documentation of this file.
1
14
15#ifndef DDL_MAPPING_RT_TARGET_HEADER
16#define DDL_MAPPING_RT_TARGET_HEADER
17
18#include <a_util/concurrency.h>
19#include <a_util/result.h>
26
27#include <memory>
28#include <vector>
29
30namespace ddl {
31namespace mapping {
32namespace rt {
34class Target {
35public: // types
36#if defined(__GNUC__) && (__GNUC__ == 5) && defined(__QNX__)
37#pragma GCC diagnostic ignored \
38 "-Wattributes" // standard type attributes are ignored when used in templates
39#endif
40
42 typedef std::vector<std::pair<std::string, TargetElement*>> Assignments;
44 typedef std::vector<std::pair<uint64_t, TargetElement*>> TriggerCounters;
46 typedef std::vector<std::pair<std::string, TargetElement*>> Constants;
48 typedef std::vector<uint8_t> MemoryBuffer;
49
50#if defined(__GNUC__) && (__GNUC__ == 5) && defined(__QNX__)
51#pragma GCC diagnostic warning \
52 "-Wattributes" // standard type attributes are ignored when used in templates
53#endif
54
55public:
61
66
77 const MapTarget& map_target,
78 const std::string& target_description,
79 SourceMap& sources);
80
87
92 const std::string& getName() const;
93
98 const std::string& getTypeName() const;
99
105
111 size_t getSize() const;
112
121 a_util::result::Result getCurrentBuffer(void* target_buffer, size_t target_buffer_size);
122
130 a_util::result::Result getBufferRef(const void*& buffer, size_t& target_buffer_size);
131
137
143
144private:
146 std::string _name;
147 std::string _type_name;
148 TargetElementList _target_elements;
149 std::vector<TargetElement*> _simulation_time_elements;
150 TriggerCounters _counter_elements;
151 Constants _constant_elements;
152 uint64_t _counter;
153 std::unique_ptr<ddl::codec::StaticCodec> _codec;
154 MemoryBuffer _buffer;
155 mutable a_util::concurrency::shared_mutex _buffer_mutex;
158
159public:
161 inline void aquireWriteLock() const
162 {
163 _buffer_mutex.lock_shared();
164 }
165
167 inline void releaseWriteLock() const
168 {
169 _buffer_mutex.unlock_shared();
170 }
171
173 inline void aquireReadLock() const
174 {
175 _buffer_mutex.lock();
176 }
177
179 inline void releaseReadLock() const
180 {
181 _buffer_mutex.unlock();
182 }
183};
184
186typedef std::map<std::string, Target*> TargetMap;
188typedef std::set<Target*> TargetSet;
189
190} // namespace rt
191} // namespace mapping
192} // namespace ddl
193#endif // DDL_MAPPING_RT_TARGET_HEADER
Definition shared_mutex.h:26
void lock()
Lock the mutex, blocks if the mutex is not available.
void unlock_shared()
Unlock the mutex (shared ownership)
void lock_shared()
Lock the mutex for shared ownership, blocks if the mutex is not available.
void unlock()
Unlock the mutex.
Definition result_type_decl.h:34
Definition map_configuration.h:36
Definition map_target.h:31
Definition mapping_environment_intf.h:56
void releaseWriteLock() const
Unlock the buffer after a source update.
Definition target.h:167
a_util::result::Result getBufferRef(const void *&buffer, size_t &target_buffer_size)
size_t getSize() const
a_util::result::Result updateAccessFunctionValues()
const std::string & getTypeName() const
a_util::result::Result create(const MapConfiguration &map_config, const MapTarget &map_target, const std::string &target_description, SourceMap &sources)
std::vector< std::pair< uint64_t, TargetElement * > > TriggerCounters
Trigger counter container.
Definition target.h:44
void aquireReadLock() const
Lock the buffer for a buffer read.
Definition target.h:173
std::vector< std::pair< std::string, TargetElement * > > Assignments
Assignment container.
Definition target.h:42
a_util::result::Result updateTriggerFunctionValues()
void releaseReadLock() const
Unlock the buffer after a buffer read.
Definition target.h:179
Target(IMappingEnvironment &env)
const TargetElementList & getElementList() const
std::vector< std::pair< std::string, TargetElement * > > Constants
Constant container.
Definition target.h:46
const std::string & getName() const
a_util::result::Result reset(const MapConfiguration &map_config)
std::vector< uint8_t > MemoryBuffer
Generic byte-buffer.
Definition target.h:48
void aquireWriteLock() const
Lock the buffer for a source update.
Definition target.h:161
a_util::result::Result getCurrentBuffer(void *target_buffer, size_t target_buffer_size)
definition of the rt namespace for mapping
Definition ddl.h:59
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
std::map< std::string, Target * > TargetMap
Public composite types used in the mapping::rt namespace.
Definition target.h:186
std::set< Target * > TargetSet
the targets pointer list
Definition target.h:188
definition of the mapping namespace
Definition ddl.h:50
definition of the ddl namespace
Definition codec.h:21