Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
sets.hxx
1/*
2** Copyright 2007-2024, 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_HXX__
22#define __LIBS_STUDY_SCENARIO_BUILDER_SETS_HXX__
23
24namespace Antares
25{
26namespace Data
27{
28namespace ScenarioBuilder
29{
30inline uint Sets::size() const
31{
32 return (uint)pMap.size();
33}
34
35inline bool Sets::empty() const
36{
37 return pMap.empty();
38}
39
40inline Sets::iterator Sets::begin()
41{
42 return pMap.begin();
43}
44
45inline Sets::const_iterator Sets::begin() const
46{
47 return pMap.begin();
48}
49
50inline Sets::iterator Sets::end()
51{
52 return pMap.end();
53}
54
55inline Sets::const_iterator Sets::end() const
56{
57 return pMap.end();
58}
59
60inline bool Sets::exists(const RulesScenarioName& lname) const
61{
62 return pMap.find(lname) != pMap.end();
63}
64
65inline Rules::Ptr Sets::find(const RulesScenarioName& lname) const
66{
67 using namespace Yuni;
68 const_iterator i = pMap.find(lname);
69 if (i != pMap.end())
70 {
71 return i->second;
72 }
73 return nullptr;
74}
75
76template<class StringT>
77inline bool Sets::saveToINIFile(const StringT& filename)
78{
79 const AnyString adapter(filename);
80 return internalSaveToIniFile(adapter);
81}
82
83template<class StringT>
84bool Sets::loadFromINIFile(const StringT& filename)
85{
86 // If the source code below is changed, please change it in loadFromStudy too
87 const AnyString adapter(filename);
88 bool r = internalLoadFromINIFile(adapter);
89 if (!r)
90 {
91 pMap.clear();
92 }
93 if (pMap.empty())
94 {
95 createNew("Default Ruleset");
96 }
97 return r;
98}
99
100} // namespace ScenarioBuilder
101} // namespace Data
102} // namespace Antares
103
104#endif // __LIBS_STUDY_SCENARIO_BUILDER_SETS_H__
std::shared_ptr< Rules > Ptr
Smart pointer.
Definition rules.h:55
Rules::Ptr createNew(const RulesScenarioName &name)
Create a new set.
Definition sets.cpp:83
bool empty() const
Get if empty.
Definition sets.hxx:35
bool saveToINIFile(const StringT &filename)
Save all rulesets into a mere INI file.
Definition sets.hxx:77
bool loadFromINIFile(const StringT &filename)
Load all rulesets from an INI file.
Definition sets.hxx:84
Rules::Map::iterator iterator
Iterator.
Definition sets.h:41
Rules::Ptr find(const RulesScenarioName &lname) const
Find a rule set.
Definition sets.hxx:65
bool exists(const RulesScenarioName &lname) const
Test if a rules set exist.
Definition sets.hxx:60
Rules::Map::const_iterator const_iterator
Const iterator.
Definition sets.h:43
uint size() const
Get the number of available sets.
Definition sets.hxx:30
MapType::const_iterator const_iterator
Standard iterators from the STL (const)
Definition sets.h:58