Antares Simulator
Power System Simulator
header.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_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 
39 namespace Antares::Data
40 {
45 class StudyHeader final
46 {
47 public:
54  static bool readVersionFromFile(const std::filesystem::path& filename, std::string& version);
55 
57 
58 
62  {
63  reset();
64  }
65 
69  ~StudyHeader() = default;
71 
75  void reset();
76 
84  bool loadFromFile(const std::filesystem::path& filename, bool warnings = true);
85 
95  bool saveToFile(const AnyString& filename, bool upgradeVersion = true);
96 
98  void CopySettingsToIni(IniFile& ini, bool upgradeVersion);
99 
107  static StudyVersion tryToFindTheVersion(const std::string& folder);
108 
109  bool validateVersion();
110 
112  Yuni::String caption;
113 
116 
118  time_t dateCreated;
120  time_t dateLastSave;
121 
123  Yuni::String author;
124  Yuni::String editor;
125 
126 private:
128  bool internalLoadFromINIFile(const IniFile& ini, bool warnings);
129 
131  static bool internalFindVersionFromFile(const IniFile& ini, std::string& version);
132 
133 }; // class StudyHeader;
134 
135 } // namespace Antares::Data
136 
137 #endif /* __ANTARES_LIBS_STUDY_HEADER_H__ */
Header of a study.
Definition: header.h:46
StudyHeader()
Default constructor.
Definition: header.h:61
Yuni::String author
Author.
Definition: header.h:123
Yuni::String caption
Caption of the study.
Definition: header.h:112
void CopySettingsToIni(IniFile &ini, bool upgradeVersion)
Copy the internal settings into an INI structure.
Definition: header.cpp:65
bool loadFromFile(const std::filesystem::path &filename, bool warnings=true)
Load a study header from a file.
Definition: header.cpp:190
static bool readVersionFromFile(const std::filesystem::path &filename, std::string &version)
Get the version of a header.
Definition: header.cpp:238
time_t dateCreated
Date: Creation (timestamp)
Definition: header.h:118
~StudyHeader()=default
Destructor.
bool saveToFile(const AnyString &filename, bool upgradeVersion=true)
Save a study header into a file.
Definition: header.cpp:200
time_t dateLastSave
Date: Last save (timestamp)
Definition: header.h:120
void reset()
Reset the values.
Definition: header.cpp:49
StudyVersion version
Format version.
Definition: header.h:115
static StudyVersion tryToFindTheVersion(const std::string &folder)
Try to determine the version of a study.
Definition: header.cpp:207
Version of a study.
Definition: version.h:36
Data for an INI file.
Definition: inifile.h:34