Gyoto
|
Wrapper around ut_converter from udunits. More...
#include <GyotoConverters.h>
Public Types | |
typedef Gyoto::SmartPointer< Gyoto::SmartPointee > | Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &) |
A subcontractor builds an object upon order from the Factory. More... | |
Public Member Functions | |
Converter () | |
Construct trivial Converter (Converter()(x)==x) | |
Converter (const Gyoto::Units::Unit &from, const Gyoto::Units::Unit &to) | |
Construct Converter from two Unit. | |
~Converter () | |
Destruct converter, freeing converter_. | |
void | reset () |
Reset to trivial Converter (Converter()(x)==x) | |
void | reset (const Gyoto::Units::Unit &from, const Gyoto::Units::Unit &to) |
Reset to converter from "from" to "to". | |
double | operator() (double value) const |
Actually convert data. More... | |
void | incRefCount () |
Increment the reference counter. Warning: Don't mess with the counter. | |
int | decRefCount () |
Decrement the reference counter and return current value. Warning: Don't mess with the counter. | |
int | getRefCount () |
Get the current number of references. | |
Private Attributes | |
cv_converter * | converter_ |
Underlying ut_converter object from udunits. | |
Friends | |
class | Gyoto::SmartPointer< Gyoto::Units::Converter > |
Wrapper around ut_converter from udunits.
A Gyoto::Units::Converter object is a functor and can be used to convert efficiently between the two units specified at instantiation time:
Since std::string cast automatically to Gyoto::Units::Unit object, this is equivalent:
|
inherited |
A subcontractor builds an object upon order from the Factory.
Various classes need to provide a subcontractor to be able to instantiate themselves upon order from the Factory. A subcontractor is a function (often a static member function) which accepts a pointer to a FactoryMessenger as unique parameter, communicates with the Factory using this messenger to read an XML description of the object to build, and returns this objet. SmartPointee::Subcontractor_t* is just generic enough a typedef to cast to and from other subcontractor types: Astrobj::Subcontractor_t, Metric::Subcontractor_t, Spectrum::Subcontractor_t. A subcontractor needs to be registered using the relevant Register() function: Astrobj::Register(), Metric::Register(), Spectrum::Register().
double Gyoto::Units::Converter::operator() | ( | double | value | ) | const |
Actually convert data.
The entire Gyoto::Units::Converter class is there just for this operator, which converts value from unit "from" to unit "to" where "from" and "to" are the two Units passed to the constructor Gyoto::Units::Converter::Converter(const Gyoto::Units::Unit& from, const Gyoto::Units::Unit& to).
value | double expressed in Unit from |