CARMA C++
ConformableQuantity.h
Go to the documentation of this file.
1 // $Id: ConformableQuantity.h,v 1.7 2005/06/06 20:37:52 mpound Exp $
2 
14 #ifndef CARMA_SERVICES_CONFORMABLEQUANTITY_H
15 #define CARMA_SERVICES_CONFORMABLEQUANTITY_H
16 
17 #include "carma/services/Units.h"
18 #include <iostream>
19 #include <string>
20 
21 namespace carma {
22  namespace services {
35  public:
36 
42  explicit ConformableQuantity(double value,
43  const std::string& units);
44 
46  virtual ~ConformableQuantity();
47 
60  virtual double convert(const std::string& convertTo) const;
61 
66  double getValue() const
67  {
68  return value_;
69  }
70 
75  virtual std::string getUnits() const;
76 
83  virtual const ConformableQuantity
84  operator+(const ConformableQuantity& quantity) const;
85 
92  virtual const ConformableQuantity
93  operator-(const ConformableQuantity& quantity) const;
94 
100  virtual ConformableQuantity&
101  operator+=(const ConformableQuantity& quantity);
102 
108  virtual ConformableQuantity&
109  operator-=(const ConformableQuantity& quantity);
110 
122  virtual void reset(double value, const std::string& units);
123 
124  protected:
129 
130  private:
131 
135  double value_;
136 
141  std::string units_;
142 
143  };
144 
148 std::ostream& operator<<(std::ostream& os,
149  ConformableQuantity& quantity);
150 
151  } // namespace services
152 } // namespace carma
153 
154 #endif //CARMA_SERVICES_CONFORMABLEQUANTITY_H
The ConformableQuantity class can represent any quantity that can be expressed in many units...
ConformableQuantity(double value, const std::string &units)
Construct an ConformableQuantity given a value and units.
virtual ConformableQuantity & operator-=(const ConformableQuantity &quantity)
Subtract ConformableQuantity from itself.
Units u_
Used for converting between units.
virtual const ConformableQuantity operator+(const ConformableQuantity &quantity) const
Add two ConformableQuantities.
virtual std::string getUnits() const
virtual double convert(const std::string &convertTo) const
Converts this quantity to any conformable units.
virtual ConformableQuantity & operator+=(const ConformableQuantity &quantity)
Add ConformableQuantity to itself.
virtual ~ConformableQuantity()
Destructor.
std::ostream & operator<<(std::ostream &os, const carma::services::Angle &angle)
Define the &lt;&lt; operator to allow, e.g.
virtual void reset(double value, const std::string &units)
Reset method to change value and/or units.
This class is based on the GNU units library.
Definition: Units.h:46
virtual const ConformableQuantity operator-(const ConformableQuantity &quantity) const
Subtract two ConformableQuantities.