CARMA C++
Length.h
Go to the documentation of this file.
1 // $Id: Length.h,v 1.6 2006/01/20 16:46:40 mpound Exp $
2 
13 #ifndef CARMA_SERVICES_LENGTH_H
14 #define CARMA_SERVICES_LENGTH_H
15 
17 #include <iostream>
18 #include <string>
19 
20 namespace carma {
21  namespace services {
36  class Length : public ConformableQuantity {
37  public:
38 
44  Length(double value, const std::string& units);
45 
47  virtual ~Length();
48 
52  double meters() const {
53  return convert("meter");
54  }
55 
59  double millimeters() const {
60  return convert("millimeter");
61  }
62 
69  const Length operator+(const Length& length) const;
70 
77  const Length operator-(const Length& length) const;
78 
83  Length &operator+=(const Length &frequency);
84 
89  Length &operator-=(const Length &frequency);
90  };
94  std::ostream& operator<<(std::ostream& os,
95  const carma::services::Length& length);
96 
97  }
98 }
99 
100 
101 #endif //CARMA_SERVICES_LENGTH_H
The ConformableQuantity class can represent any quantity that can be expressed in many units...
const Length operator+(const Length &length) const
Add two Lengths.
double meters() const
Convenience method to return value in meters.
Definition: Length.h:52
double millimeters() const
Convenience method to return value in millimeters.
Definition: Length.h:59
virtual ~Length()
Destructor.
const Length operator-(const Length &length) const
Subtract two Lengths.
Length & operator-=(const Length &frequency)
Decrement Length.
virtual double convert(const std::string &convertTo) const
Converts this quantity to any conformable units.
Length & operator+=(const Length &frequency)
Increment Length.
Parent class for representations of quantities that can have conformable units, e.g.
std::ostream & operator<<(std::ostream &os, const carma::services::Angle &angle)
Define the &lt;&lt; operator to allow, e.g.
The Length class can represent a length in any units.
Definition: Length.h:36
Length(double value, const std::string &units)
Construct an Length given a value and units.