Gazebo Math

API Reference

7.5.1
gz/math/Temperature.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_MATH_TEMPERATURE_HH_
18 #define GZ_MATH_TEMPERATURE_HH_
19 
20 #include <istream>
21 #include <ostream>
22 
23 #include <gz/math/config.hh>
24 #include "gz/math/Helpers.hh"
25 #include <gz/utils/ImplPtr.hh>
26 
27 
28 namespace gz::math
29 {
30  // Inline bracket to help doxygen filtering.
31  inline namespace GZ_MATH_VERSION_NAMESPACE {
74  class GZ_MATH_VISIBLE Temperature
75  {
77  public: Temperature();
78 
82  // cppcheck-suppress noExplicitConstructor
83  public: Temperature(double _temp);
84 
88  public: static double KelvinToCelsius(double _temp);
89 
93  public: static double KelvinToFahrenheit(double _temp);
94 
98  public: static double CelsiusToFahrenheit(double _temp);
99 
103  public: static double CelsiusToKelvin(double _temp);
104 
108  public: static double FahrenheitToCelsius(double _temp);
109 
113  public: static double FahrenheitToKelvin(double _temp);
114 
117  public: void SetKelvin(double _temp);
118 
121  public: void SetCelsius(double _temp);
122 
125  public: void SetFahrenheit(double _temp);
126 
129  public: double Kelvin() const;
130 
133  public: double Celsius() const;
134 
137  public: double Fahrenheit() const;
138 
142  public: double operator()() const;
143 
147  public: Temperature &operator=(double _temp);
148 
152  public: Temperature operator+(double _temp) const;
153 
157  public: Temperature operator+(const Temperature &_temp) const;
158 
163  public: friend Temperature operator+(double _t, const Temperature &_temp)
164  {
165  return _t + _temp.Kelvin();
166  }
167 
171  public: const Temperature &operator+=(double _temp);
172 
176  public: const Temperature &operator+=(const Temperature &_temp);
177 
181  public: Temperature operator-(double _temp) const;
182 
186  public: Temperature operator-(const Temperature &_temp) const;
187 
192  public: friend Temperature operator-(double _t, const Temperature &_temp)
193  {
194  return _t - _temp.Kelvin();
195  }
196 
200  public: const Temperature &operator-=(double _temp);
201 
205  public: const Temperature &operator-=(const Temperature &_temp);
206 
210  public: Temperature operator*(double _temp) const;
211 
215  public: Temperature operator*(const Temperature &_temp) const;
216 
221  public: friend Temperature operator*(double _t, const Temperature &_temp)
222  {
223  return _t * _temp.Kelvin();
224  }
225 
229  public: const Temperature &operator*=(double _temp);
230 
234  public: const Temperature &operator*=(const Temperature &_temp);
235 
239  public: Temperature operator/(double _temp) const;
240 
244  public: Temperature operator/(const Temperature &_temp) const;
245 
250  public: friend Temperature operator/(double _t, const Temperature &_temp)
251  {
252  return _t / _temp.Kelvin();
253  }
254 
258  public: const Temperature &operator/=(double _temp);
259 
263  public: const Temperature &operator/=(const Temperature &_temp);
264 
268  public: bool operator==(const Temperature &_temp) const;
269 
274  public: bool operator==(double _temp) const;
275 
279  public: bool operator!=(const Temperature &_temp) const;
280 
285  public: bool operator!=(double _temp) const;
286 
290  public: bool operator<(const Temperature &_temp) const;
291 
296  public: bool operator<(double _temp) const;
297 
301  public: bool operator<=(const Temperature &_temp) const;
302 
307  public: bool operator<=(double _temp) const;
308 
312  public: bool operator>(const Temperature &_temp) const;
313 
318  public: bool operator>(double _temp) const;
319 
323  public: bool operator>=(const Temperature &_temp) const;
324 
329  public: bool operator>=(double _temp) const;
330 
335  public: friend std::ostream &operator<<(std::ostream &_out,
336  const gz::math::Temperature &_temp)
337  {
338  _out << _temp.Kelvin();
339  return _out;
340  }
341 
347  public: friend std::istream &operator>>(std::istream &_in,
348  gz::math::Temperature &_temp)
349  {
350  // Skip white spaces
351  _in.setf(std::ios_base::skipws);
352 
353  double kelvin;
354  _in >> kelvin;
355 
356  if (!_in.fail())
357  {
358  _temp.SetKelvin(kelvin);
359  }
360  return _in;
361  }
362 
363  GZ_UTILS_IMPL_PTR(dataPtr)
364  };
365  } // namespace GZ_MATH_VERSION_NAMESPACE
366 } // namespace gz::math
367 #endif // GZ_MATH_TEMPERATURE_HH_