Gazebo Math

API Reference

7.5.1
gz/math/SignalStats.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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_SIGNALSTATS_HH_
18 #define GZ_MATH_SIGNALSTATS_HH_
19 
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <gz/math/Helpers.hh>
24 #include <gz/math/config.hh>
25 
26 namespace gz::math
27 {
28  // Inline bracket to help doxygen filtering.
29  inline namespace GZ_MATH_VERSION_NAMESPACE {
30  //
32  class SignalStatisticPrivate;
33 
36  class GZ_MATH_VISIBLE SignalStatistic
37  {
39  public: SignalStatistic();
40 
42  public: virtual ~SignalStatistic();
43 
46  public: SignalStatistic(const SignalStatistic &_ss);
47 
50  public: virtual double Value() const = 0;
51 
54  public: virtual std::string ShortName() const = 0;
55 
58  public: virtual size_t Count() const;
59 
62  public: virtual void InsertData(const double _data) = 0;
63 
65  public: virtual void Reset();
66 
67 #ifdef _WIN32
68 // Disable warning C4251 which is triggered by
69 // std::unique_ptr
70 #pragma warning(push)
71 #pragma warning(disable: 4251)
72 #endif
75 #ifdef _WIN32
76 #pragma warning(pop)
77 #endif
78  };
79 
82  class GZ_MATH_VISIBLE SignalMaximum : public SignalStatistic
83  {
84  // Documentation inherited.
85  public: virtual double Value() const override;
86 
89  public: virtual std::string ShortName() const override;
90 
91  // Documentation inherited.
92  public: virtual void InsertData(const double _data) override;
93  };
94 
97  class GZ_MATH_VISIBLE SignalMean : public SignalStatistic
98  {
99  // Documentation inherited.
100  public: virtual double Value() const override;
101 
104  public: virtual std::string ShortName() const override;
105 
106  // Documentation inherited.
107  public: virtual void InsertData(const double _data) override;
108  };
109 
112  class GZ_MATH_VISIBLE SignalMinimum : public SignalStatistic
113  {
114  // Documentation inherited.
115  public: virtual double Value() const override;
116 
119  public: virtual std::string ShortName() const override;
120 
121  // Documentation inherited.
122  public: virtual void InsertData(const double _data) override;
123  };
124 
128  class GZ_MATH_VISIBLE SignalRootMeanSquare : public SignalStatistic
129  {
130  // Documentation inherited.
131  public: virtual double Value() const override;
132 
135  public: virtual std::string ShortName() const override;
136 
137  // Documentation inherited.
138  public: virtual void InsertData(const double _data) override;
139  };
140 
146  class GZ_MATH_VISIBLE SignalMaxAbsoluteValue : public SignalStatistic
147  {
148  // Documentation inherited.
149  public: virtual double Value() const override;
150 
153  public: virtual std::string ShortName() const override;
154 
155  // Documentation inherited.
156  public: virtual void InsertData(const double _data) override;
157  };
158 
162  class GZ_MATH_VISIBLE SignalVariance : public SignalStatistic
163  {
164  // Documentation inherited.
165  public: virtual double Value() const override;
166 
169  public: virtual std::string ShortName() const override;
170 
171  // Documentation inherited.
172  public: virtual void InsertData(const double _data) override;
173  };
174 
176  class SignalStatsPrivate;
177 
180  class GZ_MATH_VISIBLE SignalStats
181  {
183  public: SignalStats();
184 
186  public: ~SignalStats();
187 
190  public: SignalStats(const SignalStats &_ss);
191 
197  public: size_t Count() const;
198 
204 
207  public: void InsertData(const double _data);
208 
218  public: bool InsertStatistic(const std::string &_name);
219 
227  public: bool InsertStatistics(const std::string &_names);
228 
230  public: void Reset();
231 
235  public: SignalStats &operator=(const SignalStats &_s);
236 
237 #ifdef _WIN32
238 // Disable warning C4251 which is triggered by
239 // std::unique_ptr
240 #pragma warning(push)
241 #pragma warning(disable: 4251)
242 #endif
244  private: std::unique_ptr<SignalStatsPrivate> dataPtr;
245 #ifdef _WIN32
246 #pragma warning(pop)
247 #endif
248  };
249  } // namespace GZ_MATH_VERSION_NAMESPACE
250 } // namespace gz::math
251 #endif // GZ_MATH_SIGNALSTATS_HH_