70 assert(_factor != 0.0);
77 decimal_places = _decimal_places;
84 return internal * factor + offset;
93 for (
int i = 0; i <
internal.eNUMBER_OF_ELEMENTS; i++ )
95 if (
internal.Valid( i ) )
96 rv[i] =
internal[i] * factor + offset;
105 std::vector<double> rv;
107 for ( std::vector<double>::const_iterator vi =
internal.begin();
108 vi !=
internal.end();
111 rv.push_back( *vi * factor + offset );
120 return (external - offset) / factor;
131 if ( external.
Valid( i ) )
132 rv[i] = (external[i] - offset) / factor;
141 std::vector<double> rv;
143 for ( std::vector<double>::const_iterator vi = external.begin();
144 vi != external.end();
147 rv.push_back( ( *vi - offset) / factor );
193 return decimal_places;
cUnitConverter(char const *_kind, char const *_name, char const *_symbol, double _factor=1.0, double _offset=0.0, int _decimal_places=1)
Unit conversion class to convert values between physical unit systems.
char const * GetKind(void) const
Return the kind of unit converted (something like "angle" or "time")
int GetDecimalPlaces(void) const
Return the number of decimal places for printing values in the external unit system.
A simple vector implementation.
double ToExternal(double internal) const
double GetFactor(void) const
Return the conversion factor from internal to external units.
Interface of class #SDH::cUnitConverter.
#define NAMESPACE_SDH_START
char const * GetSymbol(void) const
Return the symbol of the external unit (something like "deg" or "ms")
double ToInternal(double external) const
#define USING_NAMESPACE_SDH
#define NAMESPACE_SDH_END
NAMESPACE_SDH_START cUnitConverter const uc_identity("any","any","?", 1.0, 0.0, 4)
double GetOffset(void) const
Return the conversion offset from internal to external units.
char const * GetName(void) const
Return the name of the external unit (something like "degrees" or "milliseconds") ...
number of elements in vector
bool Valid(unsigned int index) const
Return true if vector element index is valid (has been accessed at least once)