History

TimeSeriesPlatformLibrary: Fixed issues with active measurements generation from common metadata, plus general code clean-up

J. Ritchie Carroll committed 7 years ago

Commit eb746151 parent d716f1b17 files · +212 −234Browse files

Unified · Split

17 files
  1. Source/Libraries/TimeSeriesPlatformLibrary/Common/CommonTypes.h +30 −8
  2. Source/Libraries/TimeSeriesPlatformLibrary/Common/Convert.h +3 −3
  3. Source/Libraries/TimeSeriesPlatformLibrary/Common/EndianConverter.h +12 −12
  4. Source/Libraries/TimeSeriesPlatformLibrary/Common/Nullable.h +90 −125
  5. Source/Libraries/TimeSeriesPlatformLibrary/Common/ThreadSafeQueue.h +11 −12
  6. Source/Libraries/TimeSeriesPlatformLibrary/FilterExpressions/ExpressionTree.cpp +2 −2
  7. Source/Libraries/TimeSeriesPlatformLibrary/FilterExpressions/ExpressionTree.h +2 −2
  8. Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimplePublish.cpp +5 −3
  9. Source/Libraries/TimeSeriesPlatformLibrary/Transport/ActiveMeasurementsSchema.cpp +2 −2
  10. Source/Libraries/TimeSeriesPlatformLibrary/Transport/ActiveMeasurementsSchema.h +1 −1
  11. Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataPublisher.cpp +36 −37
  12. Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataSubscriber.cpp +1 −0
  13. Source/Libraries/TimeSeriesPlatformLibrary/Transport/MetadataSchema.cpp +2 −2
  14. Source/Libraries/TimeSeriesPlatformLibrary/Transport/MetadataSchema.h +1 −1
  15. Source/Libraries/TimeSeriesPlatformLibrary/Transport/SignalIndexCache.cpp +4 −14
  16. Source/Libraries/TimeSeriesPlatformLibrary/Transport/SubscriberConnection.h +1 −1
  17. Source/Libraries/TimeSeriesPlatformLibrary/Transport/SubscriberInstance.cpp +9 −9
Source/Libraries/TimeSeriesPlatformLibrary/Common/CommonTypes.h+30−8
@@ -127,31 +127,31 @@ namespace GSF · 126 unmodified lines
127 return boost::make_shared<T>();127 return boost::make_shared<T>();
128 }128 }
129 129
130 template<class T, typename P1>130 template<class T, class P1>
131 SharedPtr<T> NewSharedPtr(P1 p1)131 SharedPtr<T> NewSharedPtr(P1 p1)
132 {132 {
133 return boost::make_shared<T>(p1);133 return boost::make_shared<T>(p1);
134 }134 }
135 135
136 template<class T, typename P1, typename P2>136 template<class T, class P1, class P2>
137 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2)137 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2)
138 {138 {
139 return boost::make_shared<T>(p1, p2);139 return boost::make_shared<T>(p1, p2);
140 }140 }
141 141
142 template<class T, typename P1, typename P2, typename P3>142 template<class T, class P1, class P2, class P3>
143 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3)143 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3)
144 {144 {
145 return boost::make_shared<T>(p1, p2, p3);145 return boost::make_shared<T>(p1, p2, p3);
146 }146 }
147 147
148 template<class T, typename P1, typename P2, typename P3, typename P4>148 template<class T, class P1, class P2, class P3, class P4>
149 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4)149 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4)
150 {150 {
151 return boost::make_shared<T>(p1, p2, p3, p4);151 return boost::make_shared<T>(p1, p2, p3, p4);
152 }152 }
153 153
154 template<class T, typename P1, typename P2, typename P3, typename P4, typename P5>154 template<class T, class P1, class P2, class P3, class P4, class P5>
155 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)155 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
156 {156 {
157 return boost::make_shared<T>(p1, p2, p3, p4, p5);157 return boost::make_shared<T>(p1, p2, p3, p4, p5);
@@ -221,7 +221,7 @@ namespace GSF · 63 unmodified lines
221 template<class T>221 template<class T>
222 using SortedStringMap = std::map<std::string, T, GSF::StringComparer>;222 using SortedStringMap = std::map<std::string, T, GSF::StringComparer>;
223 223
224 template<typename TKey, typename TValue>224 template<class TKey, class TValue>
225 bool TryGetValue(const std::map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)225 bool TryGetValue(const std::map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)
226 {226 {
227 auto iterator = dictionary.find(key);227 auto iterator = dictionary.find(key);
@@ -236,7 +236,7 @@ namespace GSF · 8 unmodified lines
236 return false;236 return false;
237 }237 }
238 238
239 template<typename TKey, typename TValue>239 template<class TKey, class TValue>
240 bool TryGetValue(const std::unordered_map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)240 bool TryGetValue(const std::unordered_map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)
241 {241 {
242 auto iterator = dictionary.find(key);242 auto iterator = dictionary.find(key);
@@ -251,7 +251,7 @@ namespace GSF · 8 unmodified lines
251 return false;251 return false;
252 }252 }
253 253
254 template<typename TValue>254 template<class TValue>
255 bool TryGetValue(const StringMap<TValue>& dictionary, const std::string& key, TValue& value, const TValue& defaultValue)255 bool TryGetValue(const StringMap<TValue>& dictionary, const std::string& key, TValue& value, const TValue& defaultValue)
256 {256 {
257 auto iterator = dictionary.find(key);257 auto iterator = dictionary.find(key);
@@ -308,6 +308,28 @@ namespace GSF · 50 unmodified lines
308 sink.push_back(static_cast<uint8_t>(*it));308 sink.push_back(static_cast<uint8_t>(*it));
309 }309 }
310 310
311 template<class T>
312 static uint32_t WriteBytes(std::vector<uint8_t>& buffer, const T& value)
313 {
314 static const int32_t length = sizeof(T);
315 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(&value);
316
317 for (int32_t i = 0; i < length; i++)
318 buffer.push_back(bytes[i]);
319
320 return length;
321 }
322
323 static uint32_t WriteBytes(std::vector<uint8_t>& buffer, const Guid& value)
324 {
325 const uint8_t* bytes = value.data;
326
327 for (uint32_t i = 0; i < 16; i++)
328 buffer.push_back(bytes[i]);
329
330 return 16;
331 }
332
311 Guid NewGuid();333 Guid NewGuid();
312 334
313 // Handy string functions (boost wrappers)335 // Handy string functions (boost wrappers)
Source/Libraries/TimeSeriesPlatformLibrary/Common/Convert.h+3−3
@@ -43,7 +43,7 @@ namespace GSF · 42 unmodified lines
43 DateTime LocalFromUtc(const DateTime& timestamp);43 DateTime LocalFromUtc(const DateTime& timestamp);
44 44
45 // Converts an object to a string45 // Converts an object to a string
46 template <class T>46 template<class T>
47 std::string ToString(const T& obj)47 std::string ToString(const T& obj)
48 {48 {
49 std::stringstream stream;49 std::stringstream stream;
@@ -61,11 +61,11 @@ namespace GSF · 11 unmodified lines
61 std::string ToUTF8(const std::wstring& value);61 std::string ToUTF8(const std::wstring& value);
62 62
63 // Converts an integer value to a hex representation63 // Converts an integer value to a hex representation
64 template <class T>64 template<class T>
65 std::string ToHex(const T& value)65 std::string ToHex(const T& value)
66 {66 {
67 std::stringstream stream;67 std::stringstream stream;
68 stream << "0x" << std::hex << static_cast<int>(value);68 stream << "0x" << std::hex << static_cast<int32_t>(value);
69 return stream.str();69 return stream.str();
70 }70 }
71 71
Source/Libraries/TimeSeriesPlatformLibrary/Common/EndianConverter.h+12−12
@@ -47,7 +47,7 @@ namespace GSF · 46 unmodified lines
47 47
48 // Converts between big endian and48 // Converts between big endian and
49 // the system's native byte order.49 // the system's native byte order.
50 template <class T>50 template<class T>
51 T ConvertBigEndian(T value) const51 T ConvertBigEndian(T value) const
52 {52 {
53 if (m_nativeOrder != EndianConverter::BigEndian)53 if (m_nativeOrder != EndianConverter::BigEndian)
@@ -58,7 +58,7 @@ namespace GSF · 4 unmodified lines
58 58
59 // Converts between little endian and59 // Converts between little endian and
60 // the system's native byte order.60 // the system's native byte order.
61 template <class T>61 template<class T>
62 T ConvertLittleEndian(T value) const62 T ConvertLittleEndian(T value) const
63 {63 {
64 if (m_nativeOrder != EndianConverter::LittleEndian)64 if (m_nativeOrder != EndianConverter::LittleEndian)
@@ -82,39 +82,39 @@ namespace GSF · 17 unmodified lines
82 static bool IsLittleEndian();82 static bool IsLittleEndian();
83 static bool IsBigEndian();83 static bool IsBigEndian();
84 84
85 template <class T>85 template<class T>
86 static T ToBigEndian(const uint8_t* buffer, const uint32_t startIndex)86 static T ToBigEndian(const uint8_t* buffer, const uint32_t startIndex)
87 {87 {
88 return Default.ConvertBigEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));88 return Default.ConvertBigEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));
89 }89 }
90 90
91 template <class T>91 template<class T>
92 static T ToLittleEndian(const uint8_t* buffer, const uint32_t startIndex)92 static T ToLittleEndian(const uint8_t* buffer, const uint32_t startIndex)
93 {93 {
94 return Default.ConvertLittleEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));94 return Default.ConvertLittleEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));
95 }95 }
96 96
97 template <class T>97 template<class T>
98 static int32_t WriteBigEndianBytes(std::vector<uint8_t>& buffer, T value)98 static uint32_t WriteBigEndianBytes(std::vector<uint8_t>& buffer, T value)
99 {99 {
100 int32_t length = sizeof(T);100 static const uint32_t length = sizeof(T);
101 value = Default.ConvertBigEndian(value);101 value = Default.ConvertBigEndian(value);
102 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);102 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);
103 103
104 for (int32_t i = 0; i < length; i++)104 for (uint32_t i = 0; i < length; i++)
105 buffer.push_back(bytes[i]);105 buffer.push_back(bytes[i]);
106 106
107 return length;107 return length;
108 }108 }
109 109
110 template <class T>110 template<class T>
111 static int32_t WriteLittleEndianBytes(std::vector<uint8_t>& buffer, T value)111 static uint32_t WriteLittleEndianBytes(std::vector<uint8_t>& buffer, T value)
112 {112 {
113 int32_t length = sizeof(T);113 static const uint32_t length = sizeof(T);
114 value = Default.ConvertLittleEndian(value);114 value = Default.ConvertLittleEndian(value);
115 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);115 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);
116 116
117 for (int32_t i = 0; i < length; i++)117 for (uint32_t i = 0; i < length; i++)
118 buffer.push_back(bytes[i]);118 buffer.push_back(bytes[i]);
119 119
120 return length;120 return length;
Source/Libraries/TimeSeriesPlatformLibrary/Common/Nullable.h+90−125
@@ -25,178 +25,143 @@ · 24 unmodified lines
25#ifndef __NULLABLE_H25#ifndef __NULLABLE_H
26#define __NULLABLE_H26#define __NULLABLE_H
27 27
28#include <cstddef>
29#include "Convert.h"28#include "Convert.h"
30 29
31namespace GSF30namespace GSF
32{31{
33 class NullableType // NOLINT32 template<class T>
34 {33 class Nullable final // NOLINT
35 public:
36 virtual ~NullableType() = default;
37
38 virtual bool HasValue() const
39 {
40 return false;
41 };
42 };
43
44 template <typename T>
45 class Nullable final : public NullableType // NOLINT
46 {34 {
47 public:35 public:
48 Nullable();36 Nullable();
49 Nullable(const T &value);37 Nullable(const T& value);
50 Nullable(nullptr_t nullpointer);38 Nullable(nullptr_t nullpointer);
51 const Nullable<T> & operator=(const Nullable<T> &value);39 const Nullable<T>& operator=(const Nullable<T>& value); // NOLINT
52 const Nullable<T> & operator=(const T &value);40 const Nullable<T>& operator=(const T& value); // NOLINT
53 const Nullable<T> & operator=(nullptr_t nullpointer);41 const Nullable<T>& operator=(nullptr_t nullpointer); // NOLINT
54 bool HasValue() const override;42 bool HasValue() const;
55 const T & GetValueOrDefault() const;43 const T& GetValueOrDefault() const;
56 const T & GetValueOrDefault(const T &def) const;44 const T& GetValueOrDefault(const T& def) const;
57 bool TryGetValue(T &value) const;45 bool TryGetValue(T& value) const;
58 46
59 public:47 class NullableValue final // NOLINT
60 class NullableValue final
61 {48 {
62 public:
63 friend class Nullable;
64
65 private:49 private:
66 NullableValue();50 NullableValue();
67 NullableValue(const T &value);51 NullableValue(const T& value);
68 52
69 public:53 void checkHasValue() const;
70 NullableValue & operator=(const NullableValue &) = delete;
71 operator const T &() const;
72 const T & operator*() const;
73 const T * operator&() const;
74 54
75 // https://stackoverflow.com/questions/42183631/inability-to-overload-dot-operator-in-c55 bool m_hasValue;
76 const T * operator->() const;56 T m_value;
77 57
78 public:58 public:
79 template <typename T2>59 NullableValue& operator=(const NullableValue&) = delete;
80 friend bool operator==(const Nullable<T2> &op1, const Nullable<T2> &op2);60 operator const T&() const;
81 61 const T& operator*() const;
82 template <typename T2>62 const T* operator&() const; // NOLINT
83 friend bool operator==(const Nullable<T2> &op, const T2 &value);
84
85 template <typename T2>
86 friend bool operator==(const T2 &value, const Nullable<T2> &op);
87
88 template <typename T2>
89 friend bool operator==(const Nullable<T2> &op, nullptr_t nullpointer);
90
91 template <typename T2>
92 friend bool operator!=(const Nullable<T2> &op1, const Nullable<T2> &op2);
93
94 template <typename T2>
95 friend bool operator!=(const Nullable<T2> &op, const T2 &value);
96
97 template <typename T2>
98 friend bool operator!=(const T2 &value, const Nullable<T2> &op);
99 63
100 template <typename T2>64 // https://stackoverflow.com/questions/42183631/inability-to-overload-dot-operator-in-c
101 friend bool operator==(nullptr_t nullpointer, const Nullable<T2> &op);65 const T* operator->() const;
102
103 template <typename T2>
104 friend bool operator!=(const Nullable<T2> &op, nullptr_t nullpointer);
105
106 template <typename T2>
107 friend bool operator!=(nullptr_t nullpointer, const Nullable<T2> &op);
108
109 private:
110 void checkHasValue() const;
111 66
112 private:67 friend class Nullable;
113 bool m_hasValue;
114 T m_value;
115 };68 };
116 69
117 public:
118 NullableValue Value;70 NullableValue Value;
119 };71 };
120 72
121 template <typename T>73 template<class T>
122 Nullable<T>::NullableValue::NullableValue()74 Nullable<T>::NullableValue::NullableValue() : // NOLINT
123 : m_hasValue(false), m_value(T()) { }75 m_hasValue(false),
76 m_value(T())
77 {
78 }
124 79
125 template <typename T>80 template<class T>
126 Nullable<T>::NullableValue::NullableValue(const T &value)81 Nullable<T>::NullableValue::NullableValue(const T& value):
127 : m_hasValue(true), m_value(value) { }82 m_hasValue(true),
83 m_value(value)
84 {
85 }
128 86
129 template <typename T>87 template<class T>
130 Nullable<T>::NullableValue::operator const T &() const88 Nullable<T>::NullableValue::operator const T&() const
131 {89 {
132 checkHasValue();90 checkHasValue();
133 return m_value;91 return m_value;
134 }92 }
135 93
136 template <typename T>94 template<class T>
137 const T & Nullable<T>::NullableValue::operator*() const95 const T& Nullable<T>::NullableValue::operator*() const
138 {96 {
139 checkHasValue();97 checkHasValue();
140 return m_value;98 return m_value;
141 }99 }
142 100
143 template <typename T>101 template<class T> // NOLINT
144 const T * Nullable<T>::NullableValue::operator&() const102 const T* Nullable<T>::NullableValue::operator&() const // NOLINT
145 {103 {
146 checkHasValue();104 checkHasValue();
147 return &m_value;105 return &m_value;
148 }106 }
149 107
150 template <typename T>108 template<class T>
151 const T * Nullable<T>::NullableValue::operator->() const109 const T* Nullable<T>::NullableValue::operator->() const
152 {110 {
153 checkHasValue();111 checkHasValue();
154 return &m_value;112 return &m_value;
155 }113 }
156 114
157 template <typename T>115 template<class T>
158 void Nullable<T>::NullableValue::checkHasValue() const116 void Nullable<T>::NullableValue::checkHasValue() const
159 {117 {
160 if (!m_hasValue)118 if (!m_hasValue)
161 throw std::exception("Nullable object must have a value");119 throw std::exception("Nullable object must have a value");
162 }120 }
163 121
164 template <typename T>122 template<class T>
165 bool Nullable<T>::HasValue() const { return Value.m_hasValue; }123 bool Nullable<T>::HasValue() const { return Value.m_hasValue; }
166 124
167 template <typename T>125 template<class T>
168 const T & Nullable<T>::GetValueOrDefault() const126 const T& Nullable<T>::GetValueOrDefault() const
169 {127 {
170 return Value.m_value;128 return Value.m_value;
171 }129 }
172 130
173 template <typename T>131 template<class T>
174 const T & Nullable<T>::GetValueOrDefault(const T &def) const132 const T& Nullable<T>::GetValueOrDefault(const T& def) const
175 {133 {
176 if (Value.m_hasValue)134 if (Value.m_hasValue)
177 return Value.m_value;135 return Value.m_value;
178 else136
179 return def;137 return def;
180 }138 }
181 139
182 template <typename T>140 template<class T>
183 bool Nullable<T>::TryGetValue(T &value) const141 bool Nullable<T>::TryGetValue(T& value) const
184 {142 {
185 value = Value.m_value;143 value = Value.m_value;
186 return Value.m_hasValue;144 return Value.m_hasValue;
187 }145 }
188 146
189 template <typename T>147 template<class T>
190 Nullable<T>::Nullable() { }148 Nullable<T>::Nullable()
149 {
150 }
191 151
192 template <typename T>152 template<class T>
193 Nullable<T>::Nullable(nullptr_t nullpointer) { (void)nullpointer; }153 Nullable<T>::Nullable(nullptr_t nullpointer)
154 {
155 (void)nullpointer;
156 }
194 157
195 template <typename T>158 template<class T>
196 Nullable<T>::Nullable(const T &value)159 Nullable<T>::Nullable(const T& value)
197 : Value(value) { }160 : Value(value)
161 {
162 }
198 163
199 template <typename T2>164 template<class T2>
200 bool operator==(const Nullable<T2> &op1, const Nullable<T2> &op2)165 bool operator==(const Nullable<T2> &op1, const Nullable<T2> &op2)
201 {166 {
202 if (op1.Value.m_hasValue != op2.Value.m_hasValue)167 if (op1.Value.m_hasValue != op2.Value.m_hasValue)
@@ -204,11 +169,11 @@ namespace GSF · 1 unmodified line
204 169
205 if (op1.Value.m_hasValue)170 if (op1.Value.m_hasValue)
206 return op1.Value.m_value == op2.Value.m_value;171 return op1.Value.m_value == op2.Value.m_value;
207 else172
208 return true;173 return true;
209 }174 }
210 175
211 template <typename T2>176 template<class T2>
212 bool operator==(const Nullable<T2> &op, const T2 &value)177 bool operator==(const Nullable<T2> &op, const T2 &value)
213 {178 {
214 if (!op.Value.m_hasValue)179 if (!op.Value.m_hasValue)
@@ -217,7 +182,7 @@ namespace GSF · 2 unmodified lines
217 return op.Value.m_value == value;182 return op.Value.m_value == value;
218 }183 }
219 184
220 template <typename T2>185 template<class T2>
221 bool operator==(const T2 &value, const Nullable<T2> &op)186 bool operator==(const T2 &value, const Nullable<T2> &op)
222 {187 {
223 if (!op.Value.m_hasValue)188 if (!op.Value.m_hasValue)
@@ -226,21 +191,21 @@ namespace GSF · 2 unmodified lines
226 return op.Value.m_value == value;191 return op.Value.m_value == value;
227 }192 }
228 193
229 template <typename T2>194 template<class T2>
230 bool operator==(const Nullable<T2> &op, nullptr_t nullpointer)195 bool operator==(const Nullable<T2> &op, nullptr_t nullpointer)
231 {196 {
232 (void)nullpointer;197 (void)nullpointer;
233 return !op.Value.m_hasValue;198 return !op.Value.m_hasValue;
234 }199 }
235 200
236 template <typename T2>201 template<class T2>
237 bool operator==(nullptr_t nullpointer, const Nullable<T2> &op)202 bool operator==(nullptr_t nullpointer, const Nullable<T2> &op)
238 {203 {
239 (void)nullpointer;204 (void)nullpointer;
240 return !op.Value.m_hasValue;205 return !op.Value.m_hasValue;
241 }206 }
242 207
243 template <typename T2>208 template<class T2>
244 bool operator!=(const Nullable<T2> &op1, const Nullable<T2> &op2)209 bool operator!=(const Nullable<T2> &op1, const Nullable<T2> &op2)
245 {210 {
246 if (op1.Value.m_hasValue != op2.Value.m_hasValue)211 if (op1.Value.m_hasValue != op2.Value.m_hasValue)
@@ -248,11 +213,11 @@ namespace GSF · 1 unmodified line
248 213
249 if (op1.Value.m_hasValue)214 if (op1.Value.m_hasValue)
250 return op1.Value.m_value != op2.Value.m_value;215 return op1.Value.m_value != op2.Value.m_value;
251 else216
252 return false;217 return false;
253 }218 }
254 219
255 template <typename T2>220 template<class T2>
256 bool operator!=(const Nullable<T2> &op, const T2 &value)221 bool operator!=(const Nullable<T2> &op, const T2 &value)
257 {222 {
258 if (!op.Value.m_hasValue)223 if (!op.Value.m_hasValue)
@@ -261,7 +226,7 @@ namespace GSF · 2 unmodified lines
261 return op.Value.m_value != value;226 return op.Value.m_value != value;
262 }227 }
263 228
264 template <typename T2>229 template<class T2>
265 bool operator!=(const T2 &value, const Nullable<T2> &op)230 bool operator!=(const T2 &value, const Nullable<T2> &op)
266 {231 {
267 if (!op.Value.m_hasValue)232 if (!op.Value.m_hasValue)
@@ -270,38 +235,38 @@ namespace GSF · 2 unmodified lines
270 return op.Value.m_value != value;235 return op.Value.m_value != value;
271 }236 }
272 237
273 template <typename T2>238 template<class T2>
274 bool operator!=(const Nullable<T2> &op, nullptr_t nullpointer)239 bool operator!=(const Nullable<T2> &op, nullptr_t nullpointer)
275 {240 {
276 (void)nullpointer;241 (void)nullpointer;
277 return op.Value.m_hasValue;242 return op.Value.m_hasValue;
278 }243 }
279 244
280 template <typename T2>245 template<class T2>
281 bool operator!=(nullptr_t nullpointer, const Nullable<T2> &op)246 bool operator!=(nullptr_t nullpointer, const Nullable<T2> &op)
282 {247 {
283 (void)nullpointer;248 (void)nullpointer;
284 return op.Value.m_hasValue;249 return op.Value.m_hasValue;
285 }250 }
286 251
287 template <typename T>252 template<class T> // NOLINT
288 const Nullable<T> & Nullable<T>::operator=(const Nullable<T> &value)253 const Nullable<T>& Nullable<T>::operator=(const Nullable<T>& value)
289 {254 {
290 Value.m_hasValue = value.Value.m_hasValue;255 Value.m_hasValue = value.Value.m_hasValue;
291 Value.m_value = value.Value.m_value;256 Value.m_value = value.Value.m_value;
292 return *this;257 return *this;
293 }258 }
294 259
295 template <typename T>260 template<class T> // NOLINT
296 const Nullable<T> & Nullable<T>::operator=(const T &value)261 const Nullable<T>& Nullable<T>::operator=(const T& value)
297 {262 {
298 Value.m_hasValue = true;263 Value.m_hasValue = true;
299 Value.m_value = value;264 Value.m_value = value;
300 return *this;265 return *this;
301 }266 }
302 267
303 template <typename T>268 template<class T> // NOLINT
304 const Nullable<T> & Nullable<T>::operator=(nullptr_t nullpointer)269 const Nullable<T>& Nullable<T>::operator=(nullptr_t nullpointer)
305 {270 {
306 (void)nullpointer;271 (void)nullpointer;
307 Value.m_hasValue = false;272 Value.m_hasValue = false;
@@ -309,7 +274,7 @@ namespace GSF · 1 unmodified line
309 return *this;274 return *this;
310 }275 }
311 276
312 template<typename T, typename U>277 template<class T, class U>
313 Nullable<T> CastAsNullable(const Nullable<U>& source)278 Nullable<T> CastAsNullable(const Nullable<U>& source)
314 {279 {
315 if (source.HasValue())280 if (source.HasValue())
@@ -318,7 +283,7 @@ namespace GSF · 2 unmodified lines
318 return nullptr;283 return nullptr;
319 }284 }
320 285
321 template<typename T>286 template<class T>
322 std::string ToString(const Nullable<T>& value)287 std::string ToString(const Nullable<T>& value)
323 {288 {
324 if (value.HasValue())289 if (value.HasValue())
@@ -367,7 +332,7 @@ namespace GSF · 42 unmodified lines
367 return {};332 return {};
368 }333 }
369 334
370 template<typename T>335 template<class T>
371 static int32_t CompareValues(Nullable<T> leftNullable, Nullable<T> rightNullable)336 static int32_t CompareValues(Nullable<T> leftNullable, Nullable<T> rightNullable)
372 {337 {
373 const bool leftHasValue = leftNullable.HasValue();338 const bool leftHasValue = leftNullable.HasValue();
Source/Libraries/TimeSeriesPlatformLibrary/Common/ThreadSafeQueue.h+11−12
@@ -24,9 +24,8 @@ · 23 unmodified lines
24#ifndef __THREAD_SAFE_QUEUE_H24#ifndef __THREAD_SAFE_QUEUE_H
25#define __THREAD_SAFE_QUEUE_H25#define __THREAD_SAFE_QUEUE_H
26 26
27#include <queue>
28
29#include "CommonTypes.h"27#include "CommonTypes.h"
28#include <queue>
30 29
31namespace GSF30namespace GSF
32{31{
@@ -37,8 +36,8 @@ namespace GSF · 4 unmodified lines
37 // single thread and process in FIFO order.36 // single thread and process in FIFO order.
38 //37 //
39 // The use of multiple consumers may cause undesired effects.38 // The use of multiple consumers may cause undesired effects.
40 template <class T>39 template<class T>
41 class ThreadSafeQueue40 class ThreadSafeQueue // NOLINT
42 {41 {
43 private:42 private:
44 Mutex m_mutex;43 Mutex m_mutex;
@@ -89,14 +88,14 @@ namespace GSF · 44 unmodified lines
89 };88 };
90 89
91 // Releases all threads waiting for data.90 // Releases all threads waiting for data.
92 template <class T>91 template<class T>
93 ThreadSafeQueue<T>::~ThreadSafeQueue()92 ThreadSafeQueue<T>::~ThreadSafeQueue()
94 {93 {
95 Release();94 Release();
96 }95 }
97 96
98 // Inserts an item into the queue.97 // Inserts an item into the queue.
99 template <class T>98 template<class T>
100 void ThreadSafeQueue<T>::Enqueue(T item)99 void ThreadSafeQueue<T>::Enqueue(T item)
101 {100 {
102 ScopeLock lock(m_mutex);101 ScopeLock lock(m_mutex);
@@ -106,7 +105,7 @@ namespace GSF · 3 unmodified lines
106 105
107 // Removes an item from the106 // Removes an item from the
108 // queue and returns that item.107 // queue and returns that item.
109 template <class T>108 template<class T>
110 T ThreadSafeQueue<T>::Dequeue()109 T ThreadSafeQueue<T>::Dequeue()
111 {110 {
112 ScopeLock lock(m_mutex);111 ScopeLock lock(m_mutex);
@@ -116,7 +115,7 @@ namespace GSF · 3 unmodified lines
116 }115 }
117 116
118 // Empties the queue.117 // Empties the queue.
119 template <class T>118 template<class T>
120 void ThreadSafeQueue<T>::Clear()119 void ThreadSafeQueue<T>::Clear()
121 {120 {
122 ScopeLock lock(m_mutex);121 ScopeLock lock(m_mutex);
@@ -127,7 +126,7 @@ namespace GSF · 4 unmodified lines
127 126
128 // Returns the number of127 // Returns the number of
129 // items left in the queue.128 // items left in the queue.
130 template <class T>129 template<class T>
131 uint32_t ThreadSafeQueue<T>::Size()130 uint32_t ThreadSafeQueue<T>::Size()
132 {131 {
133 ScopeLock lock(m_mutex);132 ScopeLock lock(m_mutex);
@@ -137,7 +136,7 @@ namespace GSF · 3 unmodified lines
137 // Waits for data to be inserted into the queue.136 // Waits for data to be inserted into the queue.
138 // If there is already data in the queue,137 // If there is already data in the queue,
139 // this method will not wait.138 // this method will not wait.
140 template <class T>139 template<class T>
141 void ThreadSafeQueue<T>::WaitForData()140 void ThreadSafeQueue<T>::WaitForData()
142 {141 {
143 UniqueLock lock(m_mutex);142 UniqueLock lock(m_mutex);
@@ -147,7 +146,7 @@ namespace GSF · 3 unmodified lines
147 }146 }
148 147
149 // Releases all threads waiting for data.148 // Releases all threads waiting for data.
150 template <class T>149 template<class T>
151 void ThreadSafeQueue<T>::Release()150 void ThreadSafeQueue<T>::Release()
152 {151 {
153 ScopeLock lock(m_mutex);152 ScopeLock lock(m_mutex);
@@ -159,7 +158,7 @@ namespace GSF · 5 unmodified lines
159 // Resets the "release valve" for threads calling WaitForData.158 // Resets the "release valve" for threads calling WaitForData.
160 // This can be called after Release so that the queue can be159 // This can be called after Release so that the queue can be
161 // used again.160 // used again.
162 template <class T>161 template<class T>
163 void ThreadSafeQueue<T>::Reset()162 void ThreadSafeQueue<T>::Reset()
164 {163 {
165 ScopeLock lock(m_mutex);164 ScopeLock lock(m_mutex);
Source/Libraries/TimeSeriesPlatformLibrary/FilterExpressions/ExpressionTree.cpp+2−2
@@ -2843,7 +2843,7 @@ ValueExpressionPtr ExpressionTree::Or(const ValueExpressionPtr& leftValue, const · 2842 unmodified lines
2843 return NewSharedPtr<ValueExpression>(ExpressionValueType::Boolean, left || right);2843 return NewSharedPtr<ValueExpression>(ExpressionValueType::Boolean, left || right);
2844}2844}
2845 2845
2846template<typename T>2846template<class T>
2847T ExpressionTree::Unary(const T& unaryValue, ExpressionUnaryType unaryOperation)2847T ExpressionTree::Unary(const T& unaryValue, ExpressionUnaryType unaryOperation)
2848{2848{
2849 switch (unaryOperation)2849 switch (unaryOperation)
@@ -2859,7 +2859,7 @@ T ExpressionTree::Unary(const T& unaryValue, ExpressionUnaryType unaryOperation) · 9 unmodified lines
2859 }2859 }
2860}2860}
2861 2861
2862template<typename T>2862template<class T>
2863T ExpressionTree::UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType)2863T ExpressionTree::UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType)
2864{2864{
2865 switch (unaryOperation)2865 switch (unaryOperation)
Source/Libraries/TimeSeriesPlatformLibrary/FilterExpressions/ExpressionTree.h+2−2
@@ -366,10 +366,10 @@ private: · 365 unmodified lines
366 ValueExpressionPtr And(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;366 ValueExpressionPtr And(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;
367 ValueExpressionPtr Or(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;367 ValueExpressionPtr Or(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;
368 368
369 template<typename T>369 template<class T>
370 static T Unary(const T& unaryValue, ExpressionUnaryType unaryOperation);370 static T Unary(const T& unaryValue, ExpressionUnaryType unaryOperation);
371 371
372 template<typename T>372 template<class T>
373 static T UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType);373 static T UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType);
374 374
375 static bool UnaryBool(bool unaryValue, ExpressionUnaryType unaryOperation);375 static bool UnaryBool(bool unaryValue, ExpressionUnaryType unaryOperation);
Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimplePublish.cpp+5−3
@@ -21,13 +21,12 @@ · 20 unmodified lines
21//21//
22//******************************************************************************************************22//******************************************************************************************************
23 23
24#include <iostream>
25#include <string>
26
27#include "../Transport/DataPublisher.h"24#include "../Transport/DataPublisher.h"
25#include <iostream>
28 26
29using namespace std;27using namespace std;
30using namespace GSF;28using namespace GSF;
29using namespace GSF::Data;
31using namespace GSF::TimeSeries;30using namespace GSF::TimeSeries;
32using namespace GSF::TimeSeries::Transport;31using namespace GSF::TimeSeries::Transport;
33 32
@@ -115,6 +114,9 @@ bool RunPublisher(uint16_t port) · 81 unmodified lines
115 Publisher->RegisterClientDisconnectedCallback(&DisplayClientDisconnected);114 Publisher->RegisterClientDisconnectedCallback(&DisplayClientDisconnected);
116 Publisher->RegisterStatusMessageCallback(&DisplayStatusMessage);115 Publisher->RegisterStatusMessageCallback(&DisplayStatusMessage);
117 Publisher->RegisterErrorMessageCallback(&DisplayErrorMessage);116 Publisher->RegisterErrorMessageCallback(&DisplayErrorMessage);
117
118 // Define metadata
119 Publisher->DefineMetadata(DataSet::FromXml("Metadata.xml"));
118 }120 }
119 else121 else
120 {122 {
Source/Libraries/TimeSeriesPlatformLibrary/Transport/ActiveMeasurementsSchema.cpp+2−2
@@ -1,4 +1,4 @@
1// Auto-generated on Thu Feb 7 16:57:40 20191// Auto-generated on Fri Feb 8 13:02:59 2019
2// EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::2// EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::
3 3
4#include "ActiveMeasurementsSchema.h"4#include "ActiveMeasurementsSchema.h"
@@ -206,7 +206,7 @@ const uint8_t GSF::TimeSeries::Transport::ActiveMeasurementsSchema[] = { · 201 unmodified lines
206 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x65,206 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x65,
207 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E, 0x3C, 0x2F, 0x78,207 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E, 0x3C, 0x2F, 0x78,
208 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x3E, 0x3C,208 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x3E, 0x3C,
209 0x2F, 0x49, 0x61, 0x6F, 0x6E, 0x3E, 0x00209 0x2F, 0x49, 0x61, 0x6F, 0x6E, 0x3E
210};210};
211 211
212const uint32_t GSF::TimeSeries::Transport::ActiveMeasurementsSchemaLength = sizeof(GSF::TimeSeries::Transport::ActiveMeasurementsSchema);212const uint32_t GSF::TimeSeries::Transport::ActiveMeasurementsSchemaLength = sizeof(GSF::TimeSeries::Transport::ActiveMeasurementsSchema);
Source/Libraries/TimeSeriesPlatformLibrary/Transport/ActiveMeasurementsSchema.h+1−1
@@ -1,4 +1,4 @@
1// Auto-generated on Thu Feb 7 16:57:40 20191// Auto-generated on Fri Feb 8 13:02:59 2019
2// EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::2// EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::
3 3
4#ifndef _ACTIVE_MEASUREMENTS_SCHEMA4#ifndef _ACTIVE_MEASUREMENTS_SCHEMA
Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataPublisher.cpp+36−37
@@ -646,68 +646,70 @@ DataSetPtr DataPublisher::FilterClientMetadata(const SubscriberConnectionPtr& co · 645 unmodified lines
646 646
647vector<uint8_t> DataPublisher::SerializeSignalIndexCache(const SubscriberConnectionPtr& connection, const SignalIndexCachePtr& signalIndexCache) const647vector<uint8_t> DataPublisher::SerializeSignalIndexCache(const SubscriberConnectionPtr& connection, const SignalIndexCachePtr& signalIndexCache) const
648{648{
649 if (connection == nullptr)649 vector<uint8_t> serializationBuffer;
650 return vector<uint8_t>{};
651 650
652 const uint32_t operationalModes = connection->GetOperationalModes();651 if (connection != nullptr)
653 const uint32_t compressionModes = operationalModes & OperationalModes::CompressionModeMask;652 {
654 const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;653 const uint32_t operationalModes = connection->GetOperationalModes();
655 const bool compressSignalIndexCache = (operationalModes & OperationalModes::CompressSignalIndexCache) > 0;654 const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;
655 const bool compressSignalIndexCache = (operationalModes & OperationalModes::CompressSignalIndexCache) > 0;
656 const bool useGZipCompression = (operationalModes & CompressionModes::GZip) > 0;
656 657
657 if (!useCommonSerializationFormat)658 if (!useCommonSerializationFormat)
658 throw PublisherException("DataPublisher only supports common serialization format");659 throw PublisherException("DataPublisher only supports common serialization format");
659 660
660 vector<uint8_t> serializedCache(uint32_t(signalIndexCache->GetBinaryLength() * 0.02));661 serializationBuffer.reserve(uint32_t(signalIndexCache->GetBinaryLength() * 0.02));
661 signalIndexCache->Serialize(connection, serializedCache);662 signalIndexCache->Serialize(connection, serializationBuffer);
662 663
663 if (compressSignalIndexCache && (compressionModes & CompressionModes::GZip) > 0)664 if (compressSignalIndexCache && useGZipCompression)
664 {665 {
665 const MemoryStream metadataStream(serializedCache);666 const MemoryStream memoryStream(serializationBuffer);
666 StreamBuffer streamBuffer;667 StreamBuffer streamBuffer;
667 668
668 streamBuffer.push(GZipCompressor());669 streamBuffer.push(GZipCompressor());
669 streamBuffer.push(metadataStream);670 streamBuffer.push(memoryStream);
670 671
671 vector<uint8_t> compressed;672 vector<uint8_t> compressedBuffer;
672 CopyStream(&streamBuffer, compressed);673 CopyStream(&streamBuffer, compressedBuffer);
673 return compressed;674 return compressedBuffer;
675 }
674 }676 }
675 677
676 return serializedCache;678 return serializationBuffer;
677}679}
678 680
679vector<uint8_t> DataPublisher::SerializeMetadata(const SubscriberConnectionPtr& connection, const DataSetPtr& metadata) const681vector<uint8_t> DataPublisher::SerializeMetadata(const SubscriberConnectionPtr& connection, const DataSetPtr& metadata) const
680{682{
681 vector<uint8_t> serializedMetadata;683 vector<uint8_t> serializationBuffer;
682 684
683 if (connection != nullptr)685 if (connection != nullptr)
684 {686 {
685 const uint32_t operationalModes = connection->GetOperationalModes();687 const uint32_t operationalModes = connection->GetOperationalModes();
686 const uint32_t compressionModes = operationalModes & OperationalModes::CompressionModeMask;
687 const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;688 const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;
688 const bool compressMetadata = (operationalModes & OperationalModes::CompressMetadata) > 0;689 const bool compressMetadata = (operationalModes & OperationalModes::CompressMetadata) > 0;
690 const bool useGZipCompression = (operationalModes & CompressionModes::GZip) > 0;
689 691
690 if (!useCommonSerializationFormat)692 if (!useCommonSerializationFormat)
691 throw PublisherException("DataPublisher only supports common serialization format");693 throw PublisherException("DataPublisher only supports common serialization format");
692 694
693 metadata->WriteXml(serializedMetadata);695 metadata->WriteXml(serializationBuffer);
694 696
695 if (compressMetadata && (compressionModes & CompressionModes::GZip) > 0)697 if (compressMetadata && useGZipCompression)
696 {698 {
697 const MemoryStream metadataStream(serializedMetadata);699 const MemoryStream memoryStream(serializationBuffer);
698 StreamBuffer streamBuffer;700 StreamBuffer streamBuffer;
699 701
700 streamBuffer.push(GZipCompressor());702 streamBuffer.push(GZipCompressor());
701 streamBuffer.push(metadataStream);703 streamBuffer.push(memoryStream);
702 704
703 vector<uint8_t> compressed;705 vector<uint8_t> compressionBuffer;
704 CopyStream(&streamBuffer, compressed);706 CopyStream(&streamBuffer, compressionBuffer);
705 707
706 return compressed;708 return compressionBuffer;
707 }709 }
708 }710 }
709 711
710 return serializedMetadata;712 return serializationBuffer;
711}713}
712 714
713bool DataPublisher::SendClientResponse(const SubscriberConnectionPtr& connection, uint8_t responseCode, uint8_t commandCode, const std::string& message)715bool DataPublisher::SendClientResponse(const SubscriberConnectionPtr& connection, uint8_t responseCode, uint8_t commandCode, const std::string& message)
@@ -745,10 +747,7 @@ bool DataPublisher::SendClientResponse(const SubscriberConnectionPtr& connection · 31 unmodified lines
745 if (data.empty())747 if (data.empty())
746 {748 {
747 // Add zero sized data buffer to response packet749 // Add zero sized data buffer to response packet
748 buffer.push_back(0);750 WriteBytes(buffer, uint32_t(0));
749 buffer.push_back(0);
750 buffer.push_back(0);
751 buffer.push_back(0);
752 }751 }
753 else752 else
754 {753 {
@@ -1081,7 +1080,7 @@ void DataPublisher::DefineMetadata(const DataSetPtr& metadata) · 326 unmodified lines
1081 phasorData[deviceName] = phasorMap;1080 phasorData[deviceName] = phasorMap;
1082 }1081 }
1083 1082
1084 phasorMap->at(row->ValueAsInt32(sourceIndex).GetValueOrDefault()) = phasor;1083 phasorMap->insert_or_assign(row->ValueAsInt32(sourceIndex).GetValueOrDefault(), phasor);
1085 }1084 }
1086 }1085 }
1087 1086
@@ -1147,8 +1146,8 @@ void DataPublisher::DefineMetadata(const DataSetPtr& metadata) · 59 unmodified lines
1147 am_row->SetGuidValue(am_signalID, md_row->ValueAsGuid(md_signalID));1146 am_row->SetGuidValue(am_signalID, md_row->ValueAsGuid(md_signalID));
1148 am_row->SetStringValue(am_pointTag, md_row->ValueAsString(md_pointTag));1147 am_row->SetStringValue(am_pointTag, md_row->ValueAsString(md_pointTag));
1149 am_row->SetStringValue(am_signalReference, md_row->ValueAsString(md_signalReference));1148 am_row->SetStringValue(am_signalReference, md_row->ValueAsString(md_signalReference));
1150 am_row->SetInt32Value(am_internal, md_row->ValueAsInt32(md_internal));1149 am_row->SetInt32Value(am_internal, md_row->ValueAsBoolean(md_internal).GetValueOrDefault() ? 1 : 0);
1151 am_row->SetBooleanValue(am_subscribed, false);1150 am_row->SetInt32Value(am_subscribed, 0);
1152 am_row->SetStringValue(am_description, md_row->ValueAsString(md_description));1151 am_row->SetStringValue(am_description, md_row->ValueAsString(md_description));
1153 am_row->SetDoubleValue(am_adder, 0.0);1152 am_row->SetDoubleValue(am_adder, 0.0);
1154 am_row->SetDoubleValue(am_multiplier, 1.0);1153 am_row->SetDoubleValue(am_multiplier, 1.0);
Source/Libraries/TimeSeriesPlatformLibrary/Transport/DataSubscriber.cpp+1−0
@@ -224,6 +224,7 @@ bool SubscriberConnector::GetAutoReconnect() const · 223 unmodified lines
224// --- DataSubscriber ---224// --- DataSubscriber ---
225 225
226DataSubscriber::DataSubscriber() :226DataSubscriber::DataSubscriber() :
227 m_subscriberID(Empty::Guid),
227 m_compressPayloadData(true),228 m_compressPayloadData(true),
228 m_compressMetadata(true),229 m_compressMetadata(true),
229 m_compressSignalIndexCache(true),230 m_compressSignalIndexCache(true),
Source/Libraries/TimeSeriesPlatformLibrary/Transport/MetadataSchema.cpp+2−2
@@ -1,4 +1,4 @@
1// Auto-generated on Thu Feb 7 17:00:15 20191// Auto-generated on Fri Feb 8 13:02:18 2019
2// EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::2// EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::
3 3
4#include "MetadataSchema.h"4#include "MetadataSchema.h"
@@ -331,7 +331,7 @@ const uint8_t GSF::TimeSeries::Transport::MetadataSchema[] = { · 326 unmodified lines
331 0x65, 0x78, 0x54, 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78,331 0x65, 0x78, 0x54, 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78,
332 0x73, 0x3A, 0x65, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E,332 0x73, 0x3A, 0x65, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E,
333 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D,333 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D,
334 0x61, 0x3E, 0x00334 0x61, 0x3E
335};335};
336 336
337const uint32_t GSF::TimeSeries::Transport::MetadataSchemaLength = sizeof(GSF::TimeSeries::Transport::MetadataSchema);337const uint32_t GSF::TimeSeries::Transport::MetadataSchemaLength = sizeof(GSF::TimeSeries::Transport::MetadataSchema);
Source/Libraries/TimeSeriesPlatformLibrary/Transport/MetadataSchema.h+1−1
@@ -1,4 +1,4 @@
1// Auto-generated on Thu Feb 7 17:00:15 20191// Auto-generated on Fri Feb 8 13:02:18 2019
2// EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::2// EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::
3 3
4#ifndef _METADATA_SCHEMA4#ifndef _METADATA_SCHEMA
Source/Libraries/TimeSeriesPlatformLibrary/Transport/SignalIndexCache.cpp+4−14
@@ -178,7 +178,7 @@ void SignalIndexCache::Parse(const vector<uint8_t>& buffer, Guid& subscriberID) · 177 unmodified lines
178 const uint32_t referenceCount = EndianConverter::Default.ConvertBigEndian(*referenceCountPtr);178 const uint32_t referenceCount = EndianConverter::Default.ConvertBigEndian(*referenceCountPtr);
179 179
180 // Set up signalIndexPtr before entering the loop180 // Set up signalIndexPtr before entering the loop
181 const uint16_t * signalIndexPtr = reinterpret_cast<const uint16_t*>(referenceCountPtr + 1);181 const uint16_t* signalIndexPtr = reinterpret_cast<const uint16_t*>(referenceCountPtr + 1);
182 182
183 for (uint32_t i = 0; i < referenceCount; ++i)183 for (uint32_t i = 0; i < referenceCount; ++i)
184 {184 {
@@ -222,19 +222,12 @@ void SignalIndexCache::Serialize(const SubscriberConnectionPtr& connection, vect · 37 unmodified lines
222 uint32_t binaryLength = 28;222 uint32_t binaryLength = 28;
223 223
224 // Reserve space for binary byte length of cache224 // Reserve space for binary byte length of cache
225 buffer.push_back(0);225 WriteBytes(buffer, uint32_t(0));
226 buffer.push_back(0);
227 buffer.push_back(0);
228 buffer.push_back(0);
229 226
230 // Encode subscriber ID227 // Encode subscriber ID
231 Guid subscriberID = connection->GetSubscriberID();228 Guid subscriberID = connection->GetSubscriberID();
232
233 SwapGuidEndianness(subscriberID, true);229 SwapGuidEndianness(subscriberID, true);
234 uint8_t* bytes = subscriberID.data;230 WriteBytes(buffer, subscriberID);
235
236 for (int32_t i = 0; i < 16; i++)
237 buffer.push_back(bytes[i]);
238 231
239 // Encode number of references232 // Encode number of references
240 EndianConverter::WriteBigEndianBytes(buffer, int32_t(m_reference.size()));233 EndianConverter::WriteBigEndianBytes(buffer, int32_t(m_reference.size()));
@@ -248,10 +241,7 @@ void SignalIndexCache::Serialize(const SubscriberConnectionPtr& connection, vect · 7 unmodified lines
248 241
249 // Encode signal ID242 // Encode signal ID
250 SwapGuidEndianness(signalID, true);243 SwapGuidEndianness(signalID, true);
251 bytes = signalID.data;244 WriteBytes(buffer, signalID);
252
253 for (int32_t j = 0; j < 16; j++)
254 buffer.push_back(bytes[j]);
255 245
256 // Encode source246 // Encode source
257 vector<uint8_t> sourceBytes = DataPublisher::EncodeClientString(connection, m_sourceList[i]);247 vector<uint8_t> sourceBytes = DataPublisher::EncodeClientString(connection, m_sourceList[i]);
Source/Libraries/TimeSeriesPlatformLibrary/Transport/SubscriberConnection.h+1−1
@@ -36,7 +36,7 @@ namespace Transport · 35 unmodified lines
36 typedef GSF::SharedPtr<DataPublisher> DataPublisherPtr;36 typedef GSF::SharedPtr<DataPublisher> DataPublisherPtr;
37 37
38 // Represents a subscriber connection to a data publisher38 // Represents a subscriber connection to a data publisher
39 class SubscriberConnection : public GSF::EnableSharedThisPtr<SubscriberConnection> //NOLINT39 class SubscriberConnection : public GSF::EnableSharedThisPtr<SubscriberConnection> // NOLINT
40 {40 {
41 private:41 private:
42 const DataPublisherPtr m_parent;42 const DataPublisherPtr m_parent;
Source/Libraries/TimeSeriesPlatformLibrary/Transport/SubscriberInstance.cpp+9−9
@@ -577,35 +577,35 @@ void SubscriberInstance::ReceivedMetadata(const vector<uint8_t>& payload) · 576 unmodified lines
577 return;577 return;
578 }578 }
579 579
580 vector<uint8_t>* uncompressed;580 vector<uint8_t>* uncompressesBuffer;
581 581
582 // Step 1: Decompress meta-data if needed582 // Step 1: Decompress meta-data if needed
583 if (IsMetadataCompressed())583 if (IsMetadataCompressed())
584 {584 {
585 // Perform zlib decompression on buffer585 // Perform zlib decompression on buffer
586 const MemoryStream payloadStream(payload);586 const MemoryStream memoryStream(payload);
587 StreamBuffer streamBuffer;587 StreamBuffer streamBuffer;
588 588
589 streamBuffer.push(GZipDecompressor());589 streamBuffer.push(GZipDecompressor());
590 streamBuffer.push(payloadStream);590 streamBuffer.push(memoryStream);
591 591
592 uncompressed = new vector<uint8_t>();592 uncompressesBuffer = new vector<uint8_t>();
593 CopyStream(&streamBuffer, *uncompressed);593 CopyStream(&streamBuffer, *uncompressesBuffer);
594 }594 }
595 else595 else
596 {596 {
597 uncompressed = const_cast<vector<uint8_t>*>(&payload);597 uncompressesBuffer = const_cast<vector<uint8_t>*>(&payload);
598 }598 }
599 599
600 // Step 2: Load string into an XML parser600 // Step 2: Load string into an XML parser
601 xml_document document;601 xml_document document;
602 602
603 const xml_parse_result result = document.load_buffer_inplace(static_cast<void*>(uncompressed->data()), uncompressed->size());603 const xml_parse_result result = document.load_buffer_inplace(static_cast<void*>(uncompressesBuffer->data()), uncompressesBuffer->size());
604 604
605 if (result.status != xml_parse_status::status_ok)605 if (result.status != xml_parse_status::status_ok)
606 {606 {
607 if (IsMetadataCompressed())607 if (IsMetadataCompressed())
608 delete uncompressed;608 delete uncompressesBuffer;
609 609
610 stringstream errorMessageStream;610 stringstream errorMessageStream;
611 errorMessageStream << "Failed to parse meta data XML, status code = " << ToHex(result.status);611 errorMessageStream << "Failed to parse meta data XML, status code = " << ToHex(result.status);
@@ -758,7 +758,7 @@ void SubscriberInstance::ReceivedMetadata(const vector<uint8_t>& payload) · 146 unmodified lines
758 758
759 // Release uncompressed buffer759 // Release uncompressed buffer
760 if (IsMetadataCompressed())760 if (IsMetadataCompressed())
761 delete uncompressed;761 delete uncompressesBuffer;
762 762
763 // Notify derived class that meta-data has been parsed and is now available763 // Notify derived class that meta-data has been parsed and is now available
764 ParsedMetadata();764 ParsedMetadata();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t