Skip to content

Commit 47dc55f

Browse files
pingmessage: Add function_map variable
This new variable will help us to create a better log from all function return the function name and the value on it. Right now this variable can't return pointer types. Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 23c6c6e commit 47dc55f

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/protocol/templates/pingmessage.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
/// script found in this directory
88

99
#ifdef QT_CORE_LIB
10+
#include <functional>
1011
#include <QObject>
12+
#include <QMap>
1113

1214
#endif
1315
{% for message_type in messages %}
@@ -62,6 +64,9 @@ public:
6264

6365
protected:
6466
uint16_t _bufferLength;
67+
#ifdef QT_CORE_LIB
68+
const QMap<QString, std::function<float()> > function_map;
69+
#endif
6570

6671
public:
6772
uint8_t* msgData;

src/protocol/templates/pingmessage_.h.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55

66
#include "pingmessage.h"
77

8+
#ifdef QT_CORE_LIB
9+
#include <functional>
10+
#include <QMap>
11+
#include <QVariant>
12+
13+
#endif
814
{% set message_type = _actual_message_type %}
915
{% for message in messages[message_type] %}
1016
{% set total_payload = calc_payload(messages[message_type][message].payload) %}
@@ -23,6 +29,16 @@ public:
2329
msgData[6] = 0;
2430
msgData[7] = 0;
2531
}
32+
#ifdef QT_CORE_LIB
33+
34+
const QMap<QString, std::function<float()> > function_map {
35+
{% for payload in messages[message_type][message].payload %}
36+
{% if not is_vector(payload.type) %}
37+
{"{{payload.name}}", [this]()->float{return this->{{payload.name}}();}},
38+
{% endif %}
39+
{% endfor %}
40+
};
41+
#endif
2642

2743
{% set byte = namespace(offset=0, func='') %}
2844
{% if messages[message_type][message].payload %}

0 commit comments

Comments
 (0)