Antares Simulator
Power System Simulator
logfile.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_TOOLBOX_COMPONENT_DATAGRID_RENDERER_MC_PLAYLIST_H__
22 #define __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_MC_PLAYLIST_H__
23 
24 #include "../renderer.h"
25 #include "../../../../application/study.h"
26 #include <memory>
27 #include <vector>
28 
29 namespace Antares::Component::Datagrid::Renderer
30 {
31 class LogEntry
32 {
33 public:
35  using Vector = std::vector<LogEntry*>;
36 
39  {
40  vtInfo,
41  vtNotice,
42  vtCheckpoint,
43  vtWarning,
44  vtError,
45  vtDebug
46  };
47 
48 public:
49  LogEntry();
50 
51  bool isWarningError() const
52  {
53  return (verbosityType == vtWarning || verbosityType == vtError);
54  }
55 
56  void assignVerbosity(const AnyString& pS);
57 
58 public:
62  uint line;
63  // The most of the time, we will prefer customstring to consume less
64  // memory for large logfiles
66  Yuni::CString<32, false> date;
68  Yuni::CString<32, false> application;
70  Yuni::CString<16, false> verbosity;
72  wxString message;
74  bool highlight;
75 };
76 
78 {
79 public:
81  using Ptr = std::shared_ptr<LogEntryContainer>;
82 
83 public:
85  longestLine(0),
87  {
88  }
89 
91 
92 public:
94  YString filename;
96  YString barefilename;
98  uint lines;
100  uint64_t size;
107 };
108 
109 class LogFile: public IRenderer
110 {
111 public:
112  LogFile();
113  virtual ~LogFile();
114 
115  virtual int width() const
116  {
117  return 3;
118  }
119 
120  virtual int height() const;
121 
122  virtual wxString columnCaption(int colIndx) const;
123 
124  virtual wxString rowCaption(int rowIndx) const;
125 
126  virtual wxString cellValue(int x, int y) const;
127 
128  virtual double cellNumericValue(int x, int y) const;
129 
130  virtual bool cellValue(int x, int y, const Yuni::String& value);
131 
132  virtual void resetColors(int, int, wxColour&, wxColour&) const
133  {
134  // Do nothing
135  }
136 
137  virtual bool valid() const
138  {
139  return !(!logs);
140  }
141 
142  virtual uint maxWidthResize() const
143  {
144  return 0;
145  }
146 
147  virtual IRenderer::CellStyle cellStyle(int col, int row) const;
148 
149  virtual wxColour cellBackgroundColor(int, int) const;
150  virtual wxColour cellTextColor(int, int) const;
151 
152  virtual wxColour verticalBorderColor(int x, int y) const;
153 
154  void control(wxWindow* control)
155  {
156  pControl = control;
157  }
158 
159  virtual int cellAlignment(int x, int y) const;
160 
161  virtual int columnWidthCustom(int x) const;
162 
163  virtual void hintForColumnWidth(int x, wxString& out) const;
164 
165 public:
168 
169 protected:
170  wxWindow* pControl;
171 
172 }; // class LogFile
173 
174 } // namespace Antares::Component::Datagrid::Renderer
175 
176 #endif // __ANTARES_TOOLBOX_COMPONENT_DATAGRID_RENDERER_MC_PLAYLIST_H__
Data provider for Datagrids.
Definition: renderer.h:50
YString filename
Full filename.
Definition: logfile.h:94
uint lines
The total number of lines.
Definition: logfile.h:98
uint longestLine
The longest line.
Definition: logfile.h:104
uint64_t size
Size.
Definition: logfile.h:100
std::shared_ptr< LogEntryContainer > Ptr
The most suitable smart pointer for the class.
Definition: logfile.h:81
YString barefilename
The bare filename.
Definition: logfile.h:96
LogEntry::Vector entries
All entries.
Definition: logfile.h:102
uint maxCharForALine
The maximum number of char found for a single line.
Definition: logfile.h:106
Yuni::CString< 32, false > application
Application.
Definition: logfile.h:68
wxString message
The message itself.
Definition: logfile.h:72
Yuni::CString< 32, false > date
Date.
Definition: logfile.h:66
bool highlight
Highlight.
Definition: logfile.h:74
Yuni::CString< 16, false > verbosity
Verbosity.
Definition: logfile.h:70
VerbosityType
Verbosity type.
Definition: logfile.h:39
uint line
Line in the file.
Definition: logfile.h:62
std::vector< LogEntry * > Vector
Vector of log entries.
Definition: logfile.h:35
VerbosityType verbosityType
Type of the verbosity.
Definition: logfile.h:60
virtual int cellAlignment(int x, int y) const
Get the alignment of a cell (-1: left, 0: center, +1: right)
Definition: logfile.cpp:241
virtual wxString rowCaption(int rowIndx) const
Get the caption of a row.
Definition: logfile.cpp:124
virtual wxString cellValue(int x, int y) const
Get the string representation of a Cell.
Definition: logfile.cpp:147
virtual wxString columnCaption(int colIndx) const
Get the caption of a column.
Definition: logfile.cpp:109
virtual void hintForColumnWidth(int x, wxString &out) const
String to use.
Definition: logfile.cpp:257
virtual int width() const
The effective width of the grid.
Definition: logfile.h:115
virtual int columnWidthCustom(int x) const
Get how the a column must resize (0: auto, >0: specific width, <0: use custom string)
Definition: logfile.cpp:246
virtual double cellNumericValue(int x, int y) const
Get the floating value of a Cell.
Definition: logfile.cpp:142
LogEntryContainer::Ptr logs
Logs.
Definition: logfile.h:167
virtual wxColour verticalBorderColor(int x, int y) const
Get the color of the vertical right border.
Definition: logfile.cpp:223
virtual int height() const
The effective height of the grid.
Definition: logfile.cpp:104
virtual uint maxWidthResize() const
The most suitable column count.
Definition: logfile.h:142