Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
header.h
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 __ANTARES_LIBS_STUDY_HEADER_H__
22#define __ANTARES_LIBS_STUDY_HEADER_H__
23
24#include <ctime>
25#include <filesystem>
26
27#include <yuni/yuni.h>
28#include <yuni/core/string.h>
29
30#include <antares/inifile/inifile.h>
31
32#include "version.h"
33
35#define STUDYHEADER_DEFAULT_AUTHOR "Unknown"
37#define STUDYHEADER_DEFAULT_CAPTION "No title"
38
39namespace Antares
40{
41namespace Data
42{
47class StudyHeader final
48{
49public:
56 static bool readVersionFromFile(const std::filesystem::path& filename, std::string& version);
57
59
60
64 {
65 reset();
66 }
67
71 ~StudyHeader() = default;
73
77 void reset();
78
86 bool loadFromFile(const std::filesystem::path& filename, bool warnings = true);
87
97 bool saveToFile(const AnyString& filename, bool upgradeVersion = true);
98
100 void CopySettingsToIni(IniFile& ini, bool upgradeVersion);
101
109 static StudyVersion tryToFindTheVersion(const std::string& folder);
110
111 bool validateVersion();
112
114 Yuni::String caption;
115
118
123
125 Yuni::String author;
126
127private:
129 bool internalLoadFromINIFile(const IniFile& ini, bool warnings);
130
132 static bool internalFindVersionFromFile(const IniFile& ini, std::string& version);
133
134}; // class StudyHeader;
135
136} // namespace Data
137} // namespace Antares
138
139#endif /* __ANTARES_LIBS_STUDY_HEADER_H__ */
Header of a study.
Definition header.h:48
StudyHeader()
Default constructor.
Definition header.h:63
Yuni::String author
Author.
Definition header.h:125
Yuni::String caption
Caption of the study.
Definition header.h:114
void CopySettingsToIni(IniFile &ini, bool upgradeVersion)
Copy the internal settings into an INI structure.
Definition header.cpp:60
bool loadFromFile(const std::filesystem::path &filename, bool warnings=true)
Load a study header from a file.
Definition header.cpp:182
static bool readVersionFromFile(const std::filesystem::path &filename, std::string &version)
Get the version of a header.
Definition header.cpp:230
time_t dateCreated
Date: Creation (timestamp)
Definition header.h:120
~StudyHeader()=default
Destructor.
bool saveToFile(const AnyString &filename, bool upgradeVersion=true)
Save a study header into a file.
Definition header.cpp:192
time_t dateLastSave
Date: Last save (timestamp)
Definition header.h:122
void reset()
Reset the values.
Definition header.cpp:47
StudyVersion version
Format version.
Definition header.h:117
static StudyVersion tryToFindTheVersion(const std::string &folder)
Try to determine the version of a study.
Definition header.cpp:199
Version of a study.
Definition version.h:36
Data for an INI file.
Definition inifile.h:34