History

TimeSeriesPlatformLibrary: Added static assestions that will fail at compile time if float is not 32-bits and double is not 64-bits since compression depends on this.

J. Ritchie Carroll committed 7 years ago

Commit 0fb09bd1 parent 385845d2 files · +21 −17Browse files

Unified · Split

2 files
  1. Source/Libraries/TimeSeriesPlatformLibrary/Common/CommonTypes.h +6 −2
  2. Source/Libraries/TimeSeriesPlatformLibrary/Samples/PublisherHandler.cpp +15 −15
Source/Libraries/TimeSeriesPlatformLibrary/Common/CommonTypes.h+6−2
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 #ifndef __COMMON_TYPES_H
2525 #define __COMMON_TYPES_H
2626
27+#include <climits>
2728 #include <cstddef>
2829 #include <cstring>
2930 #include <map>
@@ -44,9 +45,12 @@ · 14 unmodified lines
4445
4546 namespace GSF
4647 {
48+ static_assert(sizeof(float) * CHAR_BIT == 32, "float not defined as 32-bits");
49+ static_assert(sizeof(double) * CHAR_BIT == 64, "double not defined as 64-bits");
50+
4751 // Floating-point types
48− typedef float_t float32_t;
49− typedef double_t float64_t;
52+ typedef float float32_t;
53+ typedef double float64_t;
5054 typedef boost::multiprecision::cpp_dec_float_100 decimal_t;
5155
5256 // DateTime type
Source/Libraries/TimeSeriesPlatformLibrary/Samples/PublisherHandler.cpp+15−15
@@ -208,21 +208,21 @@ void PublisherHandler::Start() · 207 unmodified lines
208208
209209 switch (metadata->Reference.Kind)
210210 {
211− case Frequency:
212− value = 60.0 + sign * randFraction * 0.1;
213− break;
214− case DfDt:
215− value = sign * randFraction * 2;
216− break;
217− case Magnitude:
218− value = 500 + sign * randFraction * 50;
219− break;
220− case Angle:
221− value = sign * randFraction * 180;
222− break;
223− default:
224− value = sign * randFraction * UInt32::MaxValue;
225− break;
211+ case Frequency:
212+ value = 60.0 + sign * randFraction * 0.1;
213+ break;
214+ case DfDt:
215+ value = sign * randFraction * 2;
216+ break;
217+ case Magnitude:
218+ value = 500 + sign * randFraction * 50;
219+ break;
220+ case Angle:
221+ value = sign * randFraction * 180;
222+ break;
223+ default:
224+ value = sign * randFraction * UInt32::MaxValue;
225+ break;
226226 }
227227
228228 measurement->Value = value;

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