summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-03-22 16:27:57 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2018-03-22 16:27:57 +0100
commit1151515e5d811d90d5bcfdc454581c525143eca4 (patch)
treee1924de61df97024342cb59f28cbff0144f80eae
parentc190b189601bcbf79182165d77921d37232c9ec0 (diff)
Add undefined value possibility in signal values
By default, signal value are initialized to 0 which isn't acceptable to be accurate and be able to calculate virtual signals values as result would be false. Change-Id: I8ec40d8dcb9ce1fae42aeec9fb48369f0914fd9f Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--signal-composer-binding/signal.hpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/signal-composer-binding/signal.hpp b/signal-composer-binding/signal.hpp
index 63be5c9..5b35065 100644
--- a/signal-composer-binding/signal.hpp
+++ b/signal-composer-binding/signal.hpp
@@ -34,6 +34,7 @@ class Composer;
/// Not very efficient or optimized, maybe use of Variant in
/// C++17 but this is a bit too new to uses it for now
struct signalValue {
+ bool undefined;
bool hasBool;
bool boolVal;
bool hasNum;
@@ -42,15 +43,15 @@ struct signalValue {
std::string strVal;
signalValue():
- hasBool(false), boolVal(false), hasNum(false), numVal(0), hasStr(false), strVal("") {};
+ undefined(true), hasBool(false), boolVal(false), hasNum(false), numVal(0), hasStr(false), strVal("") {};
signalValue(bool b):
- hasBool(true), boolVal(b), hasNum(false), numVal(0), hasStr(false), strVal("") {};
+ undefined(false), hasBool(true), boolVal(b), hasNum(false), numVal(0), hasStr(false), strVal("") {};
signalValue(int b):
- hasBool(true), boolVal(b), hasNum(false), numVal(0), hasStr(false), strVal("") {};
+ undefined(false), hasBool(true), boolVal(b), hasNum(false), numVal(0), hasStr(false), strVal("") {};
signalValue(double d):
- hasBool(false), boolVal(false), hasNum(true), numVal(d), hasStr(false), strVal("") {};
+ undefined(false), hasBool(false), boolVal(false), hasNum(true), numVal(d), hasStr(false), strVal("") {};
signalValue(const std::string& s):
- hasBool(false), boolVal(false), hasNum(false), numVal(0), hasStr(true), strVal(s) {};
+ undefined(false), hasBool(false), boolVal(false), hasNum(false), numVal(0), hasStr(true), strVal(s) {};
};
extern "C" void searchNsetSignalValueHandle(const char* aName, uint64_t timestamp, struct signalValue value);