CARMA C++
carma::services::Length Class Reference

The Length class can represent a length in any units. More...

#include <carma/services/Length.h>

Inheritance diagram for carma::services::Length:
carma::services::ConformableQuantity carma::services::Distance

Public Member Functions

 Length (double value, const std::string &units)
 Construct an Length given a value and units. More...
 
double meters () const
 Convenience method to return value in meters. More...
 
double millimeters () const
 Convenience method to return value in millimeters. More...
 
const Length operator+ (const Length &length) const
 Add two Lengths. More...
 
Lengthoperator+= (const Length &frequency)
 Increment Length. More...
 
const Length operator- (const Length &length) const
 Subtract two Lengths. More...
 
Lengthoperator-= (const Length &frequency)
 Decrement Length. More...
 
virtual ~Length ()
 Destructor. More...
 
- Public Member Functions inherited from carma::services::ConformableQuantity
 ConformableQuantity (double value, const std::string &units)
 Construct an ConformableQuantity given a value and units. More...
 
virtual double convert (const std::string &convertTo) const
 Converts this quantity to any conformable units. More...
 
virtual std::string getUnits () const
 
double getValue () const
 
virtual const ConformableQuantity operator+ (const ConformableQuantity &quantity) const
 Add two ConformableQuantities. More...
 
virtual ConformableQuantityoperator+= (const ConformableQuantity &quantity)
 Add ConformableQuantity to itself. More...
 
virtual const ConformableQuantity operator- (const ConformableQuantity &quantity) const
 Subtract two ConformableQuantities. More...
 
virtual ConformableQuantityoperator-= (const ConformableQuantity &quantity)
 Subtract ConformableQuantity from itself. More...
 
virtual void reset (double value, const std::string &units)
 Reset method to change value and/or units. More...
 
virtual ~ConformableQuantity ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from carma::services::ConformableQuantity
Units u_
 Used for converting between units. More...
 

Detailed Description

The Length class can represent a length in any units.

It uses the Units class internally to handle conversion of any length unit to any other length unit. For example,
Length length1(1000.0,"m")
Length length2(1.0,"km")
both length1 and length2 represent the same physical quantity. Binary operations + and - are supported, as is the stream operation <<.

Definition at line 36 of file Length.h.

Constructor & Destructor Documentation

carma::services::Length::Length ( double  value,
const std::string &  units 
)

Construct an Length given a value and units.

Parameters
valueThe value of this length
unitsThe units of the value.
virtual carma::services::Length::~Length ( )
virtual

Destructor.

Member Function Documentation

double carma::services::Length::meters ( ) const

Convenience method to return value in meters.

Definition at line 52 of file Length.h.

double carma::services::Length::millimeters ( ) const

Convenience method to return value in millimeters.

Definition at line 59 of file Length.h.

const Length carma::services::Length::operator+ ( const Length length) const

Add two Lengths.

Returns
a Length with kilometer units that is the sum of the two Lengths.
Exceptions
ConformabilityException
Length& carma::services::Length::operator+= ( const Length frequency)

Increment Length.

Returns
incremented Length
const Length carma::services::Length::operator- ( const Length length) const

Subtract two Lengths.

Returns
an Length with kilometer units that is the difference of the two lengths
Exceptions
ConformabilityException
Length& carma::services::Length::operator-= ( const Length frequency)

Decrement Length.

Returns
decremented Length

The documentation for this class was generated from the following file: