osgEarth 2.1.1
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes

osgEarth::Units Class Reference

Collaboration diagram for osgEarth::Units:

List of all members.

Public Types

enum  Type {
  TYPE_LINEAR, TYPE_ANGULAR, TYPE_TEMPORAL, TYPE_SPEED,
  TYPE_INVALID
}

Public Member Functions

bool canConvert (const Units &to) const
bool convertTo (const Units &to, double input, double &output) const
double convertTo (const Units &to, double input) const
const std::string & getName () const
const std::string & getAbbr () const
const TypegetType () const
bool operator== (const Units &rhs) const
bool operator!= (const Units &rhs) const
bool isLinear () const
bool isAngular () const
bool isTemporal () const
bool isSpeed () const
 Units (const std::string &name, const std::string &abbr, const Type &type, double toBase)
 Units (const std::string &name, const std::string &abbr, const Units &distance, const Units &time)
 Units ()

Static Public Member Functions

static bool convert (const Units &from, const Units &to, double input, double &output)
static double convert (const Units &from, const Units &to, double input)
static bool canConvert (const Units &from, const Units &to)

Static Public Attributes

static const Units CENTIMETERS
static const Units DATA_MILES
static const Units FATHOMS
static const Units FEET
static const Units FEET_US_SURVEY
static const Units INCHES
static const Units KILOFEET
static const Units KILOMETERS
static const Units KILOYARDS
static const Units METERS
static const Units MILES
static const Units MILLIMETERS
static const Units NAUTICAL_MILES
static const Units YARDS
static const Units BAM
static const Units DEGREES
static const Units NATO_MILS
static const Units RADIANS
static const Units DAYS
static const Units HOURS
static const Units MICROSECONDS
static const Units MILLISECONDS
static const Units MINUTES
static const Units SECONDS
static const Units WEEKS
static const Units FEET_PER_SECOND
static const Units YARDS_PER_SECOND
static const Units METERS_PER_SECOND
static const Units KILOMETERS_PER_SECOND
static const Units KILOMETERS_PER_HOUR
static const Units MILES_PER_HOUR
static const Units DATA_MILES_PER_HOUR
static const Units KNOTS

Static Private Member Functions

static void convertSimple (const Units &from, const Units &to, double input, double &output)
static void convertSpeed (const Units &from, const Units &to, double input, double &output)

Private Attributes

std::string _name
std::string _abbr
Type _type
double _toBase
const Units_distance
const Units_time

Detailed Description

Definition at line 26 of file Units.


Member Enumeration Documentation

Enumerator:
TYPE_LINEAR 
TYPE_ANGULAR 
TYPE_TEMPORAL 
TYPE_SPEED 
TYPE_INVALID 

Definition at line 70 of file Units.


Constructor & Destructor Documentation

Units::Units ( const std::string &  name,
const std::string &  abbr,
const Type type,
double  toBase 
)

Definition at line 25 of file Units.cpp.

                                                                                                 :
_name  ( name ),
_abbr  ( abbr ),
_type  ( type ),
_toBase( toBase )
{
    //nop
}
Units::Units ( const std::string &  name,
const std::string &  abbr,
const Units distance,
const Units time 
)

Definition at line 34 of file Units.cpp.

                                                                                                     :
_name    ( name ),
_abbr    ( abbr ),
_type    ( TYPE_SPEED ),
_distance( &distance ),
_time    ( &time )
{
    //nop
}
osgEarth::Units::Units ( ) [inline]

Definition at line 135 of file Units.


Member Function Documentation

static bool osgEarth::Units::canConvert ( const Units from,
const Units to 
) [inline, static]

Definition at line 91 of file Units.

                                                                     {
            return from._type == to._type;
        }

Here is the caller graph for this function:

bool osgEarth::Units::canConvert ( const Units to) const [inline]

Definition at line 95 of file Units.

                                                 {
            return _type == to._type;
        }
static double osgEarth::Units::convert ( const Units from,
const Units to,
double  input 
) [inline, static]

Definition at line 85 of file Units.

                                                                                  {
            double output;
            convert( from, to, input, output );
            return output;
        }
static bool osgEarth::Units::convert ( const Units from,
const Units to,
double  input,
double &  output 
) [inline, static]

Definition at line 74 of file Units.

                                                                                                {
            if ( canConvert(from, to) ) {
                if ( from._type == TYPE_LINEAR || from._type == TYPE_ANGULAR || from._type == TYPE_TEMPORAL )
                    convertSimple( from, to, input, output );
                else if ( from._type == TYPE_SPEED )
                    convertSpeed( from, to, input, output );
                return true;
            }
            return false;
        }

Here is the caller graph for this function:

static void osgEarth::Units::convertSimple ( const Units from,
const Units to,
double  input,
double &  output 
) [inline, static, private]

Definition at line 139 of file Units.

                                                                                                      {
            output = input * from._toBase / to._toBase;
        }
static void osgEarth::Units::convertSpeed ( const Units from,
const Units to,
double  input,
double &  output 
) [inline, static, private]

Definition at line 142 of file Units.

                                                                                                     {
            double t = from._distance->convertTo( *to._distance, input );
            output = to._time->convertTo( *from._time, t );
        }

Here is the call graph for this function:

bool osgEarth::Units::convertTo ( const Units to,
double  input,
double &  output 
) const [inline]

Definition at line 99 of file Units.

                                                                               {
            return convert( *this, to, input, output );
        }

Here is the caller graph for this function:

double osgEarth::Units::convertTo ( const Units to,
double  input 
) const [inline]

Definition at line 103 of file Units.

                                                                {
            return convert( *this, to, input );
        }
const std::string& osgEarth::Units::getAbbr ( ) const [inline]

Definition at line 109 of file Units.

{ return _abbr; }
const std::string& osgEarth::Units::getName ( ) const [inline]

Definition at line 107 of file Units.

{ return _name; }
const Type& osgEarth::Units::getType ( ) const [inline]

Definition at line 111 of file Units.

{ return _type; }
bool osgEarth::Units::isAngular ( ) const [inline]

Definition at line 121 of file Units.

{ return _type == TYPE_ANGULAR; }
bool osgEarth::Units::isLinear ( ) const [inline]

Definition at line 119 of file Units.

{ return _type == TYPE_LINEAR; }
bool osgEarth::Units::isSpeed ( ) const [inline]

Definition at line 125 of file Units.

{ return _type == TYPE_SPEED; }
bool osgEarth::Units::isTemporal ( ) const [inline]

Definition at line 123 of file Units.

{ return _type == TYPE_TEMPORAL; }
bool osgEarth::Units::operator!= ( const Units rhs) const [inline]

Definition at line 116 of file Units.

                                                    {
            return _type != rhs._type || _toBase != rhs._toBase; }
bool osgEarth::Units::operator== ( const Units rhs) const [inline]

Definition at line 113 of file Units.

                                                    {
            return _type == rhs._type && _toBase == rhs._toBase; }

Member Data Documentation

std::string osgEarth::Units::_abbr [private]

Definition at line 148 of file Units.

Definition at line 151 of file Units.

std::string osgEarth::Units::_name [private]

Definition at line 148 of file Units.

const Units* osgEarth::Units::_time [private]

Definition at line 152 of file Units.

double osgEarth::Units::_toBase [private]

Definition at line 150 of file Units.

Definition at line 149 of file Units.

const Units Units::BAM [static]

Definition at line 46 of file Units.

const Units Units::CENTIMETERS [static]

Definition at line 30 of file Units.

const Units Units::DATA_MILES [static]

Definition at line 31 of file Units.

Definition at line 67 of file Units.

const Units Units::DAYS [static]

Definition at line 52 of file Units.

const Units Units::DEGREES [static]

Definition at line 47 of file Units.

const Units Units::FATHOMS [static]

Definition at line 32 of file Units.

const Units Units::FEET [static]

Definition at line 33 of file Units.

const Units Units::FEET_PER_SECOND [static]

Definition at line 61 of file Units.

const Units Units::FEET_US_SURVEY [static]

Definition at line 34 of file Units.

const Units Units::HOURS [static]

Definition at line 53 of file Units.

const Units Units::INCHES [static]

Definition at line 35 of file Units.

const Units Units::KILOFEET [static]

Definition at line 36 of file Units.

const Units Units::KILOMETERS [static]

Definition at line 37 of file Units.

Definition at line 65 of file Units.

Definition at line 64 of file Units.

const Units Units::KILOYARDS [static]

Definition at line 38 of file Units.

const Units Units::KNOTS [static]

Definition at line 68 of file Units.

const Units Units::METERS [static]

Definition at line 39 of file Units.

Definition at line 63 of file Units.

const Units Units::MICROSECONDS [static]

Definition at line 54 of file Units.

const Units Units::MILES [static]

Definition at line 40 of file Units.

const Units Units::MILES_PER_HOUR [static]

Definition at line 66 of file Units.

const Units Units::MILLIMETERS [static]

Definition at line 41 of file Units.

const Units Units::MILLISECONDS [static]

Definition at line 55 of file Units.

const Units Units::MINUTES [static]

Definition at line 56 of file Units.

const Units Units::NATO_MILS [static]

Definition at line 48 of file Units.

const Units Units::NAUTICAL_MILES [static]

Definition at line 42 of file Units.

const Units Units::RADIANS [static]

Definition at line 49 of file Units.

const Units Units::SECONDS [static]

Definition at line 57 of file Units.

const Units Units::WEEKS [static]

Definition at line 58 of file Units.

const Units Units::YARDS [static]

Definition at line 43 of file Units.

Definition at line 62 of file Units.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines