CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsFlags.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
31 
32 #include <fstream>
33 #include <iostream>
34 #include <sstream>
35 #include <source_location>
36 
39 
53 class Flags : public CepsObject
54 {
55 
56  public:
57 
58  Flags() = delete;
59 
61  Flags(int argc, CepsChar **argv);
62 
64  Flags(Flags& that) = delete;
65 
67  ~Flags();
68 
70  Flags&
71  operator=(Flags& that) = delete;
72 
74  void
76 
78  void
79  enableDebug();
80 
82  void
84 
86  void
87  enableTesting();
88 
90  void
92 
94  void
96 
98  void
100 
102  CepsBool
103  profiling() const;
104 
106  CepsBool
107  testing() const;
108 
110  CepsBool
111  verbose() const;
112 
114  CepsBool
115  warnings() const;
116 
118  void
119  printHelp(CepsChar** argv);
120 
122  CepsString
123  getDebugLogName() const;
124 
126  CepsString
127  getProfilingLogName() const;
128 
130  std::ofstream&
131  getDebugLog();
132 
134  std::ofstream&
135  getProfilingLog();
136 
137 
138  private:
139 
144 
146  std::ofstream m_debugLog;
148  std::ofstream m_profilingLog;
149 
150 };
151 
153 extern Flags *flags;
154 
156 namespace ceps
157 {
163  std::ofstream&
164  debugLog();
165 
171  std::ofstream&
172  profilingLog();
173 
180  CepsBool
181  isProfiling();
182 
189  CepsBool
190  isVerbose();
191 
198  CepsBool
199  isWarnings();
200 
207  CepsBool
208  isDebug();
209 
211  void
213 
215  void
217 
218 
219 
220 } // namespace ceps
Flags * flags
Global variable, used in every application.
Definition: ceps.cpp:34
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
char CepsChar
Char.
Definition: CepsTypes.hpp:125
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
Base class for other (big) CEPS classes. All classes can get a pointer to this base class and also co...
Definition: CepsObject.hpp:40
Management of run options.
Definition: CepsFlags.hpp:54
std::ofstream m_debugLog
Debug file stream (opened in init, closed at finalize)
Definition: CepsFlags.hpp:146
void enableProfiling()
Activates profiling, opens profiling log stream.
Definition: CepsFlags.cpp:108
CepsBool m_testing
Used for unit tests.
Definition: CepsFlags.hpp:143
void disableWarnings()
Disables warning messages.
Definition: CepsFlags.cpp:150
Flags(Flags &that)=delete
Copy construction. Deleted. Flags should not be copied.
CepsBool warnings() const
True if option -w was set in command line.
Definition: CepsFlags.cpp:201
std::ofstream & getDebugLog()
the Log stream
Definition: CepsFlags.cpp:233
CepsBool testing() const
Tells if currently running in a test suite (switched in CepsGlobalFixture.hpp)
Definition: CepsFlags.cpp:189
CepsString m_profilingLogName
Profiling file name.
Definition: CepsFlags.hpp:147
CepsString getDebugLogName() const
Name has the form debug_PID.log (PID of master node)
Definition: CepsFlags.cpp:221
std::ofstream m_profilingLog
Profiling file stream (opened in init, closed at finalize)
Definition: CepsFlags.hpp:148
std::ofstream & getProfilingLog()
The Profiling stream.
Definition: CepsFlags.cpp:239
void disableTesting()
Disables testing (CepsException for errors now cause abort)
Definition: CepsFlags.cpp:138
CepsBool verbose() const
True if option -d was set in command line.
Definition: CepsFlags.cpp:195
void printHelp(CepsChar **argv)
Display info on how to type in command line.
Definition: CepsFlags.cpp:207
CepsString m_debugLogName
Debug file name.
Definition: CepsFlags.hpp:145
CepsBool m_verbose
Blah blah if true.
Definition: CepsFlags.hpp:141
CepsString getProfilingLogName() const
Name has the form profiling_PID.log (PID of master node)
Definition: CepsFlags.cpp:227
void enableTesting()
Enables testing (CepsException for errors do not cause abort)
Definition: CepsFlags.cpp:132
Flags()=delete
CepsBool m_warnings
More blah blah if true.
Definition: CepsFlags.hpp:142
CepsBool m_profiling
Profiling option.
Definition: CepsFlags.hpp:140
CepsBool profiling() const
True if option -p was set in command line.
Definition: CepsFlags.cpp:183
~Flags()
If needed closes the logs with current time.
Definition: CepsFlags.cpp:155
void enableDebug()
Activates profiling, opens debug log stream.
Definition: CepsFlags.cpp:85
void enableWarnings()
Enables warning messages.
Definition: CepsFlags.cpp:144
Flags & operator=(Flags &that)=delete
Assignment operator. Deleted, flags should not be copied.
void setVerbose(CepsBool v)
Enable/disable verbosity.
Definition: CepsFlags.cpp:79
A namespace for all utility methods.
CepsBool isVerbose()
Check if the verbosity is enabled on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:263
std::ofstream & debugLog()
Get the DebugLog used in Ceps.
Definition: CepsFlags.cpp:245
CepsBool isWarnings()
Check if we enable the warnings on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:269
CepsBool isDebug()
Check if we enable the debug on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:275
std::ofstream & profilingLog()
Get the ProfilingLog used in Ceps.
Definition: CepsFlags.cpp:251
void disableAbortOnError()
Set testing to true. Exceptions do not terminate program.
Definition: CepsFlags.cpp:285
void enableAbortOnError()
Set testing to false. Exceptions terminate program.
Definition: CepsFlags.cpp:291
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:257