File indexing completed on 2026-06-02 08:51:49
0001 #ifndef PHYSICAL_UNIT_H
0002 #define PHYSICAL_UNIT_H
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <string>
0012
0013 #include "UnitCategory.h"
0014
0015 namespace ElemUtils {
0016 class Packet;
0017 }
0018
0019 namespace PARTONS {
0020
0021
0022
0023
0024
0025
0026 class PhysicalUnit {
0027
0028 public:
0029
0030
0031
0032
0033 enum Type {
0034
0035
0036 UNDEFINED = 0,
0037
0038
0039 NONE = 1,
0040
0041
0042 EV = 2,
0043 KEV = 3,
0044 MEV = 4,
0045 GEV = 5,
0046 TEV = 6,
0047
0048
0049 EV2 = 7,
0050 KEV2 = 8,
0051 MEV2 = 9,
0052 GEV2 = 10,
0053 TEV2 = 11,
0054
0055
0056 EVm1 = 12,
0057 KEVm1 = 13,
0058 MEVm1 = 14,
0059 GEVm1 = 15,
0060 TEVm1 = 16,
0061
0062 FM = 17,
0063 PM = 18,
0064 NM = 19,
0065 UM = 20,
0066 MM = 21,
0067 M = 22,
0068
0069 FS = 23,
0070 PS = 24,
0071 NS = 25,
0072 US = 26,
0073 MS = 27,
0074 S = 28,
0075
0076
0077 GEVm2 = 29,
0078
0079 FM2 = 30,
0080
0081 FB = 31,
0082 PB = 32,
0083 NB = 33,
0084 UB = 34,
0085 MB = 35,
0086 B = 36,
0087
0088
0089 DEG = 37,
0090 RAD = 38,
0091 MRAD = 39
0092 };
0093
0094
0095
0096
0097 PhysicalUnit();
0098
0099
0100
0101
0102
0103 PhysicalUnit(Type type);
0104
0105
0106
0107
0108
0109 PhysicalUnit(const std::string& type);
0110
0111
0112
0113
0114
0115 PhysicalUnit(const PhysicalUnit &other);
0116
0117
0118
0119
0120 operator Type() const;
0121
0122
0123
0124
0125 std::string toString() const;
0126
0127
0128
0129
0130 std::string getShortName();
0131
0132
0133
0134
0135
0136 void serialize(ElemUtils::Packet &packet) const;
0137
0138
0139
0140
0141
0142 void unserialize(ElemUtils::Packet &packet);
0143
0144
0145
0146
0147 UnitCategory::Type getUnitCategory() const;
0148
0149
0150
0151
0152 double getConversionFactor() const;
0153
0154
0155
0156
0157
0158
0159
0160
0161 PhysicalUnit::Type getType() const;
0162
0163
0164
0165
0166 void setType(Type type);
0167
0168 private:
0169
0170
0171
0172
0173 PhysicalUnit::Type m_type;
0174 };
0175
0176
0177
0178
0179 ElemUtils::Packet& operator <<(ElemUtils::Packet& packet,
0180 PhysicalUnit& physicalUnit);
0181
0182
0183
0184
0185 ElemUtils::Packet& operator >>(ElemUtils::Packet& packet,
0186 PhysicalUnit& physicalUnit);
0187
0188 }
0189
0190 #endif