mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Add comment on how Units are built
This commit is contained in:
@@ -188,6 +188,13 @@ public:
|
||||
typedef UnitNode::Prefix Prefix;
|
||||
typedef UnitNode::Representative Representative;
|
||||
typedef UnitNode::Dimension Dimension;
|
||||
/* TODO: Prefix, Representative and Dimension defined below must be defined
|
||||
* only once and all units must be constructed from their pointers. This way
|
||||
* we can easily check if two Unit objects are equal by comparing pointers.
|
||||
* This saves us from overloading the == operator on Prefix, Representative
|
||||
* and Dimension and saves time at execution. We should assert at compilation
|
||||
* that only one occurence of each is built by maybe privatizing constructors
|
||||
* on these classes? */
|
||||
static constexpr const Prefix
|
||||
PicoPrefix = Prefix("p", -12),
|
||||
NanoPrefix = Prefix("n", -9),
|
||||
|
||||
@@ -393,15 +393,18 @@ Expression Unit::removeUnit(Expression * unit) {
|
||||
}
|
||||
|
||||
bool Unit::isSecond() const {
|
||||
// TODO: comparing pointers suffices because all time dimension are built from the same pointers. This should be asserted some way at compile-time?
|
||||
return node()->dimension() == TimeDimension && node()->representative() == SecondRepresentative && node()->prefix() == &EmptyPrefix;
|
||||
}
|
||||
|
||||
bool Unit::isMeter() const {
|
||||
// See comment on isSecond
|
||||
return node()->dimension() == DistanceDimension && node()->representative() == MeterRepresentative && node()->prefix() == &EmptyPrefix;
|
||||
}
|
||||
|
||||
|
||||
bool Unit::isKilogram() const {
|
||||
// See comment on isSecond
|
||||
return node()->dimension() == MassDimension && node()->representative() == KilogramRepresentative && node()->prefix() == &KiloPrefix;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user