Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
jit.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_JIT_JIT_H__
22#define __ANTARES_LIBS_JIT_JIT_H__
23
24#include <yuni/core/fwd.h>
25#include <yuni/core/string/string.h>
26
27namespace Antares
28{
29template<class T, class ReadWriteT>
30class Matrix;
31}
32
33class JIT final
34{
35public:
36 // Forward declaration
37 class Informations;
38
42 static Informations* Reset(Informations* jit, const AnyString& filename);
43
47 static Informations* Reset(Informations* jit);
48
52 static void MarkAsNotLoaded(Informations* j);
53
57 static void Invalidate(Informations* j);
58
62 static bool IsReady(Informations* j);
63
64public:
66 {
67 public:
68 just_in_time_manager(JIT::Informations* jit, const AnyString filename):
69 jit_(jit),
70 file_name_(filename)
71 {
72 }
73
74 void record_current_jit_state(unsigned width, unsigned height);
75
76 inline JIT::Informations* jit_recorded_state()
77 {
78 return jit_record_;
79 }
80
81 bool matrix_content_in_memory_is_same_as_on_disk()
82 {
83 return not jit_->modified;
84 }
85
86 bool jit_activated()
87 {
88 return jit_;
89 }
90
91 bool do_we_force_matrix_load_from_disk();
92
93 template<class T, class ReadWriteT>
94 void load_matrix(const Antares::Matrix<T, ReadWriteT>* mtx);
95
96 template<class T, class ReadWriteT>
97 void clear_matrix(const Antares::Matrix<T, ReadWriteT>* mtx);
98
99 template<class T, class ReadWriteT>
100 void unload_matrix_properly_from_memory(const Antares::Matrix<T, ReadWriteT>* mtx);
101
103 {
104 delete jit_record_;
105 }
106
107 private:
108 JIT::Informations* jit_;
109 JIT::Informations* jit_record_;
110 AnyString file_name_;
111 };
112
113public:
117 class Informations final
118 {
119 public:
121
122
125 Informations();
127 Informations(const Informations& rhs);
131
135 void markAsModified();
136
137 public:
140
146 // The item will be considered as modified
148
150 unsigned options;
156 unsigned minWidth;
162 unsigned maxHeight;
163
165 unsigned estimatedSize[2];
166
169
170 }; // class Informations
171
172public:
179 static bool enabled;
180
184 static bool usedFromGUI;
185
186}; // class JIT
187
188#include "jit.hxx"
189
190#endif // __ANTARES_LIBS_JIT_JIT_H__
A n-by-n matrix.
Definition jit.h:30
Definition jit.h:118
bool modified
Flag to determine wheter if the associated data have already been modified.
Definition jit.h:144
Informations()
Default constructor.
Definition jit.cpp:32
bool loadDataIfNotAlreadyDone
Flag to determine wheter if the associated data have already been reload.
Definition jit.h:147
int64_t lastModification
Timestamp of the last modification.
Definition jit.h:168
unsigned options
The option to the matrix.
Definition jit.h:150
~Informations()
Destructor.
Definition jit.cpp:58
bool alreadyLoaded
Flag to determine wheter if the associated data have already been loaded.
Definition jit.h:142
unsigned minWidth
Minimum width expected (for Matrices)
Definition jit.h:156
unsigned maxHeight
Minimum height expected (for Matrices)
Definition jit.h:162
YString sourceFilename
Filename/folder to consider if some data should be loaded.
Definition jit.h:139
void markAsModified()
Mark the associated data as modified.
Definition jit.hxx:33
unsigned estimatedSize[2]
The estimated number of columns and rows.
Definition jit.h:165
Definition jit.h:66
Definition jit.h:34
static Informations * Reset(Informations *jit, const AnyString &filename)
Reset the source filename.
Definition jit.cpp:80
static bool IsReady(Informations *j)
Get if the data has been loaded.
Definition jit.hxx:28
static void Invalidate(Informations *j)
Mark the attached object as modified.
Definition jit.cpp:110
static bool enabled
Flag to enable/disable JIT informations.
Definition jit.h:179
static void MarkAsNotLoaded(Informations *j)
Mark the attached object as not loaded.
Definition jit.cpp:101
static bool usedFromGUI
Flag to know if the library is called from the User interface.
Definition jit.h:184