CommonDefs.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "pulse_export.h"
6#define CDM_DECL PULSE_EXPORT
7
8#if (0)
9#define DEBUGOUT(x) x
10#else
11#define DEBUGOUT(x)
12#endif
13
14
15#define PULSE_CDM pulse::cdm
16#define CDM_BIND pulse::cdm::bind
17
18#define CDM_BIND_DECL(type) \
19 namespace pulse { namespace cdm { namespace bind { class type; }}}
20#define CDM_BIND_DECL2(type) \
21 class SE##type;\
22 namespace pulse { namespace cdm { namespace bind { class type##Data; }}}
23
24#if defined(_MSC_VER)
25 // Modify the following defines if you have to target a platform prior to the ones specified below.
26 // Refer to MSDN for the latest info on corresponding values for different platforms.
27 #ifndef WINVER // Allow use of features specific to Windows XP or later.
28 #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
29 #endif
30
31 #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
32 #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
33 #endif
34
35 #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
36 #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
37 #endif
38
39 #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
40 #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
41 #endif
42
43 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
44#endif
45
46// See https ://www.fluentcpp.com/2019/08/30/how-to-disable-a-warning-in-cpp/
47// When adding new warnings remember to add the DISABLE_ macro
48// for all three sections MSVC, GCC/CLANG, other
49#if defined(_MSC_VER)
50
51 __pragma(warning(disable : 4251)) // Ignore needs dll-interface warnings
52 //#pragma warning(disable:4100) // unreferenced formal parameter (intentional in base classes)
53
54 #define DISABLE_WARNING_PUSH __pragma(warning( push ))
55 #define DISABLE_WARNING_POP __pragma(warning( pop ))
56 #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
57
58 #define PUSH_PROTO_WARNINGS \
59 DISABLE_WARNING_PUSH \
60 DISABLE_WARNING(4127) \
61 DISABLE_WARNING(4267) \
62 DISABLE_WARNING(4244)
63 #define POP_PROTO_WARNINGS DISABLE_WARNING_POP
64
65 #define PUSH_EIGEN_WARNINGS \
66 DISABLE_WARNING_PUSH \
67 DISABLE_WARNING(4127) \
68 DISABLE_WARNING(4267) \
69 DISABLE_WARNING(4244)
70 #define POP_EIGEN_WARNINGS DISABLE_WARNING_POP
71
72#elif defined(__GNUC__) || defined(__clang__)
73 #define DO_PRAGMA(X) _Pragma(#X)
74 #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push)
75 #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop)
76 #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName)
77
78 #define PUSH_PROTO_WARNINGS \
79 DISABLE_WARNING_PUSH
80 #define POP_PROTO_WARNINGS DISABLE_WARNING_POP
81
82 #define PUSH_EIGEN_WARNINGS \
83 DISABLE_WARNING_PUSH
84 #define POP_EIGEN_WARNINGS DISABLE_WARNING_POP
85
86#else
87 #define DISABLE_WARNING_PUSH
88 #define DISABLE_WARNING_POP
89 #define DISABLE_WARNING
90
91 #define PUSH_PROTO_WARNINGS
92 #define POP_PROTO_WARNINGS
93
94 #define PUSH_EIGEN_WARNINGS
95 #define POP_EIGEN_WARNINGS
96#endif
97
98
99#define _USE_MATH_DEFINES
100#include <memory>
101#include <stdio.h>
102#include <iostream>
103#include <fstream>
104#include <stdexcept>
105#include <algorithm>
106#include <cmath>
107#include <climits>
108#include <string>
109#include <math.h>
110#include <vector>
111#include <stack>
112#include <map>
113#include <set>
114
115#ifdef _MSC_VER
116#include <direct.h>
117#include <unordered_map>
118using namespace stdext;
119#else//if (__GCC__) || (__GNUC__)
120#include <unordered_map>
121#endif
122
123//Utilities
124enum class eSerializationFormat { JSON = 0, BINARY, VERBOSE_JSON,TEXT };
125
126struct CommonDataModelException : public std::runtime_error
127{
129 : std::runtime_error( "Common Data Model Error" ) {}
130
131 CommonDataModelException(const std::string& _Message)
132 : std::runtime_error(_Message) {}
133};
134// Basics
135#include "cdm/Macros.h"
136#include "cdm/utils/Logger.h"
137
138
139// General Enums
140// Keep enums in sync with appropriate schema/cdm/Enums.proto file !!
141//
142enum class eSide { NullSide = 0, Left, Right };
143extern CDM_DECL const std::string& eSide_Name(eSide m);
144
145enum class eGate { NullGate = 0, Open, Closed };
146extern CDM_DECL const std::string& eGate_Name(eGate m);
147
148enum class eSwitch { NullSwitch = 0, Off, On };
149extern CDM_DECL const std::string& eSwitch_Name(eSwitch m);
150
151enum class eCharge { NullCharge = 0, Negative, Neutral, Positive };
152extern CDM_DECL const std::string& eCharge_Name(eCharge m);
153
154enum class eBreathState { NoBreath=0,
155 PatientInhale, PatientPause, PatientExhale,
156 EquipmentInhale, EquipmentPause, EquipmentExhale,
157 ExpiratoryHold, InspiratoryHold };
158extern CDM_DECL const std::string& eBreathState_Name(eBreathState m);
159
160enum class eDefaultType { Model = 0, Zero };
161extern CDM_DECL const std::string& eDefaultType_Name(eDefaultType m);
162
163enum class eDriverWaveform { NullDriverWaveform = 0, Square,
164 AscendingRamp, DescendingRamp,
165 ExponentialGrowth, ExponentialDecay,
166 SinusoidalRise, SinusoidalFall,
167 SigmoidalRise, SigmoidalFall };
168extern CDM_DECL const std::string& eDriverWaveform_Name(eDriverWaveform m);
169
170//
171// End General Enum
172
173// IF YOU ADD A NEW SCALAR TYPE
174// PLEASE UPDATE THE METHOD IN SEProperty.cpp
175// ALSO DECLARE A TEMPLATE CLASS AT THE BOTTOM OF SESCALAR.CPP
176
177class CCompoundUnit;
178
179// Used for overrides and modifiers, a super generic way of enumerating a list of properties
180// properties are an actual scalar member variable on an object
181// map<variable_name,SEScalarPair(value,unit)>
182class CDM_DECL SEScalarPair
183{
184public:
185 SEScalarPair();
186 SEScalarPair(double v);
187 SEScalarPair(double v, const std::string& u);
188 SEScalarPair(double v, const CCompoundUnit& cc);
189 ~SEScalarPair() = default;
190 double value;
191 std::string unit;
192};
193using SEScalarProperties = std::map<std::string, SEScalarPair>;
194
195
196class SECurve;
197class SERunningAverage;
198class SEScalar; class SEUnitScalar; class SEGenericScalar; class NoUnit;
199class SEScalar0To1;
201class SEScalarUnsigned;
202class SEScalarAmount; class AmountUnit;
206class SEScalarArea; class AreaUnit;
214class SEScalarEnergy; class EnergyUnit;
218class SEScalarForce; class ForceUnit;
219class SEScalar0To1;
231class SEScalarLength; class LengthUnit;
234class SEScalarMass; class MassUnit;
242class SEScalarPower; class PowerUnit;
244class SEScalarPressure; class PressureUnit;
250class SEScalarTime; class TimeUnit;
252class SEScalarVolume; class VolumeUnit;
260
261class SEArray;
263
264class SEFunction;
267
268class SEHistogram;
270
271class SESegment;
273class SESegmentLinear;
Definition: SEScalarAmountPerMass.h:8
Definition: SEScalarAmountPerTime.h:8
Definition: SEScalarAmountPerVolume.h:8
Definition: SEScalarAmount.h:8
Definition: SEScalarAreaPerTimePressure.h:8
Definition: SEScalarArea.h:8
Definition: CompoundUnit.h:40
Definition: SEScalarElectricCapacitance.h:8
Definition: SEScalarElectricCharge.h:8
Definition: SEScalarElectricCurrent.h:8
Definition: SEScalarElectricInductance.h:8
Definition: SEScalarElectricPotential.h:8
Definition: SEScalarElectricResistance.h:8
Definition: SEScalarEnergyPerAmount.h:8
Definition: SEScalarEnergyPerMass.h:8
Definition: SEScalarEnergy.h:8
Definition: SEScalarEquivalentWeightPerVolume.h:8
Definition: SEScalarForce.h:8
Definition: SEScalarFrequency.h:8
Definition: SEScalarHeatCapacitancePerAmount.h:8
Definition: SEScalarHeatCapacitancePerMass.h:8
Definition: SEScalarHeatCapacitance.h:8
Definition: SEScalarHeatConductancePerArea.h:8
Definition: SEScalarHeatConductance.h:8
Definition: SEScalarHeatInductance.h:8
Definition: SEScalarHeatResistanceArea.h:8
Definition: SEScalarHeatResistance.h:8
Definition: SEScalarInversePressure.h:8
Definition: SEScalarInverseVolume.h:8
Definition: SEScalarLengthPerTimePressure.h:8
Definition: SEScalarLengthPerTime.h:8
Definition: SEScalarLength.h:8
Definition: SEScalarMassPerAmount.h:8
Definition: SEScalarMassPerAreaTime.h:8
Definition: SEScalarMassPerMass.h:8
Definition: SEScalarMassPerTime.h:8
Definition: SEScalarMassPerVolume.h:8
Definition: SEScalarMass.h:8
Definition: SEScalar.h:10
Definition: SEScalarOsmolality.h:8
Definition: SEScalarOsmolarity.h:8
Definition: SEScalarPowerPerAreaTemperatureToTheFourth.h:8
Definition: SEScalarPower.h:8
Definition: SEScalarPressurePerVolume.h:8
Definition: SEScalarPressureTimePerArea.h:8
Definition: SEScalarPressureTimePerVolumeArea.h:8
Definition: SEScalarPressureTimePerVolume.h:8
Definition: SEScalarPressureTimeSquaredPerVolume.h:8
Definition: SEScalarPressure.h:8
Definition: SEArrayElectricPotential.h:8
Definition: SEArray.h:8
Definition: SECurve.h:12
Definition: SEFunctionElectricPotentialVsTime.h:8
Definition: SEFunction.h:8
Definition: SEFunctionVolumeVsTime.h:8
If you want to querry what a scalar is and don't know what scalar type you have...
Definition: SEScalar.h:282
Definition: SEHistogramFractionVsLength.h:8
Definition: SEHistogram.h:8
Definition: SERunningAverage.h:8
Definition: SEScalar0To1.h:8
Definition: SEScalarAmount.h:25
Definition: SEScalarAmountPerMass.h:25
Definition: SEScalarAmountPerTime.h:29
Definition: SEScalarAmountPerVolume.h:31
Definition: SEScalarArea.h:25
Definition: SEScalarAreaPerTimePressure.h:27
Definition: SEScalarElectricCapacitance.h:24
Definition: SEScalarElectricCharge.h:24
Definition: SEScalarElectricCurrent.h:24
Definition: SEScalarElectricInductance.h:24
Definition: SEScalarElectricPotential.h:25
Definition: SEScalarElectricResistance.h:24
Definition: SEScalarEnergy.h:27
Definition: SEScalarEnergyPerAmount.h:25
Definition: SEScalarEnergyPerMass.h:27
Definition: SEScalarEquivalentWeightPerVolume.h:27
Definition: SEScalarForce.h:26
Definition: SEScalarFrequency.h:26
Definition: SEScalarHeatCapacitance.h:27
Definition: SEScalarHeatCapacitancePerAmount.h:24
Definition: SEScalarHeatCapacitancePerMass.h:27
Definition: SEScalarHeatConductance.h:27
Definition: SEScalarHeatConductancePerArea.h:26
Definition: SEScalarHeatInductance.h:24
Definition: SEScalarHeatResistanceArea.h:27
Definition: SEScalarHeatResistance.h:27
Definition: SEScalar.h:19
Definition: SEScalarInversePressure.h:27
Definition: SEScalarInverseVolume.h:25
Definition: SEScalarLength.h:29
Definition: SEScalarLengthPerTime.h:30
Definition: SEScalarLengthPerTimePressure.h:27
Definition: SEScalarMass.h:28
Definition: SEScalarMassPerAmount.h:34
Definition: SEScalarMassPerAreaTime.h:24
Definition: SEScalarMassPerMass.h:25
Definition: SEScalarMassPerTime.h:31
Definition: SEScalarMassPerVolume.h:37
Definition: SEScalarNegative1To1.h:8
Definition: SEScalarOsmolality.h:25
Definition: SEScalarOsmolarity.h:25
Definition: CommonDefs.h:183
double value
Definition: CommonDefs.h:190
std::string unit
Definition: CommonDefs.h:191
~SEScalarPair()=default
Definition: SEScalarPower.h:29
Definition: SEScalarPowerPerAreaTemperatureToTheFourth.h:24
Definition: SEScalarPressure.h:29
Definition: SEScalarPressurePerVolume.h:26
Definition: SEScalarPressureTimePerArea.h:25
Definition: SEScalarPressureTimePerVolumeArea.h:26
Definition: SEScalarPressureTimePerVolume.h:29
Definition: SEScalarPressureTimeSquaredPerVolume.h:28
Definition: SEScalarTemperature.h:27
Definition: SEScalarTime.h:28
Definition: SEScalarUnsigned.h:8
Definition: SEScalarVolume.h:28
Definition: SEScalarVolumePerPressure.h:28
Definition: SEScalarVolumePerTimeArea.h:26
Definition: SEScalarVolumePerTime.h:32
Definition: SEScalarVolumePerTimeMass.h:28
Definition: SEScalarVolumePerTimePressureArea.h:25
Definition: SEScalarVolumePerTimePressure.h:27
Definition: SESegmentConstant.h:9
Definition: SESegment.h:7
Definition: SESegmentLinear.h:9
Definition: SESegmentParabolic.h:9
Definition: SESegmentSigmoidal.h:9
Definition: SETemporalInterpolator.h:8
An interface to be used for gaining access to a scalar with any unit type
Definition: SEScalar.h:178
Definition: SEScalarTemperature.h:8
Definition: SEScalarTime.h:8
Definition: SEScalarVolumePerPressure.h:8
Definition: SEScalarVolumePerTimeArea.h:8
Definition: SEScalarVolumePerTimeMass.h:8
Definition: SEScalarVolumePerTimePressureArea.h:8
Definition: SEScalarVolumePerTimePressure.h:8
Definition: SEScalarVolumePerTime.h:8
Definition: SEScalarVolume.h:8
STL namespace.
Definition: CommonDefs.h:127
CommonDataModelException()
Definition: CommonDefs.h:128
CommonDataModelException(const std::string &_Message)
Definition: CommonDefs.h:131

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.