6 #ifndef GDCORE_MEASUREMENTUNIT
7 #define GDCORE_MEASUREMENTUNIT
10 #include "GDCore/Project/MeasurementUnitElement.h"
11 #include "GDCore/String.h"
15 class SerializerElement;
16 class MeasurementBaseUnit;
26 MeasurementUnit(
const std::vector<gd::MeasurementUnitElement> &elements_,
29 : elements(elements_), name(name_), label(label_),
30 description(description_), elementsWithWords(elementsWithWords_) {}
34 : name(name_), label(label_), description(description_),
35 elementsWithWords(elementsWithWords_) {}
62 const std::vector<gd::MeasurementUnitElement> &
GetElements()
const {
66 std::size_t GetElementsCount()
const {
return elements.size(); }
68 int GetElementPower(std::size_t elementIndex)
const {
69 return elements.at(elementIndex).GetPower();
73 GetElementBaseUnit(std::size_t elementIndex)
const {
74 return elements.at(elementIndex).GetBaseUnit();
77 bool IsUndefined()
const {
78 return this == &gd::MeasurementUnit::undefined || name ==
"Undefined";
81 static void ApplyTranslation();
96 return pixelAcceleration;
103 static const std::vector<const gd::MeasurementUnit*> &GetDefaultMeasurementUnits();
104 static std::size_t GetDefaultMeasurementUnitsCount();
106 static bool HasDefaultMeasurementUnitNamed(
const gd::String &name);
110 static std::vector<const gd::MeasurementUnit*> defaultMeasurementUnits;
122 return MeasurementUnit(
"Undefined", _(
"Undefined"),
"");
126 return MeasurementUnit(
"Dimensionless", _(
"Dimensionless"),
"");
130 std::vector<gd::MeasurementUnitElement> elements;
132 MeasurementUnitElement(gd::MeasurementBaseUnit::degreeAngle, 1));
133 return MeasurementUnit(elements,
"DegreeAngle", _(
"Angle"), _(
"degree"));
137 std::vector<gd::MeasurementUnitElement> elements;
139 MeasurementUnitElement(gd::MeasurementBaseUnit::second, 1));
140 return MeasurementUnit(elements,
"Second", _(
"Duration"), _(
"second"));
144 std::vector<gd::MeasurementUnitElement> elements;
146 MeasurementUnitElement(gd::MeasurementBaseUnit::pixel, 1));
147 return MeasurementUnit(elements,
"Pixel", _(
"Distance"), _(
"pixel"));
151 std::vector<gd::MeasurementUnitElement> elements;
153 MeasurementUnitElement(gd::MeasurementBaseUnit::pixel, 1));
155 MeasurementUnitElement(gd::MeasurementBaseUnit::second, -1));
156 return MeasurementUnit(elements,
"PixelSpeed", _(
"Speed"),
157 _(
"pixel per second"),
158 _(
"How much distance is covered per second."));
162 std::vector<gd::MeasurementUnitElement> elements;
164 MeasurementUnitElement(gd::MeasurementBaseUnit::pixel, 1));
166 MeasurementUnitElement(gd::MeasurementBaseUnit::second, -2));
167 return MeasurementUnit(elements,
"PixelAcceleration", _(
"Acceleration"),
168 _(
"pixel per second, per second"),
169 _(
"How much speed is gained (or lost) per second."));
173 std::vector<gd::MeasurementUnitElement> elements;
175 MeasurementUnitElement(gd::MeasurementBaseUnit::meter, 1));
177 MeasurementUnitElement(gd::MeasurementBaseUnit::kilogram, 1));
179 MeasurementUnitElement(gd::MeasurementBaseUnit::second, -2));
180 return MeasurementUnit(
182 _(
"Force (in Newton)"), _(
"meter kilogram per second, per second"),
183 _(
"A unit to measure forces."));
187 std::vector<gd::MeasurementUnitElement> elements;
189 MeasurementUnitElement(gd::MeasurementBaseUnit::degreeAngle, 1));
191 MeasurementUnitElement(gd::MeasurementBaseUnit::second, -1));
192 return MeasurementUnit(elements,
"AngularSpeed", _(
"Angular speed"),
193 _(
"degree per second"),
194 _(
"How much angle is covered per second."));
201 std::vector<gd::MeasurementUnitElement> elements;
An atomic unit of measurement.
Definition: MeasurementBaseUnit.h:20
A unit of measurement.
Definition: MeasurementUnit.h:24
const gd::String & GetName() const
Return the unit name.
Definition: MeasurementUnit.h:42
const std::vector< gd::MeasurementUnitElement > & GetElements() const
Return the unit elements.
Definition: MeasurementUnit.h:62
const gd::String & GetLabel() const
Return the unit label.
Definition: MeasurementUnit.h:47
const gd::String & GetElementsWithWords() const
Return the unit description.
Definition: MeasurementUnit.h:57
const gd::String & GetDescription() const
Return the unit description.
Definition: MeasurementUnit.h:52
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24