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
127127 return boost::make_shared<T>();
128128 }
129129
130− template<class T, typename P1>
130+ template<class T, class P1>
131131 SharedPtr<T> NewSharedPtr(P1 p1)
132132 {
133133 return boost::make_shared<T>(p1);
134134 }
135135
136− template<class T, typename P1, typename P2>
136+ template<class T, class P1, class P2>
137137 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2)
138138 {
139139 return boost::make_shared<T>(p1, p2);
140140 }
141141
142− template<class T, typename P1, typename P2, typename P3>
142+ template<class T, class P1, class P2, class P3>
143143 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3)
144144 {
145145 return boost::make_shared<T>(p1, p2, p3);
146146 }
147147
148− template<class T, typename P1, typename P2, typename P3, typename P4>
148+ template<class T, class P1, class P2, class P3, class P4>
149149 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4)
150150 {
151151 return boost::make_shared<T>(p1, p2, p3, p4);
152152 }
153153
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>
155155 SharedPtr<T> NewSharedPtr(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
156156 {
157157 return boost::make_shared<T>(p1, p2, p3, p4, p5);
@@ -221,7 +221,7 @@ namespace GSF · 63 unmodified lines
221221 template<class T>
222222 using SortedStringMap = std::map<std::string, T, GSF::StringComparer>;
223223
224− template<typename TKey, typename TValue>
224+ template<class TKey, class TValue>
225225 bool TryGetValue(const std::map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)
226226 {
227227 auto iterator = dictionary.find(key);
@@ -236,7 +236,7 @@ namespace GSF · 8 unmodified lines
236236 return false;
237237 }
238238
239− template<typename TKey, typename TValue>
239+ template<class TKey, class TValue>
240240 bool TryGetValue(const std::unordered_map<TKey, TValue>& dictionary, const TKey& key, TValue& value, const TValue& defaultValue)
241241 {
242242 auto iterator = dictionary.find(key);
@@ -251,7 +251,7 @@ namespace GSF · 8 unmodified lines
251251 return false;
252252 }
253253
254− template<typename TValue>
254+ template<class TValue>
255255 bool TryGetValue(const StringMap<TValue>& dictionary, const std::string& key, TValue& value, const TValue& defaultValue)
256256 {
257257 auto iterator = dictionary.find(key);
@@ -308,6 +308,28 @@ namespace GSF · 50 unmodified lines
308308 sink.push_back(static_cast<uint8_t>(*it));
309309 }
310310
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+
311333 Guid NewGuid();
312334
313335 // Handy string functions (boost wrappers)
Source/Libraries/TimeSeriesPlatformLibrary/Common/Convert.h+3−3
@@ -43,7 +43,7 @@ namespace GSF · 42 unmodified lines
4343 DateTime LocalFromUtc(const DateTime& timestamp);
4444
4545 // Converts an object to a string
46− template <class T>
46+ template<class T>
4747 std::string ToString(const T& obj)
4848 {
4949 std::stringstream stream;
@@ -61,11 +61,11 @@ namespace GSF · 11 unmodified lines
6161 std::string ToUTF8(const std::wstring& value);
6262
6363 // Converts an integer value to a hex representation
64− template <class T>
64+ template<class T>
6565 std::string ToHex(const T& value)
6666 {
6767 std::stringstream stream;
68− stream << "0x" << std::hex << static_cast<int>(value);
68+ stream << "0x" << std::hex << static_cast<int32_t>(value);
6969 return stream.str();
7070 }
7171
Source/Libraries/TimeSeriesPlatformLibrary/Common/EndianConverter.h+12−12
@@ -47,7 +47,7 @@ namespace GSF · 46 unmodified lines
4747
4848 // Converts between big endian and
4949 // the system's native byte order.
50− template <class T>
50+ template<class T>
5151 T ConvertBigEndian(T value) const
5252 {
5353 if (m_nativeOrder != EndianConverter::BigEndian)
@@ -58,7 +58,7 @@ namespace GSF · 4 unmodified lines
5858
5959 // Converts between little endian and
6060 // the system's native byte order.
61− template <class T>
61+ template<class T>
6262 T ConvertLittleEndian(T value) const
6363 {
6464 if (m_nativeOrder != EndianConverter::LittleEndian)
@@ -82,39 +82,39 @@ namespace GSF · 17 unmodified lines
8282 static bool IsLittleEndian();
8383 static bool IsBigEndian();
8484
85− template <class T>
85+ template<class T>
8686 static T ToBigEndian(const uint8_t* buffer, const uint32_t startIndex)
8787 {
8888 return Default.ConvertBigEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));
8989 }
9090
91− template <class T>
91+ template<class T>
9292 static T ToLittleEndian(const uint8_t* buffer, const uint32_t startIndex)
9393 {
9494 return Default.ConvertLittleEndian(*reinterpret_cast<T*>(const_cast<uint8_t*>(buffer + startIndex)));
9595 }
9696
97− template <class T>
98− static int32_t WriteBigEndianBytes(std::vector<uint8_t>& buffer, T value)
97+ template<class T>
98+ static uint32_t WriteBigEndianBytes(std::vector<uint8_t>& buffer, T value)
9999 {
100− int32_t length = sizeof(T);
100+ static const uint32_t length = sizeof(T);
101101 value = Default.ConvertBigEndian(value);
102102 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);
103103
104− for (int32_t i = 0; i < length; i++)
104+ for (uint32_t i = 0; i < length; i++)
105105 buffer.push_back(bytes[i]);
106106
107107 return length;
108108 }
109109
110− template <class T>
111− static int32_t WriteLittleEndianBytes(std::vector<uint8_t>& buffer, T value)
110+ template<class T>
111+ static uint32_t WriteLittleEndianBytes(std::vector<uint8_t>& buffer, T value)
112112 {
113− int32_t length = sizeof(T);
113+ static const uint32_t length = sizeof(T);
114114 value = Default.ConvertLittleEndian(value);
115115 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value);
116116
117− for (int32_t i = 0; i < length; i++)
117+ for (uint32_t i = 0; i < length; i++)
118118 buffer.push_back(bytes[i]);
119119
120120 return length;
Source/Libraries/TimeSeriesPlatformLibrary/Common/Nullable.h+90−125
@@ -25,178 +25,143 @@ · 24 unmodified lines
2525 #ifndef __NULLABLE_H
2626 #define __NULLABLE_H
2727
28−#include <cstddef>
2928 #include "Convert.h"
3029
3130 namespace GSF
3231 {
33− class NullableType // NOLINT
34− {
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
32+ template<class T>
33+ class Nullable final // NOLINT
4634 {
4735 public:
4836 Nullable();
49− Nullable(const T &value);
37+ Nullable(const T& value);
5038 Nullable(nullptr_t nullpointer);
51− const Nullable<T> & operator=(const Nullable<T> &value);
52− const Nullable<T> & operator=(const T &value);
53− const Nullable<T> & operator=(nullptr_t nullpointer);
54− bool HasValue() const override;
55− const T & GetValueOrDefault() const;
56− const T & GetValueOrDefault(const T &def) const;
57− bool TryGetValue(T &value) const;
58−
59− public:
60− class NullableValue final
39+ const Nullable<T>& operator=(const Nullable<T>& value); // NOLINT
40+ const Nullable<T>& operator=(const T& value); // NOLINT
41+ const Nullable<T>& operator=(nullptr_t nullpointer); // NOLINT
42+ bool HasValue() const;
43+ const T& GetValueOrDefault() const;
44+ const T& GetValueOrDefault(const T& def) const;
45+ bool TryGetValue(T& value) const;
46+
47+ class NullableValue final // NOLINT
6148 {
62− public:
63− friend class Nullable;
64−
6549 private:
6650 NullableValue();
67− NullableValue(const T &value);
51+ NullableValue(const T& value);
6852
69− public:
70− NullableValue & operator=(const NullableValue &) = delete;
71− operator const T &() const;
72− const T & operator*() const;
73− const T * operator&() const;
53+ void checkHasValue() const;
7454
75− // https://stackoverflow.com/questions/42183631/inability-to-overload-dot-operator-in-c
76− const T * operator->() const;
55+ bool m_hasValue;
56+ T m_value;
7757
7858 public:
79− template <typename T2>
80− friend bool operator==(const Nullable<T2> &op1, const Nullable<T2> &op2);
81−
82− template <typename T2>
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);
59+ NullableValue& operator=(const NullableValue&) = delete;
60+ operator const T&() const;
61+ const T& operator*() const;
62+ const T* operator&() const; // NOLINT
9963
100− template <typename T2>
101− friend bool operator==(nullptr_t nullpointer, const Nullable<T2> &op);
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;
64+ // https://stackoverflow.com/questions/42183631/inability-to-overload-dot-operator-in-c
65+ const T* operator->() const;
11166
112− private:
113− bool m_hasValue;
114− T m_value;
67+ friend class Nullable;
11568 };
11669
117− public:
11870 NullableValue Value;
11971 };
12072
121− template <typename T>
122− Nullable<T>::NullableValue::NullableValue()
123− : m_hasValue(false), m_value(T()) { }
73+ template<class T>
74+ Nullable<T>::NullableValue::NullableValue() : // NOLINT
75+ m_hasValue(false),
76+ m_value(T())
77+ {
78+ }
12479
125− template <typename T>
126− Nullable<T>::NullableValue::NullableValue(const T &value)
127− : m_hasValue(true), m_value(value) { }
80+ template<class T>
81+ Nullable<T>::NullableValue::NullableValue(const T& value):
82+ m_hasValue(true),
83+ m_value(value)
84+ {
85+ }
12886
129− template <typename T>
130− Nullable<T>::NullableValue::operator const T &() const
87+ template<class T>
88+ Nullable<T>::NullableValue::operator const T&() const
13189 {
13290 checkHasValue();
13391 return m_value;
13492 }
13593
136− template <typename T>
137− const T & Nullable<T>::NullableValue::operator*() const
94+ template<class T>
95+ const T& Nullable<T>::NullableValue::operator*() const
13896 {
13997 checkHasValue();
14098 return m_value;
14199 }
142100
143− template <typename T>
144− const T * Nullable<T>::NullableValue::operator&() const
101+ template<class T> // NOLINT
102+ const T* Nullable<T>::NullableValue::operator&() const // NOLINT
145103 {
146104 checkHasValue();
147105 return &m_value;
148106 }
149107
150− template <typename T>
151− const T * Nullable<T>::NullableValue::operator->() const
108+ template<class T>
109+ const T* Nullable<T>::NullableValue::operator->() const
152110 {
153111 checkHasValue();
154112 return &m_value;
155113 }
156114
157− template <typename T>
115+ template<class T>
158116 void Nullable<T>::NullableValue::checkHasValue() const
159117 {
160118 if (!m_hasValue)
161119 throw std::exception("Nullable object must have a value");
162120 }
163121
164− template <typename T>
122+ template<class T>
165123 bool Nullable<T>::HasValue() const { return Value.m_hasValue; }
166124
167− template <typename T>
168− const T & Nullable<T>::GetValueOrDefault() const
125+ template<class T>
126+ const T& Nullable<T>::GetValueOrDefault() const
169127 {
170128 return Value.m_value;
171129 }
172130
173− template <typename T>
174− const T & Nullable<T>::GetValueOrDefault(const T &def) const
131+ template<class T>
132+ const T& Nullable<T>::GetValueOrDefault(const T& def) const
175133 {
176134 if (Value.m_hasValue)
177135 return Value.m_value;
178− else
179− return def;
136+
137+ return def;
180138 }
181139
182− template <typename T>
183− bool Nullable<T>::TryGetValue(T &value) const
140+ template<class T>
141+ bool Nullable<T>::TryGetValue(T& value) const
184142 {
185143 value = Value.m_value;
186144 return Value.m_hasValue;
187145 }
188146
189− template <typename T>
190− Nullable<T>::Nullable() { }
147+ template<class T>
148+ Nullable<T>::Nullable()
149+ {
150+ }
191151
192− template <typename T>
193− Nullable<T>::Nullable(nullptr_t nullpointer) { (void)nullpointer; }
152+ template<class T>
153+ Nullable<T>::Nullable(nullptr_t nullpointer)
154+ {
155+ (void)nullpointer;
156+ }
194157
195− template <typename T>
196− Nullable<T>::Nullable(const T &value)
197− : Value(value) { }
158+ template<class T>
159+ Nullable<T>::Nullable(const T& value)
160+ : Value(value)
161+ {
162+ }
198163
199− template <typename T2>
164+ template<class T2>
200165 bool operator==(const Nullable<T2> &op1, const Nullable<T2> &op2)
201166 {
202167 if (op1.Value.m_hasValue != op2.Value.m_hasValue)
@@ -204,11 +169,11 @@ namespace GSF · 1 unmodified line
204169
205170 if (op1.Value.m_hasValue)
206171 return op1.Value.m_value == op2.Value.m_value;
207− else
208− return true;
172+
173+ return true;
209174 }
210175
211− template <typename T2>
176+ template<class T2>
212177 bool operator==(const Nullable<T2> &op, const T2 &value)
213178 {
214179 if (!op.Value.m_hasValue)
@@ -217,7 +182,7 @@ namespace GSF · 2 unmodified lines
217182 return op.Value.m_value == value;
218183 }
219184
220− template <typename T2>
185+ template<class T2>
221186 bool operator==(const T2 &value, const Nullable<T2> &op)
222187 {
223188 if (!op.Value.m_hasValue)
@@ -226,21 +191,21 @@ namespace GSF · 2 unmodified lines
226191 return op.Value.m_value == value;
227192 }
228193
229− template <typename T2>
194+ template<class T2>
230195 bool operator==(const Nullable<T2> &op, nullptr_t nullpointer)
231196 {
232197 (void)nullpointer;
233198 return !op.Value.m_hasValue;
234199 }
235200
236− template <typename T2>
201+ template<class T2>
237202 bool operator==(nullptr_t nullpointer, const Nullable<T2> &op)
238203 {
239204 (void)nullpointer;
240205 return !op.Value.m_hasValue;
241206 }
242207
243− template <typename T2>
208+ template<class T2>
244209 bool operator!=(const Nullable<T2> &op1, const Nullable<T2> &op2)
245210 {
246211 if (op1.Value.m_hasValue != op2.Value.m_hasValue)
@@ -248,11 +213,11 @@ namespace GSF · 1 unmodified line
248213
249214 if (op1.Value.m_hasValue)
250215 return op1.Value.m_value != op2.Value.m_value;
251− else
252− return false;
216+
217+ return false;
253218 }
254219
255− template <typename T2>
220+ template<class T2>
256221 bool operator!=(const Nullable<T2> &op, const T2 &value)
257222 {
258223 if (!op.Value.m_hasValue)
@@ -261,7 +226,7 @@ namespace GSF · 2 unmodified lines
261226 return op.Value.m_value != value;
262227 }
263228
264− template <typename T2>
229+ template<class T2>
265230 bool operator!=(const T2 &value, const Nullable<T2> &op)
266231 {
267232 if (!op.Value.m_hasValue)
@@ -270,38 +235,38 @@ namespace GSF · 2 unmodified lines
270235 return op.Value.m_value != value;
271236 }
272237
273− template <typename T2>
238+ template<class T2>
274239 bool operator!=(const Nullable<T2> &op, nullptr_t nullpointer)
275240 {
276241 (void)nullpointer;
277242 return op.Value.m_hasValue;
278243 }
279244
280− template <typename T2>
245+ template<class T2>
281246 bool operator!=(nullptr_t nullpointer, const Nullable<T2> &op)
282247 {
283248 (void)nullpointer;
284249 return op.Value.m_hasValue;
285250 }
286251
287− template <typename T>
288− const Nullable<T> & Nullable<T>::operator=(const Nullable<T> &value)
252+ template<class T> // NOLINT
253+ const Nullable<T>& Nullable<T>::operator=(const Nullable<T>& value)
289254 {
290255 Value.m_hasValue = value.Value.m_hasValue;
291256 Value.m_value = value.Value.m_value;
292257 return *this;
293258 }
294259
295− template <typename T>
296− const Nullable<T> & Nullable<T>::operator=(const T &value)
260+ template<class T> // NOLINT
261+ const Nullable<T>& Nullable<T>::operator=(const T& value)
297262 {
298263 Value.m_hasValue = true;
299264 Value.m_value = value;
300265 return *this;
301266 }
302267
303− template <typename T>
304− const Nullable<T> & Nullable<T>::operator=(nullptr_t nullpointer)
268+ template<class T> // NOLINT
269+ const Nullable<T>& Nullable<T>::operator=(nullptr_t nullpointer)
305270 {
306271 (void)nullpointer;
307272 Value.m_hasValue = false;
@@ -309,7 +274,7 @@ namespace GSF · 1 unmodified line
309274 return *this;
310275 }
311276
312− template<typename T, typename U>
277+ template<class T, class U>
313278 Nullable<T> CastAsNullable(const Nullable<U>& source)
314279 {
315280 if (source.HasValue())
@@ -318,7 +283,7 @@ namespace GSF · 2 unmodified lines
318283 return nullptr;
319284 }
320285
321− template<typename T>
286+ template<class T>
322287 std::string ToString(const Nullable<T>& value)
323288 {
324289 if (value.HasValue())
@@ -367,7 +332,7 @@ namespace GSF · 42 unmodified lines
367332 return {};
368333 }
369334
370− template<typename T>
335+ template<class T>
371336 static int32_t CompareValues(Nullable<T> leftNullable, Nullable<T> rightNullable)
372337 {
373338 const bool leftHasValue = leftNullable.HasValue();
Source/Libraries/TimeSeriesPlatformLibrary/Common/ThreadSafeQueue.h+11−12
@@ -24,9 +24,8 @@ · 23 unmodified lines
2424 #ifndef __THREAD_SAFE_QUEUE_H
2525 #define __THREAD_SAFE_QUEUE_H
2626
27−#include <queue>
28−
2927 #include "CommonTypes.h"
28+#include <queue>
3029
3130 namespace GSF
3231 {
@@ -37,8 +36,8 @@ namespace GSF · 4 unmodified lines
3736 // single thread and process in FIFO order.
3837 //
3938 // The use of multiple consumers may cause undesired effects.
40− template <class T>
41− class ThreadSafeQueue
39+ template<class T>
40+ class ThreadSafeQueue // NOLINT
4241 {
4342 private:
4443 Mutex m_mutex;
@@ -89,14 +88,14 @@ namespace GSF · 44 unmodified lines
8988 };
9089
9190 // Releases all threads waiting for data.
92− template <class T>
91+ template<class T>
9392 ThreadSafeQueue<T>::~ThreadSafeQueue()
9493 {
9594 Release();
9695 }
9796
9897 // Inserts an item into the queue.
99− template <class T>
98+ template<class T>
10099 void ThreadSafeQueue<T>::Enqueue(T item)
101100 {
102101 ScopeLock lock(m_mutex);
@@ -106,7 +105,7 @@ namespace GSF · 3 unmodified lines
106105
107106 // Removes an item from the
108107 // queue and returns that item.
109− template <class T>
108+ template<class T>
110109 T ThreadSafeQueue<T>::Dequeue()
111110 {
112111 ScopeLock lock(m_mutex);
@@ -116,7 +115,7 @@ namespace GSF · 3 unmodified lines
116115 }
117116
118117 // Empties the queue.
119− template <class T>
118+ template<class T>
120119 void ThreadSafeQueue<T>::Clear()
121120 {
122121 ScopeLock lock(m_mutex);
@@ -127,7 +126,7 @@ namespace GSF · 4 unmodified lines
127126
128127 // Returns the number of
129128 // items left in the queue.
130− template <class T>
129+ template<class T>
131130 uint32_t ThreadSafeQueue<T>::Size()
132131 {
133132 ScopeLock lock(m_mutex);
@@ -137,7 +136,7 @@ namespace GSF · 3 unmodified lines
137136 // Waits for data to be inserted into the queue.
138137 // If there is already data in the queue,
139138 // this method will not wait.
140− template <class T>
139+ template<class T>
141140 void ThreadSafeQueue<T>::WaitForData()
142141 {
143142 UniqueLock lock(m_mutex);
@@ -147,7 +146,7 @@ namespace GSF · 3 unmodified lines
147146 }
148147
149148 // Releases all threads waiting for data.
150− template <class T>
149+ template<class T>
151150 void ThreadSafeQueue<T>::Release()
152151 {
153152 ScopeLock lock(m_mutex);
@@ -159,7 +158,7 @@ namespace GSF · 5 unmodified lines
159158 // Resets the "release valve" for threads calling WaitForData.
160159 // This can be called after Release so that the queue can be
161160 // used again.
162− template <class T>
161+ template<class T>
163162 void ThreadSafeQueue<T>::Reset()
164163 {
165164 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
28432843 return NewSharedPtr<ValueExpression>(ExpressionValueType::Boolean, left || right);
28442844 }
28452845
2846−template<typename T>
2846+template<class T>
28472847 T ExpressionTree::Unary(const T& unaryValue, ExpressionUnaryType unaryOperation)
28482848 {
28492849 switch (unaryOperation)
@@ -2859,7 +2859,7 @@ T ExpressionTree::Unary(const T& unaryValue, ExpressionUnaryType unaryOperation) · 9 unmodified lines
28592859 }
28602860 }
28612861
2862−template<typename T>
2862+template<class T>
28632863 T ExpressionTree::UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType)
28642864 {
28652865 switch (unaryOperation)
Source/Libraries/TimeSeriesPlatformLibrary/FilterExpressions/ExpressionTree.h+2−2
@@ -366,10 +366,10 @@ private: · 365 unmodified lines
366366 ValueExpressionPtr And(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;
367367 ValueExpressionPtr Or(const ValueExpressionPtr& leftValue, const ValueExpressionPtr& rightValue) const;
368368
369− template<typename T>
369+ template<class T>
370370 static T Unary(const T& unaryValue, ExpressionUnaryType unaryOperation);
371371
372− template<typename T>
372+ template<class T>
373373 static T UnaryFloat(const T& unaryValue, ExpressionUnaryType unaryOperation, ExpressionValueType unaryValueType);
374374
375375 static bool UnaryBool(bool unaryValue, ExpressionUnaryType unaryOperation);
Source/Libraries/TimeSeriesPlatformLibrary/Samples/SimplePublish.cpp+5−3
@@ -21,13 +21,12 @@ · 20 unmodified lines
2121 //
2222 //******************************************************************************************************
2323
24−#include <iostream>
25−#include <string>
26−
2724 #include "../Transport/DataPublisher.h"
25+#include <iostream>
2826
2927 using namespace std;
3028 using namespace GSF;
29+using namespace GSF::Data;
3130 using namespace GSF::TimeSeries;
3231 using namespace GSF::TimeSeries::Transport;
3332
@@ -115,6 +114,9 @@ bool RunPublisher(uint16_t port) · 81 unmodified lines
115114 Publisher->RegisterClientDisconnectedCallback(&DisplayClientDisconnected);
116115 Publisher->RegisterStatusMessageCallback(&DisplayStatusMessage);
117116 Publisher->RegisterErrorMessageCallback(&DisplayErrorMessage);
117+
118+ // Define metadata
119+ Publisher->DefineMetadata(DataSet::FromXml("Metadata.xml"));
118120 }
119121 else
120122 {
Source/Libraries/TimeSeriesPlatformLibrary/Transport/ActiveMeasurementsSchema.cpp+2−2
@@ -1,4 +1,4 @@
1−// Auto-generated on Thu Feb 7 16:57:40 2019
1+// Auto-generated on Fri Feb 8 13:02:59 2019
22 // EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::
33
44 #include "ActiveMeasurementsSchema.h"
@@ -206,7 +206,7 @@ const uint8_t GSF::TimeSeries::Transport::ActiveMeasurementsSchema[] = { · 201 unmodified lines
206206 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x65,
207207 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E, 0x3C, 0x2F, 0x78,
208208 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D, 0x61, 0x3E, 0x3C,
209− 0x2F, 0x49, 0x61, 0x6F, 0x6E, 0x3E, 0x00
209+ 0x2F, 0x49, 0x61, 0x6F, 0x6E, 0x3E
210210 };
211211
212212 const 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 2019
1+// Auto-generated on Fri Feb 8 13:02:59 2019
22 // EmbedFile.exe ActiveMeasurementsSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\ActiveMeasurementsSchema.xml GSF::TimeSeries::Transport::
33
44 #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
646646
647647 vector<uint8_t> DataPublisher::SerializeSignalIndexCache(const SubscriberConnectionPtr& connection, const SignalIndexCachePtr& signalIndexCache) const
648648 {
649− if (connection == nullptr)
650− return vector<uint8_t>{};
649+ vector<uint8_t> serializationBuffer;
651650
652− const uint32_t operationalModes = connection->GetOperationalModes();
653− const uint32_t compressionModes = operationalModes & OperationalModes::CompressionModeMask;
654− const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;
655− const bool compressSignalIndexCache = (operationalModes & OperationalModes::CompressSignalIndexCache) > 0;
651+ if (connection != nullptr)
652+ {
653+ const uint32_t operationalModes = connection->GetOperationalModes();
654+ const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;
655+ const bool compressSignalIndexCache = (operationalModes & OperationalModes::CompressSignalIndexCache) > 0;
656+ const bool useGZipCompression = (operationalModes & CompressionModes::GZip) > 0;
656657
657− if (!useCommonSerializationFormat)
658− throw PublisherException("DataPublisher only supports common serialization format");
658+ if (!useCommonSerializationFormat)
659+ throw PublisherException("DataPublisher only supports common serialization format");
659660
660− vector<uint8_t> serializedCache(uint32_t(signalIndexCache->GetBinaryLength() * 0.02));
661− signalIndexCache->Serialize(connection, serializedCache);
661+ serializationBuffer.reserve(uint32_t(signalIndexCache->GetBinaryLength() * 0.02));
662+ signalIndexCache->Serialize(connection, serializationBuffer);
662663
663− if (compressSignalIndexCache && (compressionModes & CompressionModes::GZip) > 0)
664− {
665− const MemoryStream metadataStream(serializedCache);
666− StreamBuffer streamBuffer;
664+ if (compressSignalIndexCache && useGZipCompression)
665+ {
666+ const MemoryStream memoryStream(serializationBuffer);
667+ StreamBuffer streamBuffer;
667668
668− streamBuffer.push(GZipCompressor());
669− streamBuffer.push(metadataStream);
669+ streamBuffer.push(GZipCompressor());
670+ streamBuffer.push(memoryStream);
670671
671− vector<uint8_t> compressed;
672− CopyStream(&streamBuffer, compressed);
673− return compressed;
672+ vector<uint8_t> compressedBuffer;
673+ CopyStream(&streamBuffer, compressedBuffer);
674+ return compressedBuffer;
675+ }
674676 }
675677
676− return serializedCache;
678+ return serializationBuffer;
677679 }
678680
679681 vector<uint8_t> DataPublisher::SerializeMetadata(const SubscriberConnectionPtr& connection, const DataSetPtr& metadata) const
680682 {
681− vector<uint8_t> serializedMetadata;
683+ vector<uint8_t> serializationBuffer;
682684
683685 if (connection != nullptr)
684686 {
685687 const uint32_t operationalModes = connection->GetOperationalModes();
686− const uint32_t compressionModes = operationalModes & OperationalModes::CompressionModeMask;
687688 const bool useCommonSerializationFormat = (operationalModes & OperationalModes::UseCommonSerializationFormat) > 0;
688689 const bool compressMetadata = (operationalModes & OperationalModes::CompressMetadata) > 0;
690+ const bool useGZipCompression = (operationalModes & CompressionModes::GZip) > 0;
689691
690692 if (!useCommonSerializationFormat)
691693 throw PublisherException("DataPublisher only supports common serialization format");
692694
693− metadata->WriteXml(serializedMetadata);
695+ metadata->WriteXml(serializationBuffer);
694696
695− if (compressMetadata && (compressionModes & CompressionModes::GZip) > 0)
697+ if (compressMetadata && useGZipCompression)
696698 {
697− const MemoryStream metadataStream(serializedMetadata);
699+ const MemoryStream memoryStream(serializationBuffer);
698700 StreamBuffer streamBuffer;
699701
700702 streamBuffer.push(GZipCompressor());
701− streamBuffer.push(metadataStream);
703+ streamBuffer.push(memoryStream);
702704
703− vector<uint8_t> compressed;
704− CopyStream(&streamBuffer, compressed);
705+ vector<uint8_t> compressionBuffer;
706+ CopyStream(&streamBuffer, compressionBuffer);
705707
706− return compressed;
708+ return compressionBuffer;
707709 }
708710 }
709711
710− return serializedMetadata;
712+ return serializationBuffer;
711713 }
712714
713715 bool 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
745747 if (data.empty())
746748 {
747749 // Add zero sized data buffer to response packet
748− buffer.push_back(0);
749− buffer.push_back(0);
750− buffer.push_back(0);
751− buffer.push_back(0);
750+ WriteBytes(buffer, uint32_t(0));
752751 }
753752 else
754753 {
@@ -1081,7 +1080,7 @@ void DataPublisher::DefineMetadata(const DataSetPtr& metadata) · 326 unmodified lines
10811080 phasorData[deviceName] = phasorMap;
10821081 }
10831082
1084− phasorMap->at(row->ValueAsInt32(sourceIndex).GetValueOrDefault()) = phasor;
1083+ phasorMap->insert_or_assign(row->ValueAsInt32(sourceIndex).GetValueOrDefault(), phasor);
10851084 }
10861085 }
10871086
@@ -1147,8 +1146,8 @@ void DataPublisher::DefineMetadata(const DataSetPtr& metadata) · 59 unmodified lines
11471146 am_row->SetGuidValue(am_signalID, md_row->ValueAsGuid(md_signalID));
11481147 am_row->SetStringValue(am_pointTag, md_row->ValueAsString(md_pointTag));
11491148 am_row->SetStringValue(am_signalReference, md_row->ValueAsString(md_signalReference));
1150− am_row->SetInt32Value(am_internal, md_row->ValueAsInt32(md_internal));
1151− am_row->SetBooleanValue(am_subscribed, false);
1149+ am_row->SetInt32Value(am_internal, md_row->ValueAsBoolean(md_internal).GetValueOrDefault() ? 1 : 0);
1150+ am_row->SetInt32Value(am_subscribed, 0);
11521151 am_row->SetStringValue(am_description, md_row->ValueAsString(md_description));
11531152 am_row->SetDoubleValue(am_adder, 0.0);
11541153 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
224224 // --- DataSubscriber ---
225225
226226 DataSubscriber::DataSubscriber() :
227+ m_subscriberID(Empty::Guid),
227228 m_compressPayloadData(true),
228229 m_compressMetadata(true),
229230 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 2019
1+// Auto-generated on Fri Feb 8 13:02:18 2019
22 // EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::
33
44 #include "MetadataSchema.h"
@@ -331,7 +331,7 @@ const uint8_t GSF::TimeSeries::Transport::MetadataSchema[] = { · 326 unmodified lines
331331 0x65, 0x78, 0x54, 0x79, 0x70, 0x65, 0x3E, 0x3C, 0x2F, 0x78,
332332 0x73, 0x3A, 0x65, 0x6C, 0x65, 0x6D, 0x65, 0x6E, 0x74, 0x3E,
333333 0x3C, 0x2F, 0x78, 0x73, 0x3A, 0x73, 0x63, 0x68, 0x65, 0x6D,
334− 0x61, 0x3E, 0x00
334+ 0x61, 0x3E
335335 };
336336
337337 const 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 2019
1+// Auto-generated on Fri Feb 8 13:02:18 2019
22 // EmbedFile.exe MetadataSchema D:\Projects\gsf\Source\Libraries\TimeSeriesPlatformLibrary\Transport\MetadataSchema.xml GSF::TimeSeries::Transport::
33
44 #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
178178 const uint32_t referenceCount = EndianConverter::Default.ConvertBigEndian(*referenceCountPtr);
179179
180180 // 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);
182182
183183 for (uint32_t i = 0; i < referenceCount; ++i)
184184 {
@@ -222,19 +222,12 @@ void SignalIndexCache::Serialize(const SubscriberConnectionPtr& connection, vect · 37 unmodified lines
222222 uint32_t binaryLength = 28;
223223
224224 // Reserve space for binary byte length of cache
225− buffer.push_back(0);
226− buffer.push_back(0);
227− buffer.push_back(0);
228− buffer.push_back(0);
225+ WriteBytes(buffer, uint32_t(0));
229226
230227 // Encode subscriber ID
231228 Guid subscriberID = connection->GetSubscriberID();
232−
233229 SwapGuidEndianness(subscriberID, true);
234− uint8_t* bytes = subscriberID.data;
235−
236− for (int32_t i = 0; i < 16; i++)
237− buffer.push_back(bytes[i]);
230+ WriteBytes(buffer, subscriberID);
238231
239232 // Encode number of references
240233 EndianConverter::WriteBigEndianBytes(buffer, int32_t(m_reference.size()));
@@ -248,10 +241,7 @@ void SignalIndexCache::Serialize(const SubscriberConnectionPtr& connection, vect · 7 unmodified lines
248241
249242 // Encode signal ID
250243 SwapGuidEndianness(signalID, true);
251− bytes = signalID.data;
252−
253− for (int32_t j = 0; j < 16; j++)
254− buffer.push_back(bytes[j]);
244+ WriteBytes(buffer, signalID);
255245
256246 // Encode source
257247 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
3636 typedef GSF::SharedPtr<DataPublisher> DataPublisherPtr;
3737
3838 // Represents a subscriber connection to a data publisher
39− class SubscriberConnection : public GSF::EnableSharedThisPtr<SubscriberConnection> //NOLINT
39+ class SubscriberConnection : public GSF::EnableSharedThisPtr<SubscriberConnection> // NOLINT
4040 {
4141 private:
4242 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
577577 return;
578578 }
579579
580− vector<uint8_t>* uncompressed;
580+ vector<uint8_t>* uncompressesBuffer;
581581
582582 // Step 1: Decompress meta-data if needed
583583 if (IsMetadataCompressed())
584584 {
585585 // Perform zlib decompression on buffer
586− const MemoryStream payloadStream(payload);
586+ const MemoryStream memoryStream(payload);
587587 StreamBuffer streamBuffer;
588588
589589 streamBuffer.push(GZipDecompressor());
590− streamBuffer.push(payloadStream);
590+ streamBuffer.push(memoryStream);
591591
592− uncompressed = new vector<uint8_t>();
593− CopyStream(&streamBuffer, *uncompressed);
592+ uncompressesBuffer = new vector<uint8_t>();
593+ CopyStream(&streamBuffer, *uncompressesBuffer);
594594 }
595595 else
596596 {
597− uncompressed = const_cast<vector<uint8_t>*>(&payload);
597+ uncompressesBuffer = const_cast<vector<uint8_t>*>(&payload);
598598 }
599599
600600 // Step 2: Load string into an XML parser
601601 xml_document document;
602602
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());
604604
605605 if (result.status != xml_parse_status::status_ok)
606606 {
607607 if (IsMetadataCompressed())
608− delete uncompressed;
608+ delete uncompressesBuffer;
609609
610610 stringstream errorMessageStream;
611611 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
758758
759759 // Release uncompressed buffer
760760 if (IsMetadataCompressed())
761− delete uncompressed;
761+ delete uncompressesBuffer;
762762
763763 // Notify derived class that meta-data has been parsed and is now available
764764 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