Antares Simulator
Power System Simulator
weekday.h
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 #ifndef __ANTARES_TOOLBOX_COMPONENTS_DATAGRID_FILTER_ALL_WEEKDAY_H__
22 #define __ANTARES_TOOLBOX_COMPONENTS_DATAGRID_FILTER_ALL_WEEKDAY_H__
23 
24 #include "../filter.h"
25 #include <antares/date/date.h>
26 #include <antares/study/study.h>
27 #include "application/study.h"
28 
29 namespace Antares::Toolbox::Filter
30 {
31 class Weekday: public AFilterBase
32 {
33 public:
34  static const wxChar* Name()
35  {
36  return wxT("weekday");
37  }
38 
39  static const wxChar* Caption()
40  {
41  return wxT("WeekDay");
42  }
43 
44  static Date::Precision Precision()
45  {
46  return Date::daily;
47  }
48 
49 public:
50  Weekday(Input* parent):
51  AFilterBase(parent)
52  {
53  operators.addStdWeekday();
54  }
55 
56  virtual ~Weekday()
57  {
58  }
59 
60  virtual Date::Precision precision() const
61  {
62  return Weekday::Precision();
63  }
64 
65  virtual bool checkOnRowsLabels() const
66  {
67  return true;
68  }
69 
70  virtual const wxChar* name() const
71  {
72  return Weekday::Name();
73  }
74 
75  virtual const wxChar* caption() const
76  {
77  return Weekday::Caption();
78  }
79 
80  virtual bool rowIsValid(int row) const
81  {
82  // TODO Do not use global study
83  auto studyptr = GetCurrentStudy();
84  if (!studyptr)
85  {
86  return false;
87  }
88  auto& study = *studyptr;
89  auto& calendar = study.calendar;
90 
91  switch (pDataGridPrecision)
92  {
93  case Date::hourly:
94  {
95  if (row < study.calendar.maxHoursInYear)
96  {
97  uint w = calendar.hours[row].weekday;
98  return currentOperator->compute((int)w);
99  }
100  break;
101  }
102  case Date::daily:
103  {
104  if (row < study.calendar.maxDaysInYear)
105  {
106  uint w = calendar.days[row].weekday;
107  return currentOperator->compute((int)w);
108  }
109  break;
110  }
111  default:
112  break;
113  }
114  return false;
115  }
116 
117 }; // class HourYear
118 
119 } // namespace Antares::Toolbox::Filter
120 
121 #endif // __ANTARES_TOOLBOX_COMPONENTS_DATAGRID_FILTER_ALL_WEEKDAY_H__
Abstract Filter.
Definition: filter.h:48
Operator::AOperator * currentOperator
The current selected operator for the filter.
Definition: filter.h:198
Date::Precision pDataGridPrecision
Precision.
Definition: filter.h:202
Operator::List operators
List of all possible operations for the filter.
Definition: filter.h:196
AFilterBase(Input *parent)
Default constructor.
Definition: filter.cpp:34
Definition: input.h:34
Definition: weekday.h:32
virtual const wxChar * caption() const
Get the caption of the filter.
Definition: weekday.h:75
virtual const wxChar * name() const
Get the name of the filter.
Definition: weekday.h:70