Antares Simulator
Power System Simulator
sets.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 __LIBS_STUDY_SCENARIO_BUILDER_SETS_H__
22 #define __LIBS_STUDY_SCENARIO_BUILDER_SETS_H__
23 
24 #include <yuni/yuni.h>
25 
26 #include "rules.h"
27 
28 namespace Antares::Data::ScenarioBuilder
29 {
33 class Sets final: private Yuni::NonCopyable<Sets>
34 {
35 public:
37  using iterator = Rules::Map::iterator;
39  using const_iterator = Rules::Map::const_iterator;
40 
41 public:
45 
46 public:
48 
49 
54  Sets();
56  ~Sets();
58 
59  void setStudy(Study& study);
60 
62 
63 
66  bool loadFromStudy(Study& study);
67 
71  void clear();
72 
76  template<class StringT>
77  bool loadFromINIFile(const StringT& filename);
78 
79 #ifdef BUILD_UI
83  template<class StringT>
84  bool saveToINIFile(const StringT& filename);
86 #endif
87 
89 
90 
95  Rules::Ptr createNew(const RulesScenarioName& name);
96 
102  bool exists(const RulesScenarioName& lname) const;
103 
107  Rules::Ptr find(const RulesScenarioName& lname) const;
108 
114  Rules::Ptr rename(const RulesScenarioName& lname, const RulesScenarioName& newname);
115 
121  bool remove(const RulesScenarioName& lname);
122 
123  iterator begin();
124  const_iterator begin() const;
125 
126  iterator end();
127  const_iterator end() const;
128 
132  uint size() const;
133 
137  bool empty() const;
139 
140 private:
142  bool internalLoadFromINIFile(const AnyString& filename);
143 #ifdef BUILD_UI
145  bool internalSaveToIniFile(const AnyString& filename) const;
146 #endif
147 
148 private:
150  Rules::Map pMap;
152  Study* pStudy;
153 }; // class Sets
154 
155 } // namespace Antares::Data::ScenarioBuilder
156 
157 #include "sets.hxx"
158 
159 #endif // __LIBS_STUDY_SCENARIO_BUILDER_SETS_H__
std::map< RulesScenarioName, Ptr > Map
Map.
Definition: rules.h:55
std::shared_ptr< Rules > Ptr
Smart pointer.
Definition: rules.h:53
Sets for TS numbers, for all years and a single timeseries.
Definition: sets.h:34
Rules::Ptr rename(const RulesScenarioName &lname, const RulesScenarioName &newname)
Rename a given ruleset.
Definition: sets.cpp:103
Rules::Ptr createNew(const RulesScenarioName &name)
Create a new set.
Definition: sets.cpp:83
Sets()
Default constructor.
Definition: sets.cpp:31
bool empty() const
Get if empty.
Definition: sets.hxx:31
bool remove(const RulesScenarioName &lname)
Delete a ruleset.
Definition: sets.cpp:129
bool loadFromINIFile(const StringT &filename)
Load all rulesets from an INI file.
Definition: sets.hxx:82
void clear()
Clear all data.
Definition: sets.cpp:47
bool inUpdaterMode
Definition: sets.h:44
Rules::Map::iterator iterator
Iterator.
Definition: sets.h:37
bool loadFromStudy(Study &study)
Load data from the study.
Definition: sets.cpp:53
Rules::Ptr find(const RulesScenarioName &lname) const
Find a rule set.
Definition: sets.hxx:61
bool exists(const RulesScenarioName &lname) const
Test if a rules set exist.
Definition: sets.hxx:56
~Sets()
Destructor.
Definition: sets.cpp:37
Rules::Map::const_iterator const_iterator
Const iterator.
Definition: sets.h:39
uint size() const
Get the number of available sets.
Definition: sets.hxx:26
Definition: study.h:57