CommonDataModel.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 
6 #ifdef SHARED_CDM
7  #if defined (__clang__)
8  #define CDM_DECL
9  #elif defined(__gnu_linux__)
10  #define CDM_DECL __attribute__ ((visibility ("default")))
11  #else
12  #ifdef SHARED_CDM
13  #define CDM_DECL __declspec(dllexport)
14  #else
15  #define CDM_DECL __declspec(dllimport)
16  #endif
17  #endif
18 #else
19  #define CDM_DECL
20 #endif
21 
22 #if (0)
23 #define DEBUGOUT(x) x
24 #else
25 #define DEBUGOUT(x)
26 #endif
27 
28 #define CDM_BIND_DECL(type) namespace cdm { class type; }
29 #define CDM_BIND_DECL2(type) \
30  class SE##type;\
31  namespace cdm { class type##Data; }
32 
33 #include <memory>
34 #include <stdio.h>
35 #include <iostream>
36 #include <fstream>
37 #include <stdexcept>
38 #include <algorithm>
39 
40 #ifdef _MSC_VER
41 #include <direct.h>
42 #else
43 #include <dirent.h>
44 #endif
45 
46 #include <math.h>
47 #include <vector>
48 #include <stack>
49 #include <map>
50 
51 #if defined(_MSC_VER)
52  #include <unordered_map>
53  using namespace stdext;
54 #else//if (__GCC__) || (__GNUC__)
55  #include <unordered_map>
56 #endif
57 
58  /*
59 // Take from : https://github.com/CppCodeReviewers/Covariant-Return-Types-and-Smart-Pointers/blob/master/README.md
60 namespace xsd
61 {
62  template<typename T>
63  struct Serializable
64  {
65  using base_type = T;
66 
67  virtual ~Serializable() = default;
68 
69  virtual bool Load(const T& in) = 0;
70  protected:
71  virtual T* Unload() const
72  {
73  using base_type = typename T::base_type;
74  static_assert(std::is_base_of<base_type, T>::value, "T object has to derived from T::base_type");
75  auto ptr = static_cast<const base_type&>(object).NewBindType();
76  ptr->Unload(static_cast<T*>(ptr));
77  return std::unique_ptr<T>(static_cast<T*>(ptr));
78  }
79  virtual T* NewBindType() const = 0;
80  virtual void Unload(T& object) const = 0;
81  };
82 }
83 */
84 
85 /*
86 template class __declspec(dllexport) std::basic_string<char,
87  std::char_traits<char>,
88  std::allocator<char> >;
89 
90 template class __declspec(dllexport) std::basic_stringstream<char,
91  std::char_traits<char>,
92  std::allocator<char> >;
93 
94 template class __declspec(dllexport) std::vector<std::string>;
95 */
96 
97 // Disabling the waring about STL classes used have
98 // to have a dll interface to be used by clients
99 // From what I have read STL is compiler dependent
100 // But since we are releasing source, you can build
101 // the project necessary to ensure proper linkage
102 // If anyone else has opinions on this, let us know
103 // kitware@kitware.com
104 #pragma warning(disable : 4251)
105 //Utilities
106 
107 struct CommonDataModelException : public std::runtime_error
108 {
110  : std::runtime_error( "Common Data Model Error" ) {}
111 
112  CommonDataModelException(const std::string& _Message)
113  : std::runtime_error(_Message) {}
114 };
115 // Basics
116 #include "Macros.h"
117 #include "utils/Logger.h"
118 
119 enum SerializationFormat { BINARY = 0, JSON };
120 
121 // General Enums
122 // Keep enums in sync with appropriate schema/cdm/Enums.proto file !!
123 //
124 enum class eSide { NullSide = 0, Left, Right };
125 extern const std::string& eSide_Name(eSide m);
126 
127 enum class eGate { NullGate = 0, Open, Closed };
128 extern const std::string& eGate_Name(eGate m);
129 
130 enum class eSwitch { NullSwitch = 0, Off, On };
131 extern const std::string& eSwitch_Name(eSwitch m);
132 
133 enum class eCharge { NullCharge = 0, Negative, Neutral, Positive };
134 extern const std::string& eCharge_Name(eCharge m);
135 
136 //
137 // End General Enum
138 
139 class CCompoundUnit;
140 
141 class SERunningAverage;
142 class SEScalar; class SEUnitScalar; class SEGenericScalar; class NoUnit;
143 class SEScalar0To1;
145 class SEScalarAmount; class AmountUnit;
149 class SEScalarArea; class AreaUnit;
157 class SEScalarEnergy; class EnergyUnit;
164 class SEScalarForce; class ForceUnit;
165 class SEScalar0To1;
166 class SEScalarFrequency; class FrequencyUnit;
177 class SEScalarLength; class LengthUnit;
180 class SEScalarMass; class MassUnit;
188 class SEScalarPower; class PowerUnit;
190 class SEScalarPressure; class PressureUnit;
194 class SEScalarTime; class TimeUnit;
196 class SEScalarVolume; class VolumeUnit;
203 
204 class SEFunction;
207 
208 class SEHistogram;
Definition: SEScalarPressureTimePerVolumeArea.h:21
Definition: SEScalarArea.h:20
Definition: SEScalarLengthPerTimePressure.h:22
Definition: SEScalarMass.h:23
Definition: SEScalarVolumePerTimePressure.h:7
Definition: SEScalar.h:19
Definition: SEScalarVolume.h:7
Definition: SEScalarFlowElastance.h:7
Definition: SEScalarHeatCapacitancePerMass.h:7
Definition: SEScalarAmountPerTime.h:7
Definition: SEScalarMassPerTime.h:26
Definition: SEScalarFlowCompliance.h:7
Definition: SEScalarVolume.h:23
Definition: SEScalarLengthPerTimePressure.h:7
Definition: SEScalarHeatResistanceArea.h:7
Definition: SEScalarEnergyPerMass.h:22
Definition: SEScalarAmount.h:20
Definition: SEScalarPowerPerAreaTemperatureToTheFourth.h:19
Definition: SEScalarHeatConductancePerArea.h:7
Definition: SEScalarEnergyPerMass.h:7
Definition: SEScalarMassPerVolume.h:32
Definition: SEScalarHeatConductance.h:7
Definition: SEScalarInverseVolume.h:7
Definition: SEScalarElectricCharge.h:7
Definition: SEScalarVolumePerTimeArea.h:21
Definition: SEScalarPressure.h:23
Definition: SEScalarInverseVolume.h:20
Definition: SEScalarMassPerVolume.h:7
STL namespace.
Definition: SEFunctionVolumeVsTime.h:7
Definition: SEScalarElectricResistance.h:7
Definition: SEScalarAmountPerTime.h:25
If you want to querry what a scalar is and don&#39;t know what scalar type you have...
Definition: SEScalar.h:191
Definition: SEScalarHeatCapacitancePerAmount.h:19
Definition: SEScalarEnergyPerAmount.h:20
Definition: SEScalarPressureTimePerArea.h:7
Definition: SEScalarFlowInertance.h:7
Definition: SEScalarOsmolality.h:7
Definition: SERunningAverage.h:7
Definition: SEScalarMassPerAmount.h:7
Definition: SEScalarVolumePerTimePressure.h:22
Definition: SEScalarPressureTimePerArea.h:20
Definition: SEScalarAmountPerMass.h:20
Definition: SEFunctionElectricPotentialVsTime.h:7
Definition: SEScalarAmountPerMass.h:7
Definition: SEScalarEnergyPerAmount.h:7
Definition: SEScalarHeatConductancePerArea.h:21
Definition: SEScalarElectricPotential.h:7
Definition: SEScalarAmount.h:7
Definition: SEScalarVolumePerTime.h:7
Definition: SEScalarVolumePerPressure.h:7
Definition: SEScalarTime.h:7
Definition: SEScalarHeatInductance.h:7
Definition: SEScalarMassPerAreaTime.h:19
CommonDataModelException(const std::string &_Message)
Definition: CommonDataModel.h:112
Definition: SEScalar.h:10
Definition: SEScalarTemperature.h:22
Definition: SEScalarVolumePerTimePressureArea.h:7
Definition: SEScalarMassPerTime.h:7
Definition: SEHistogramFractionVsLength.h:7
Definition: SEScalarForce.h:7
Definition: SEScalarHeatInductance.h:19
Definition: SEScalarPressure.h:7
Definition: SEScalarVolumePerPressure.h:20
Definition: SEScalarElectricInductance.h:19
An interface to be used for gaining access to a scalar with any unit type
Definition: SEScalar.h:101
Definition: SEScalarOsmolarity.h:7
Definition: SEScalarLengthPerTime.h:24
Definition: SEScalarFlowInertance.h:23
Definition: SEScalarEnergy.h:7
Definition: SEScalarVolumePerTimeMass.h:7
Definition: SEScalarNegative1To1.h:7
Definition: SEScalarHeatCapacitance.h:7
Definition: SEScalarVolumePerTimePressureArea.h:20
Definition: SEScalarForce.h:21
Definition: SEScalarElectricCapacitance.h:19
Definition: SEScalarHeatConductance.h:22
Definition: SEScalarElectricResistance.h:19
Definition: SEScalarArea.h:7
Definition: SEScalarHeatCapacitance.h:22
Definition: SEScalarVolumePerTime.h:26
Definition: SEScalarHeatResistance.h:22
Definition: SEScalarAmountPerVolume.h:7
Definition: SEScalarEnergy.h:22
Definition: SEScalarElectricCurrent.h:19
Definition: SEScalarOsmolality.h:20
Definition: SEScalarInversePressure.h:22
Definition: SEScalarPowerPerAreaTemperatureToTheFourth.h:7
Definition: SEFunction.h:8
Definition: SEScalarOsmolarity.h:20
Definition: SEScalarLength.h:24
Definition: SEScalarMassPerMass.h:7
Definition: SEScalarElectricCharge.h:19
Definition: SEScalarLength.h:7
Definition: SEScalarElectricCurrent.h:7
Definition: SEScalarInversePressure.h:7
Definition: SEScalarAreaPerTimePressure.h:7
Definition: SEScalarPressurePerVolume.h:7
Definition: SEScalarFrequency.h:7
Definition: SEScalarTemperature.h:7
Definition: SEScalarElectricInductance.h:7
Definition: SEScalarTime.h:23
Definition: SEScalarElectricPotential.h:20
Definition: SEScalarElectricCapacitance.h:7
Definition: SEScalarLengthPerTime.h:7
Definition: SEScalarMassPerAmount.h:29
Definition: SEScalarPower.h:24
Definition: SEScalarHeatCapacitancePerAmount.h:7
Definition: SEScalarPressurePerVolume.h:21
Definition: SEScalarPressureTimePerVolumeArea.h:7
Definition: SEScalarAmountPerVolume.h:24
Definition: SEScalarVolumePerTimeMass.h:23
Definition: SEScalarPower.h:7
Definition: SEScalarVolumePerTimeArea.h:7
Definition: SEScalarFlowElastance.h:21
Definition: SEHistogram.h:8
Definition: SEScalarFrequency.h:21
Definition: SEScalarAreaPerTimePressure.h:22
Definition: CommonDataModel.h:107
Definition: SEScalarHeatResistance.h:7
Definition: SEScalarFlowResistance.h:7
CommonDataModelException()
Definition: CommonDataModel.h:109
Definition: SEScalarMass.h:7
Definition: CompoundUnit.h:39
Definition: SEScalarHeatResistanceArea.h:22
Definition: SEScalarFlowCompliance.h:22
Definition: SEScalarFlowResistance.h:23
Definition: SEScalarMassPerMass.h:20
Definition: SEScalar0To1.h:7
Definition: SEScalarMassPerAreaTime.h:7
Definition: SEScalarHeatCapacitancePerMass.h:22