CEPS  24.01
Cardiac ElectroPhysiology Simulator
CepsIoMacros.hpp File Reference

Go to the source code of this file.

Macros

#define NOARG
 Dummy macro. More...
 
#define CEPS_IO_DECIMAL_PRECISION   8
 Length of floats on std outputs and log files. More...
 
#define CEPS_WARNING   "WARNING"
 CepsString used as message for warnings. More...
 
#define CEPS_ERROR   "FATAL ERROR"
 CepsString used as message for errors. More...
 
#define CEPS_COLORED_WARNING   "\033[1m\033[34mWARNING\033[0m"
 CepsString used as colored message for warnings. More...
 
#define CEPS_COLORED_ERROR   "\033[1m\033[31mFATAL_ERROR\033[0m"
 CepsString used as colored message for errors. More...
 
#define CEPS_SEPARATOR_LENGTH   77
 
#define CEPS_STRING_SEPARATOR   std::string (CEPS_SEPARATOR_LENGTH, '-')
 CepsString used as separator. More...
 
#define CEPS_SEPARATOR   CEPS_SAYS (CEPS_STRING_SEPARATOR)
 Writes a separator in the debug log and in the terminal. More...
 
#define CEPS_SAYS_IN_PROGRESS(message)
 Writes a message in the debug log and in the terminal (stdio) without carriage return. More...
 
#define CEPS_SAYS(message)
 Writes a message in the debug log and in the terminal (stdio). More...
 
#define CEPS_SAYS_IN_GREEN(message)
 Writes a message in the debug log and in the terminal with color (stdio). More...
 
#define CEPS_SAYS_NOENDL(message)
 Writes a message in the debug log and in the terminal (stdio). More...
 
#define CEPS_SAYS_INLINE(message)
 Writes a message in the debug log and in the terminal (stdio). More...
 
#define CEPS_SAYS_IF(condition, message)
 If condition is true, writes a message in the debug log and in the terminal (stdio) More...
 
#define CEPS_WARNS(message)
 Writes a warning in the debug log and in the terminal (stderr). More...
 
#define CEPS_WARNS_IF(condition, message)
 If condition is true, writes a warning in the debug log and in the terminal (stderr). More...
 
#define CEPS_ABORT(message)
 Stops the execution with a message. If testing is enabled, only throws a runtime_error. More...
 
#define CEPS_ABORT_IF(condition, message)
 Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime_error. More...
 
#define CEPS_CHECK_IS_NAN(value, message)
 Check if a value is nan or inf. More...
 
#define CEPS_DVAL_1(_0, ...)   "\"" << #_0 << "\" : " << _0
 Displays the name and content of 1 variable. More...
 
#define CEPS_DVAL_2(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_1(__VA_ARGS__)
 Displays the name and content of 2 variables. More...
 
#define CEPS_DVAL_3(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_2(__VA_ARGS__)
 Displays the name and content of 3 variables. More...
 
#define CEPS_DVAL_4(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_3(__VA_ARGS__)
 Displays the name and content of 4 variables. More...
 
#define CEPS_DVAL_5(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_4(__VA_ARGS__)
 Displays the name and content of 5 variables. More...
 
#define CEPS_DVAL_6(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_5(__VA_ARGS__)
 Displays the name and content of 6 variables. More...
 
#define CEPS_DVAL_7(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_6(__VA_ARGS__)
 Displays the name and content of 7 variables. More...
 
#define CEPS_DVAL_8(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_7(__VA_ARGS__)
 Displays the name and content of 8 variables. More...
 
#define CEPS_DVAL_9(_0, ...)   CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_8(__VA_ARGS__)
 Displays the name and content of 9 variables. More...
 
#define VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...)   N
 Keeps the 12-th argument. More...
 
#define VA_NARGS(...)   VA_NARGS_IMPL(_, ##__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
 Returns the number of arguments in the macro. More...
 
#define CEPS_CONCAT_2(x, y)   x##y
 Writes two strings next to each other in the code. We need this second CONCAT macro in case the arguments are also macros to be expanded. More...
 
#define CEPS_CONCAT(x, y)   CEPS_CONCAT_2(x, y)
 Writes two strings next to each other in the code. More...
 
#define CEPS_DVAL_CALL(N, ...)   CEPS_CONCAT(CEPS_DVAL_, N) (__VA_ARGS__)
 Selects which CEPS_DVAL_N to call. More...
 
#define CEPS_DISPLAY_VAL(...)   CEPS_DVAL_CALL(VA_NARGS (__VA_ARGS__), __VA_ARGS__)
 Generates a string with the names and values of the arguments of the macro, supports up to ten arguments. More...
 
#define DISP(...)   std::cout << CEPS_DISPLAY_VAL(__VA_ARGS__) << std::endl
 Displays the names and values of the arguments of the macro supports up to ten arguments. More...
 
#define DISPR(...)   std::cout << "proc" << ceps::getRank() << " " << CEPS_DISPLAY_VAL(__VA_ARGS__) << std::endl
 Displays the names and values of the arguments of the macro preceeded by rank supports up to ten arguments. More...
 
#define SEQDISP(...)
 Sequential disp. Careful not to use this in a if(master) block... supports up to ten arguments. More...
 
#define CEPS_UNIMPLEMENTED   static_assert (true, "unimplemented function")
 
#define CEPS_UNUSED(X)   (void) X
 

Detailed Description

A collection of functions and macros that controls the output of standard, warning, and error messages

Definition in file CepsIoMacros.hpp.

Macro Definition Documentation

◆ CEPS_ABORT

#define CEPS_ABORT (   message)
Value:
do { \
std::ostringstream oss; \
oss << message; \
throw CepsException(oss.str()); \
} while (false)

Stops the execution with a message. If testing is enabled, only throws a runtime_error.

Definition at line 264 of file CepsIoMacros.hpp.

◆ CEPS_ABORT_IF

#define CEPS_ABORT_IF (   condition,
  message 
)
Value:
do { \
if (condition) \
{ \
std::ostringstream oss; \
oss << message; \
throw CepsException(oss.str()); \
} \
} while (false)

Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime_error.

Definition at line 275 of file CepsIoMacros.hpp.

◆ CEPS_CHECK_IS_NAN

#define CEPS_CHECK_IS_NAN (   value,
  message 
)
Value:
std::isnan(value) or ! std::isfinite(value), "Value is NaN or infinity.\n · " << message \
)
#define CEPS_WARNS_IF(condition, message)
If condition is true, writes a warning in the debug log and in the terminal (stderr).

Check if a value is nan or inf.

Definition at line 289 of file CepsIoMacros.hpp.

◆ CEPS_COLORED_ERROR

#define CEPS_COLORED_ERROR   "\033[1m\033[31mFATAL_ERROR\033[0m"

CepsString used as colored message for errors.

Definition at line 70 of file CepsIoMacros.hpp.

◆ CEPS_COLORED_WARNING

#define CEPS_COLORED_WARNING   "\033[1m\033[34mWARNING\033[0m"

CepsString used as colored message for warnings.

Definition at line 65 of file CepsIoMacros.hpp.

◆ CEPS_CONCAT

#define CEPS_CONCAT (   x,
 
)    CEPS_CONCAT_2(x, y)

Writes two strings next to each other in the code.

Definition at line 370 of file CepsIoMacros.hpp.

◆ CEPS_CONCAT_2

#define CEPS_CONCAT_2 (   x,
 
)    x##y

Writes two strings next to each other in the code. We need this second CONCAT macro in case the arguments are also macros to be expanded.

Definition at line 365 of file CepsIoMacros.hpp.

◆ CEPS_DISPLAY_VAL

#define CEPS_DISPLAY_VAL (   ...)    CEPS_DVAL_CALL(VA_NARGS (__VA_ARGS__), __VA_ARGS__)

Generates a string with the names and values of the arguments of the macro, supports up to ten arguments.

Definition at line 381 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_1

#define CEPS_DVAL_1 (   _0,
  ... 
)    "\"" << #_0 << "\" : " << _0

Displays the name and content of 1 variable.

Definition at line 308 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_2

#define CEPS_DVAL_2 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_1(__VA_ARGS__)

Displays the name and content of 2 variables.

Definition at line 313 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_3

#define CEPS_DVAL_3 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_2(__VA_ARGS__)

Displays the name and content of 3 variables.

Definition at line 318 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_4

#define CEPS_DVAL_4 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_3(__VA_ARGS__)

Displays the name and content of 4 variables.

Definition at line 323 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_5

#define CEPS_DVAL_5 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_4(__VA_ARGS__)

Displays the name and content of 5 variables.

Definition at line 328 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_6

#define CEPS_DVAL_6 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_5(__VA_ARGS__)

Displays the name and content of 6 variables.

Definition at line 333 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_7

#define CEPS_DVAL_7 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_6(__VA_ARGS__)

Displays the name and content of 7 variables.

Definition at line 338 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_8

#define CEPS_DVAL_8 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_7(__VA_ARGS__)

Displays the name and content of 8 variables.

Definition at line 343 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_9

#define CEPS_DVAL_9 (   _0,
  ... 
)    CEPS_DVAL_1 (_0) << ", " << CEPS_DVAL_8(__VA_ARGS__)

Displays the name and content of 9 variables.

Definition at line 348 of file CepsIoMacros.hpp.

◆ CEPS_DVAL_CALL

#define CEPS_DVAL_CALL (   N,
  ... 
)    CEPS_CONCAT(CEPS_DVAL_, N) (__VA_ARGS__)

Selects which CEPS_DVAL_N to call.

Definition at line 375 of file CepsIoMacros.hpp.

◆ CEPS_ERROR

#define CEPS_ERROR   "FATAL ERROR"

CepsString used as message for errors.

Definition at line 60 of file CepsIoMacros.hpp.

◆ CEPS_IO_DECIMAL_PRECISION

#define CEPS_IO_DECIMAL_PRECISION   8

Length of floats on std outputs and log files.

Definition at line 49 of file CepsIoMacros.hpp.

◆ CEPS_SAYS

#define CEPS_SAYS (   message)
Value:
do \
{ \
if (ceps::isDebug ()) \
{ \
ceps::debugLog () << " · " << message << std::endl; \
} \
if (ceps::isVerbose ()) \
{ \
std::cout << " · " << message << std::endl; \
} \
} while (false)
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 isDebug()
Check if we enable the debug on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:275

Writes a message in the debug log and in the terminal (stdio).

Definition at line 108 of file CepsIoMacros.hpp.

◆ CEPS_SAYS_IF

#define CEPS_SAYS_IF (   condition,
  message 
)
Value:
do \
{ \
if (condition) \
{ \
CEPS_SAYS (message); \
} \
} while (false)

If condition is true, writes a message in the debug log and in the terminal (stdio)

Definition at line 177 of file CepsIoMacros.hpp.

◆ CEPS_SAYS_IN_GREEN

#define CEPS_SAYS_IN_GREEN (   message)
Value:
do \
{ \
if (ceps::isDebug ()) \
{ \
ceps::debugLog () << " · " << message << std::endl; \
} \
if (ceps::isVerbose ()) \
{ \
std::cout << " · \033[1m\033[32;1m" << message << "\033[0m"<< std::endl; \
} \
} while (false)

Writes a message in the debug log and in the terminal with color (stdio).

Definition at line 124 of file CepsIoMacros.hpp.

◆ CEPS_SAYS_IN_PROGRESS

#define CEPS_SAYS_IN_PROGRESS (   message)
Value:
do \
{ \
if (ceps::isDebug ()) \
{ \
ceps::debugLog () << "\r · " << message << std::flush; \
} \
if (ceps::isVerbose ()) \
{ \
std::cout << "\r · " << message << std::flush; \
} \
} while (false)

Writes a message in the debug log and in the terminal (stdio) without carriage return.

Definition at line 91 of file CepsIoMacros.hpp.

◆ CEPS_SAYS_INLINE

#define CEPS_SAYS_INLINE (   message)
Value:
do \
{ \
if (ceps::isDebug ()) \
{ \
ceps::debugLog () << message << std::endl; \
} \
if (ceps::isVerbose ()) \
{ \
std::cout << message << std::endl; \
} \
} while (false)

Writes a message in the debug log and in the terminal (stdio).

Definition at line 160 of file CepsIoMacros.hpp.

◆ CEPS_SAYS_NOENDL

#define CEPS_SAYS_NOENDL (   message)
Value:
do \
{ \
if (ceps::isDebug ()) \
{ \
ceps::debugLog () << " · " << message; \
} \
if (ceps::isVerbose ()) \
{ \
std::cout << " · " << message; \
} \
std::flush(std::cout); \
} while (false)

Writes a message in the debug log and in the terminal (stdio).

Definition at line 142 of file CepsIoMacros.hpp.

◆ CEPS_SEPARATOR

#define CEPS_SEPARATOR   CEPS_SAYS (CEPS_STRING_SEPARATOR)

Writes a separator in the debug log and in the terminal.

Definition at line 85 of file CepsIoMacros.hpp.

◆ CEPS_SEPARATOR_LENGTH

#define CEPS_SEPARATOR_LENGTH   77

Definition at line 75 of file CepsIoMacros.hpp.

◆ CEPS_STRING_SEPARATOR

#define CEPS_STRING_SEPARATOR   std::string (CEPS_SEPARATOR_LENGTH, '-')

CepsString used as separator.

Definition at line 80 of file CepsIoMacros.hpp.

◆ CEPS_UNIMPLEMENTED

#define CEPS_UNIMPLEMENTED   static_assert (true, "unimplemented function")

Definition at line 408 of file CepsIoMacros.hpp.

◆ CEPS_UNUSED

#define CEPS_UNUSED (   X)    (void) X

Definition at line 410 of file CepsIoMacros.hpp.

◆ CEPS_WARNING

#define CEPS_WARNING   "WARNING"

CepsString used as message for warnings.

Definition at line 55 of file CepsIoMacros.hpp.

◆ CEPS_WARNS

#define CEPS_WARNS (   message)
Value:
do \
{ \
{ \
std::ostringstream oss; \
oss << message; \
CepsException ___e(oss.str(),true); \
std::cerr << ___e.errorMessage(true) << std::endl; \
} \
} while (false)
CepsBool isWarnings()
Check if we enable the warnings on the master proc (always false on slave procs).
Definition: CepsFlags.cpp:269

Writes a warning in the debug log and in the terminal (stderr).

Definition at line 226 of file CepsIoMacros.hpp.

◆ CEPS_WARNS_IF

#define CEPS_WARNS_IF (   condition,
  message 
)
Value:
do \
{ \
if ((condition) && ceps::isWarnings()) \
{ \
std::ostringstream oss; \
oss << message; \
CepsException ___e(oss.str(),true); \
std::cerr << ___e.errorMessage(true) << std::endl; \
} \
} while (false)

If condition is true, writes a warning in the debug log and in the terminal (stderr).

Definition at line 243 of file CepsIoMacros.hpp.

◆ DISP

#define DISP (   ...)    std::cout << CEPS_DISPLAY_VAL(__VA_ARGS__) << std::endl

Displays the names and values of the arguments of the macro supports up to ten arguments.

Definition at line 387 of file CepsIoMacros.hpp.

◆ DISPR

#define DISPR (   ...)    std::cout << "proc" << ceps::getRank() << " " << CEPS_DISPLAY_VAL(__VA_ARGS__) << std::endl

Displays the names and values of the arguments of the macro preceeded by rank supports up to ten arguments.

Definition at line 395 of file CepsIoMacros.hpp.

◆ NOARG

#define NOARG

Dummy macro.

Definition at line 43 of file CepsIoMacros.hpp.

◆ SEQDISP

#define SEQDISP (   ...)
Value:
DISPR(__VA_ARGS__); \
std::flush(std::cout); \
void beginSequential()
Begins a sequential block.
void endSequential()
End a sequential block.

Sequential disp. Careful not to use this in a if(master) block... supports up to ten arguments.

Definition at line 402 of file CepsIoMacros.hpp.

◆ VA_NARGS

#define VA_NARGS (   ...)    VA_NARGS_IMPL(_, ##__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)

Returns the number of arguments in the macro.

Definition at line 358 of file CepsIoMacros.hpp.

◆ VA_NARGS_IMPL

#define VA_NARGS_IMPL (   _0,
  _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  N,
  ... 
)    N

Keeps the 12-th argument.

Definition at line 353 of file CepsIoMacros.hpp.