Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
selectionoperation.h
1/*
2** Copyright 2007-2018 RTE
3** Authors: Antares_Simulator Team
4**
5** This file is part of Antares_Simulator.
6**
7** Antares_Simulator is free software: you can redistribute it and/or modify
8** it under the terms of the GNU General Public License as published by
9** the Free Software Foundation, either version 3 of the License, or
10** (at your option) any later version.
11**
12** There are special exceptions to the terms and conditions of the
13** license as they are applied to this software. View the full text of
14** the exceptions in file COPYING.txt in the directory of this software
15** distribution
16**
17** Antares_Simulator is distributed in the hope that it will be useful,
18** but WITHOUT ANY WARRANTY; without even the implied warranty of
19** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20** GNU General Public License for more details.
21**
22** You should have received a copy of the GNU General Public License
23** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>.
24**
25** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions
26*/
27#ifndef __ANTARES_TOOLBOX_COMPONENT_DATAGRID_SELECTION_OPERATION_H__
28#define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_SELECTION_OPERATION_H__
29
30#include "wx-wrapper.h"
31#include <math.h>
32#include <limits>
33
34namespace Antares
35{
36namespace Component
37{
38namespace Datagrid
39{
40namespace Selection
41{
43{
44public:
45 IOperator()
46 {
47 }
48 virtual ~IOperator()
49 {
50 }
51
55 virtual const wxChar* caption() const = 0;
56
60 virtual void reset() = 0;
61
65 virtual void appendValue(const double v) = 0;
66
70 virtual double result() const = 0;
71
72}; // class IOperator
73
74class Average final : public IOperator
75{
76public:
77 Average() : pValue(0.), pCount(0)
78 {
79 }
80
81 virtual ~Average()
82 {
83 }
84
85 virtual const wxChar* caption() const
86 {
87 return wxT("Average");
88 }
89
90 virtual void reset()
91 {
92 pValue = 0.;
93 pCount = 0;
94 }
95
96 virtual void appendValue(const double v)
97 {
98 pValue += v;
99 ++pCount;
100 }
101
102 virtual double result() const
103 {
104 return pValue / (double)pCount;
105 }
106
107private:
108 double pValue;
109 uint pCount;
110
111}; // class Average
112
113class Sum final : public IOperator
114{
115public:
116 Sum() : pValue(0.)
117 {
118 }
119
120 virtual const wxChar* caption() const
121 {
122 return wxT("Sum");
123 }
124
125 virtual void reset()
126 {
127 pValue = 0.;
128 }
129
130 virtual void appendValue(const double v)
131 {
132 pValue += v;
133 }
134
135 virtual double result() const
136 {
137 return pValue;
138 }
139
140private:
141 double pValue;
142
143}; // class Sum
144
145class CellCount final : public IOperator
146{
147public:
148 CellCount() : pCount(0)
149 {
150 }
151
152 virtual const wxChar* caption() const
153 {
154 return wxT("Cell Count");
155 }
156
157 virtual void reset()
158 {
159 pCount = 0;
160 }
161
162 virtual void appendValue(const double)
163 {
164 ++pCount;
165 }
166
167 virtual double result() const
168 {
169 return (double)pCount;
170 }
171
172private:
173 uint pCount;
174
175}; // class Average
176
177class Minimum final : public IOperator
178{
179public:
180 Minimum() : pValue(std::numeric_limits<double>::infinity())
181 {
182 }
183
184 virtual const wxChar* caption() const
185 {
186 return wxT("Minimum");
187 }
188
189 virtual void reset()
190 {
191 pValue = std::numeric_limits<double>::infinity();
192 }
193
194 virtual void appendValue(const double v)
195 {
196 if (v < pValue)
197 pValue = v;
198 }
199
200 virtual double result() const
201 {
202 return pValue;
203 }
204
205private:
206 double pValue;
207
208}; // class Sum
209
210class Maximum final : public IOperator
211{
212public:
213 Maximum() : pValue(-std::numeric_limits<double>::infinity())
214 {
215 }
216
217 virtual const wxChar* caption() const
218 {
219 return wxT("Maximum");
220 }
221 virtual void reset()
222 {
223 pValue = -std::numeric_limits<double>::infinity();
224 }
225
226 virtual void appendValue(const double v)
227 {
228 if (v > pValue)
229 pValue = v;
230 }
231
232 virtual double result() const
233 {
234 return pValue;
235 }
236
237private:
238 double pValue;
239
240}; // class Sum
241
242} // namespace Selection
243} // namespace Datagrid
244} // namespace Component
245} // namespace Antares
246
247#endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_SELECTION_OPERATION_H__
Definition selectionoperation.h:75
virtual const wxChar * caption() const
Caption of the operator.
Definition selectionoperation.h:85
virtual void reset()
Reset all internal values.
Definition selectionoperation.h:90
virtual double result() const
Get the result.
Definition selectionoperation.h:102
virtual void appendValue(const double v)
Manage a new value.
Definition selectionoperation.h:96
Definition selectionoperation.h:146
virtual void appendValue(const double)
Manage a new value.
Definition selectionoperation.h:162
virtual void reset()
Reset all internal values.
Definition selectionoperation.h:157
virtual double result() const
Get the result.
Definition selectionoperation.h:167
virtual const wxChar * caption() const
Caption of the operator.
Definition selectionoperation.h:152
Definition selectionoperation.h:43
virtual void reset()=0
Reset all internal values.
virtual void appendValue(const double v)=0
Manage a new value.
virtual const wxChar * caption() const =0
Caption of the operator.
virtual double result() const =0
Get the result.
Definition selectionoperation.h:211
virtual const wxChar * caption() const
Caption of the operator.
Definition selectionoperation.h:217
virtual double result() const
Get the result.
Definition selectionoperation.h:232
virtual void reset()
Reset all internal values.
Definition selectionoperation.h:221
virtual void appendValue(const double v)
Manage a new value.
Definition selectionoperation.h:226
Definition selectionoperation.h:178
virtual void reset()
Reset all internal values.
Definition selectionoperation.h:189
virtual const wxChar * caption() const
Caption of the operator.
Definition selectionoperation.h:184
virtual void appendValue(const double v)
Manage a new value.
Definition selectionoperation.h:194
virtual double result() const
Get the result.
Definition selectionoperation.h:200
Definition selectionoperation.h:114
virtual double result() const
Get the result.
Definition selectionoperation.h:135
virtual void appendValue(const double v)
Manage a new value.
Definition selectionoperation.h:130
virtual const wxChar * caption() const
Caption of the operator.
Definition selectionoperation.h:120
virtual void reset()
Reset all internal values.
Definition selectionoperation.h:125