Frequency.h
Go to the documentation of this file.
1 #pragma once
2 
3 
4 #include <cstdint>
5 #include <ostream>
6 #include <string>
7 
9 
10 
11 namespace armarx::core::time
12 {
13 
14  /**
15  * @brief Represents a frequency.
16  */
17  class Frequency
18  {
19  // Public API.
20  public:
21  Frequency(const Duration& cycleDuration);
22 
23  static Frequency Hertz(std::int64_t hertz);
24 
25  static Frequency HertzDouble(double hertz);
26 
27  std::int64_t toHertz() const;
28 
29  double toHertzDouble() const;
30 
31  Duration toCycleDuration() const;
32 
33  std::string toFrequencyString() const;
34 
35  // Operators.
36  public:
37  Frequency operator+(const Frequency& rhs) const;
38 
39  Frequency& operator+=(const Frequency& rhs);
40 
41  Frequency operator-(const Frequency& rhs) const;
42 
43  Frequency& operator-=(const Frequency& rhs);
44 
45  Frequency operator*(double rhs) const;
46 
47  Frequency operator*(int rhs) const;
48 
49  Frequency operator*(std::int64_t rhs) const;
50 
51  Frequency& operator*=(double rhs);
52 
53  Frequency& operator*=(int rhs);
54 
55  Frequency& operator*=(std::int64_t rhs);
56 
57  double operator/(const Frequency& rhs) const;
58 
59  Frequency operator/(double rhs) const;
60 
61  Frequency operator/(int rhs) const;
62 
63  Frequency operator/(std::int64_t rhs) const;
64 
65  Frequency& operator/=(double rhs);
66 
67  Frequency& operator/=(int rhs);
68 
69  Frequency& operator/=(std::int64_t rhs);
70 
71  bool operator<(const Frequency& rhs) const;
72 
73  bool operator<=(const Frequency& rhs) const;
74 
75  bool operator==(const Frequency& rhs) const;
76 
77  bool operator!=(const Frequency& rhs) const;
78 
79  bool operator>=(const Frequency& rhs) const;
80 
81  bool operator>(const Frequency& rhs) const;
82 
83  protected:
84  /**
85  * @brief Current cycle duration.
86  */
88  };
89 
90 
91  Frequency operator/(double cyclesPerDuration, const Duration& duration);
92 
93  Frequency operator/(int cyclesPerDuration, const Duration& duration);
94 
95  Frequency operator/(std::int64_t cyclesPerDuration, const Duration& duration);
96 
97 
98  std::ostream& operator<<(std::ostream& out, const Frequency& rhs);
99 
100 } // namespace armarx::core::time
101 
102 
103 namespace armarx
104 {
105  using core::time::Frequency;
106 } // namespace armarx
armarx::core::time::Frequency::operator!=
bool operator!=(const Frequency &rhs) const
Definition: Frequency.cpp:234
armarx::core::time::Frequency::operator>=
bool operator>=(const Frequency &rhs) const
Definition: Frequency.cpp:241
Duration.h
armarx::core::time
Definition: Clock.cpp:13
armarx::core::time::Frequency
Represents a frequency.
Definition: Frequency.h:17
armarx::core::time::Frequency::operator<
bool operator<(const Frequency &rhs) const
Definition: Frequency.cpp:213
armarx::core::time::Frequency::operator/
double operator/(const Frequency &rhs) const
Definition: Frequency.cpp:161
armarx::core::time::operator<<
std::ostream & operator<<(std::ostream &out, const DateTime &rhs)
Definition: DateTime.cpp:226
armarx::core::time::Frequency::_cycleDuration
Duration _cycleDuration
Current cycle duration.
Definition: Frequency.h:87
armarx::core::time::Frequency::operator>
bool operator>(const Frequency &rhs) const
Definition: Frequency.cpp:248
armarx::core::time::Frequency::toCycleDuration
Duration toCycleDuration() const
Definition: Frequency.cpp:67
armarx::core::time::Frequency::Frequency
Frequency(const Duration &cycleDuration)
Definition: Frequency.cpp:15
armarx::core::time::Frequency::operator<=
bool operator<=(const Frequency &rhs) const
Definition: Frequency.cpp:220
armarx::core::time::Frequency::HertzDouble
static Frequency HertzDouble(double hertz)
Definition: Frequency.cpp:34
armarx::core::time::Frequency::operator==
bool operator==(const Frequency &rhs) const
Definition: Frequency.cpp:227
armarx::core::time::Frequency::operator+=
Frequency & operator+=(const Frequency &rhs)
Definition: Frequency.cpp:93
armarx::core::time::Frequency::operator+
Frequency operator+(const Frequency &rhs) const
Definition: Frequency.cpp:86
armarx::core::time::Frequency::operator-
Frequency operator-(const Frequency &rhs) const
Definition: Frequency.cpp:101
armarx::core::time::Frequency::toHertz
std::int64_t toHertz() const
Definition: Frequency.cpp:45
armarx::core::time::Frequency::operator-=
Frequency & operator-=(const Frequency &rhs)
Definition: Frequency.cpp:108
armarx::core::time::Frequency::operator*
Frequency operator*(double rhs) const
Definition: Frequency.cpp:116
armarx::core::time::Duration
Represents a duration.
Definition: Duration.h:17
armarx::core::time::Frequency::Hertz
static Frequency Hertz(std::int64_t hertz)
Definition: Frequency.cpp:23
armarx::core::time::Frequency::operator*=
Frequency & operator*=(double rhs)
Definition: Frequency.cpp:137
armarx::core::time::Frequency::toHertzDouble
double toHertzDouble() const
Definition: Frequency.cpp:56
armarx::core::time::Frequency::toFrequencyString
std::string toFrequencyString() const
Definition: Frequency.cpp:74
armarx::core::time::Frequency::operator/=
Frequency & operator/=(double rhs)
Definition: Frequency.cpp:189
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::core::time::operator/
Frequency operator/(const double cyclesPerDuration, const Duration &duration)
Definition: Frequency.cpp:255