trick/trick_source/trick_utils/units/include/Unit.hh
Alex Lin 14a75508a3 Cleaning up once include variables and copyright cleanup.
Changed all header file once include variables to follow the same naming
convention and not start with any underscores.  Also deleted old
incorrect copyright notices.  Also removed $Id: tags from all files.

Fixes #14.  Fixes #22.
2015-03-23 16:03:14 -05:00

74 lines
2.0 KiB
C++

/*
PURPOSE: (Units Conversion Package C++ Language Interface)
PROGRAMMERS:
(((John M. Penn) (L-3Com/Titan) (May 2006) (v1.0)
(Initial Release)))
*/
#ifndef UNIT_HH
#define UNIT_HH
#include "units_conv.h"
#include "UCFn.hh"
/**
* Unit (of measurement) class.
*/
class Unit {
public:
#ifndef SWIG
class CONVERSION_ERROR {}; // Exception Class
#endif
/**
*
*/
Unit(); // Throws CONVERSION_ERROR
Unit(const char *name); // Throws CONVERSION_ERROR
~Unit();
/**
Initialize the Unit object from the given units specifier.
Throw an exception if the specifier is invalid.
*/
std::string setUnitName(const char *units_spec); // Throws CONVERSION_ERROR
/**
Return the units specifier of this Unit object.
*/
const char *getUnitName() { return this->units_name.c_str(); }
/**
Return a base and offset that converts these units to the units
specified by the given units specifier. Throw an exception if its not possible.
*/
UCFn *Conversion_to( const char *units_spec); // Throws CONVERSION_ERROR
/**
Return a base and offset that converts these units to the units
specified by the given Unit object. Throw an exception if its not possible.
*/
UCFn *Conversion_to( const Unit *u); // Throws CONVERSION_ERROR
/**
Convert the value from these units to those specified by the given units specifier.
*/
double Convert_to( double val, const char *unit_spec); // Throws CONVERSION_ERROR
/**
Convert the value from these units to those specified by the Unit parameter.
*/
double Convert_to( double val, const Unit *u); // Throws CONVERSION_ERROR
#ifndef SWIG
friend std::ostream& operator<< ( std::ostream& s, const Unit *u);
#endif
private:
std::string units_name;
Units_t *units;
};
#endif