#include <genesis/utils/core/options.hpp>
Simple Options class for application-wide configuration and settings.
Definition at line 49 of file options.hpp.
Public Member Functions | |
bool | allow_file_overwriting () const |
Get whether Genesis is allowed to overwrite files when outputting data. More... | |
void | allow_file_overwriting (bool value) |
Set whether Genesis is allowed to overwrite files when outputting data. More... | |
std::vector< std::string > | command_line () const |
Returns an array of strings containing the program's command line arguments. More... | |
void | command_line (int const argc, char const *const *argv) |
Set arguments to the program's command line options. More... | |
std::string | command_line_string () const |
Returns a string containing the program's command line arguments. More... | |
unsigned int | guess_number_of_threads (bool use_openmp=true) const |
Try to guess the number of hardware threads of the current system. More... | |
bool | hyperthreads_enabled () const |
Try to get whether hyperthreads are enabled in the current system. More... | |
std::string | info () const |
Return a list with compile time and run time options with their values. More... | |
std::string | info_compile_time () const |
Return a list of compile time options. More... | |
std::string | info_run_time () const |
Return a list of run time options. More... | |
unsigned int | number_of_threads () const |
Returns the number of threads. More... | |
void | number_of_threads (unsigned int number) |
Overwrite the system given number of threads. More... | |
long | print_object_gists () const |
Get whether an object gist is printed when using the operator << . More... | |
void | print_object_gists (long value) |
Set whether an object gist is printed when using the operator << that is defined for many (container) classes. More... | |
bool | print_object_infos () const |
Get whether an object info one-liner is printed when using the operator << . More... | |
void | print_object_infos (bool value) |
Set whether an object info one-liner is printed when using the operator << that is defined for many classes. More... | |
std::default_random_engine & | random_engine () |
Returns the default engine for random number generation. More... | |
unsigned long | random_seed () const |
Returns the random seed that was used to initialize the engine. More... | |
void | random_seed (const unsigned long seed) |
Set a specific seed for the random engine. More... | |
Static Public Member Functions | |
static std::string | build_type () |
Return the build type that was used to compile the binary, i.e., "debug" or "release". More... | |
static std::string | compile_date_time () |
Return the date and time when genesis was compiled. More... | |
static std::string | compiler_family () |
Return the compiler family (name) that was used to compile genesis. More... | |
static std::string | compiler_version () |
Return the compiler version that was used to compile genesis. More... | |
static std::string | cpp_version () |
Return the CPP version that was used to compile genesis. More... | |
static Options & | get () |
Returns a single instance of this class. More... | |
static bool | is_big_endian () |
Return whether the system uses big endian memory. More... | |
static bool | is_debug () |
Return whether the binary was compiled with build type DEBUG . More... | |
static bool | is_little_endian () |
Return whether the system uses little endian memory. More... | |
static bool | is_release () |
Return whether the binary was compiled with build type RELEASE . More... | |
static std::string | platform () |
Return the platform under which genesis was compiled. More... | |
static bool | stderr_is_terminal () |
Return true iff the standard error stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
static bool | stdin_is_terminal () |
Return true iff the standard input stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
static bool | stdout_is_terminal () |
Return true iff the standard output stream is a terminal, and false if not, i.e., if it is a file or a pipe. More... | |
static std::pair< int, int > | terminal_size () |
Return the width and height of the terminal that is used to run the program, in number of columns and lines. More... | |
static bool | using_openmp () |
Return whether the binary was compiled using OpenMP. More... | |
static bool | using_pthreads () |
Return whether the binary was compiled using Pthreads. More... | |
static bool | using_zlib () |
Return whether the binary was compiled using zlib. More... | |
|
inline |
Get whether Genesis is allowed to overwrite files when outputting data.
See allow_file_overwriting( bool ) for details.
Definition at line 172 of file options.hpp.
|
inline |
Set whether Genesis is allowed to overwrite files when outputting data.
The option is false
by default, which causes Genesis to throw an execption when it attempts to write to a file that is already existing.
By setting this option to true
, files are silently overwritten in case they already exist. This has to be activated explicitly in order to avoid losing files by accident.
Definition at line 188 of file options.hpp.
|
static |
Return the build type that was used to compile the binary, i.e., "debug" or "release".
Definition at line 276 of file options.cpp.
|
inline |
Returns an array of strings containing the program's command line arguments.
Definition at line 73 of file options.hpp.
void command_line | ( | int const | argc, |
char const *const * | argv | ||
) |
Set arguments to the program's command line options.
If the program is run from the command line, this method has to be used to properly propagate the command line options to this options class.
Definition at line 98 of file options.cpp.
std::string command_line_string | ( | ) | const |
Returns a string containing the program's command line arguments.
Definition at line 88 of file options.cpp.
|
static |
Return the date and time when genesis was compiled.
Due to this using the preprocessor, the returned date and time are from when the Options class was first compiled in a clean build process.
Definition at line 374 of file options.cpp.
|
static |
Return the compiler family (name) that was used to compile genesis.
See compiler_version() to get the version of the compiler.
Definition at line 316 of file options.cpp.
|
static |
Return the compiler version that was used to compile genesis.
See compiler_family() to get the corresponding compiler name.
Definition at line 339 of file options.cpp.
|
static |
Return the CPP version that was used to compile genesis.
Definition at line 365 of file options.cpp.
|
inlinestatic |
Returns a single instance of this class.
Definition at line 60 of file options.hpp.
unsigned int guess_number_of_threads | ( | bool | use_openmp = true | ) | const |
Try to guess the number of hardware threads of the current system.
This function uses multiple sources and ways to try to guess the number of physical cores of the system.
Definition at line 149 of file options.cpp.
bool hyperthreads_enabled | ( | ) | const |
Try to get whether hyperthreads are enabled in the current system.
Definition at line 133 of file options.cpp.
std::string info | ( | ) | const |
Return a list with compile time and run time options with their values.
Definition at line 410 of file options.cpp.
std::string info_compile_time | ( | ) | const |
Return a list of compile time options.
Definition at line 419 of file options.cpp.
std::string info_run_time | ( | ) | const |
Return a list of run time options.
Definition at line 434 of file options.cpp.
|
static |
Return whether the system uses big endian memory.
Definition at line 293 of file options.cpp.
|
static |
Return whether the binary was compiled with build type DEBUG
.
Definition at line 258 of file options.cpp.
|
static |
Return whether the system uses little endian memory.
Definition at line 287 of file options.cpp.
|
static |
Return whether the binary was compiled with build type RELEASE
.
Definition at line 267 of file options.cpp.
|
inline |
Returns the number of threads.
Definition at line 98 of file options.hpp.
void number_of_threads | ( | unsigned int | number | ) |
Overwrite the system given number of threads.
When the Options class is first instanciated, the value is initialized with the actual number of cores available in the system using std::thread::hardware_concurrency(). This method overwrites this value.
If number
is 0, the number of threads is set again to hardware concurrency.
Definition at line 111 of file options.cpp.
|
static |
Return the platform under which genesis was compiled.
This can be either "Win32", "Linux", "Apple", "Unix" or "Unknown".
Definition at line 299 of file options.cpp.
|
inline |
Get whether an object gist is printed when using the operator <<
.
See print_object_gists( long ) for details.
Definition at line 253 of file options.hpp.
|
inline |
Set whether an object gist is printed when using the operator <<
that is defined for many (container) classes.
In genesis, we create the functions print_info()
and print_gist()
, and overload the operator <<
for many classes as a convenient way to get information about an object, for example for debugging purposes. Using this setting, the behaviour of the operator <<
is controlled: If set to a value n
greather than 0, the first n
elements that the object contains are printed. If set to a negative value, all elements are printed. Default is 0, that is, no gist of the object's elements is printed.
See also print_object_infos( bool ) for an additional setting that allows to print an info one-liner when using operator <<
on an object. Both settings can also be combined. In that case, first, the one-line info is printed, followed by the gist.
Definition at line 243 of file options.hpp.
|
inline |
Get whether an object info one-liner is printed when using the operator <<
.
See print_object_infos( bool ) for details.
Definition at line 222 of file options.hpp.
|
inline |
Set whether an object info one-liner is printed when using the operator <<
that is defined for many classes.
In genesis, we create the functions print_info()
and print_gist()
, and overload the operator <<
for many classes as a convenient way to get information about an object, for example for debugging purposes. Using this setting, the behaviour of the operator <<
is controlled: If set to true
, a one-liner containing basic information about the object (its type, and for containers, its size) is printed.
See also print_object_gists( int ) for an additional setting that allows to print more details when using operator <<
on an object. Both settings can also be combined. In that case, first, the one-line info is printed, followed by the gist.
Definition at line 212 of file options.hpp.
|
inline |
Returns the default engine for random number generation.
Caveat: This is not intended for the use in more than one thread. As the order of execution in threads is not deterministic, results would not be reproducible, even when using a fixed seed. Furthermore, it might be a speed bottleneck to add a mutex to this method.
If in the future there is need for multi-threaded random engines, they needed to be outfitted with separate seeds each (otherwise they would all produce the same results). Thus, for now we simply assume single-threaded use.
Definition at line 158 of file options.hpp.
|
inline |
Returns the random seed that was used to initialize the engine.
Definition at line 134 of file options.hpp.
void random_seed | ( | const unsigned long | seed | ) |
Set a specific seed for the random engine.
On startup, the random engine is initialized using the current system time. This value can be overwritten using this method.
Definition at line 196 of file options.cpp.
|
static |
Return true iff the standard error stream is a terminal, and false if not, i.e., if it is a file or a pipe.
Definition at line 225 of file options.cpp.
|
static |
Return true iff the standard input stream is a terminal, and false if not, i.e., if it is a file or a pipe.
Definition at line 206 of file options.cpp.
|
static |
Return true iff the standard output stream is a terminal, and false if not, i.e., if it is a file or a pipe.
Definition at line 216 of file options.cpp.
|
static |
Return the width and height of the terminal that is used to run the program, in number of columns and lines.
Definition at line 234 of file options.cpp.
|
static |
Return whether the binary was compiled using OpenMP.
Definition at line 388 of file options.cpp.
|
static |
Return whether the binary was compiled using Pthreads.
Definition at line 379 of file options.cpp.
|
static |
Return whether the binary was compiled using zlib.
Definition at line 397 of file options.cpp.