A toolkit for working with phylogenetic data.
v0.24.0
Options Class Reference

#include <genesis/utils/core/options.hpp>

Detailed Description

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...
 
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...
 
long print_object_gists () const
 Get whether an object gist 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...
 
bool print_object_infos () const
 Get whether an object info one-liner is printed when using the operator <<. 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 Optionsget ()
 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...
 

Member Function Documentation

◆ allow_file_overwriting() [1/2]

bool allow_file_overwriting ( ) const
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.

◆ allow_file_overwriting() [2/2]

void allow_file_overwriting ( bool  value)
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.

See also
file_output_stream()

Definition at line 188 of file options.hpp.

◆ build_type()

std::string build_type ( )
static

Return the build type that was used to compile the binary, i.e., "debug" or "release".

Definition at line 259 of file options.cpp.

◆ command_line() [1/2]

std::vector<std::string> command_line ( ) const
inline

Returns an array of strings containing the program's command line arguments.

Definition at line 73 of file options.hpp.

◆ command_line() [2/2]

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 95 of file options.cpp.

◆ command_line_string()

std::string command_line_string ( ) const

Returns a string containing the program's command line arguments.

Definition at line 85 of file options.cpp.

◆ compile_date_time()

std::string compile_date_time ( )
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 357 of file options.cpp.

◆ compiler_family()

std::string compiler_family ( )
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 299 of file options.cpp.

◆ compiler_version()

std::string compiler_version ( )
static

Return the compiler version that was used to compile genesis.

See compiler_family() to get the corresponding compiler name.

Definition at line 322 of file options.cpp.

◆ cpp_version()

std::string cpp_version ( )
static

Return the CPP version that was used to compile genesis.

Definition at line 348 of file options.cpp.

◆ get()

static Options& get ( )
inlinestatic

Returns a single instance of this class.

Definition at line 60 of file options.hpp.

◆ guess_number_of_threads()

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 143 of file options.cpp.

◆ hyperthreads_enabled()

bool hyperthreads_enabled ( ) const

Try to get whether hyperthreads are enabled in the current system.

Definition at line 130 of file options.cpp.

◆ info()

std::string info ( ) const

Return a list with compile time and run time options with their values.

Definition at line 393 of file options.cpp.

◆ info_compile_time()

std::string info_compile_time ( ) const

Return a list of compile time options.

Definition at line 402 of file options.cpp.

◆ info_run_time()

std::string info_run_time ( ) const

Return a list of run time options.

Definition at line 417 of file options.cpp.

◆ is_big_endian()

bool is_big_endian ( )
static

Return whether the system uses big endian memory.

Definition at line 276 of file options.cpp.

◆ is_debug()

bool is_debug ( )
static

Return whether the binary was compiled with build type DEBUG.

Definition at line 241 of file options.cpp.

◆ is_little_endian()

bool is_little_endian ( )
static

Return whether the system uses little endian memory.

Definition at line 270 of file options.cpp.

◆ is_release()

bool is_release ( )
static

Return whether the binary was compiled with build type RELEASE.

Definition at line 250 of file options.cpp.

◆ number_of_threads() [1/2]

unsigned int number_of_threads ( ) const
inline

Returns the number of threads.

Definition at line 98 of file options.hpp.

◆ number_of_threads() [2/2]

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 108 of file options.cpp.

◆ platform()

std::string platform ( )
static

Return the platform under which genesis was compiled.

This can be either "Win32", "Linux", "Apple", "Unix" or "Unknown".

Definition at line 282 of file options.cpp.

◆ print_object_gists() [1/2]

void print_object_gists ( long  value)
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.

◆ print_object_gists() [2/2]

long print_object_gists ( ) const
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.

◆ print_object_infos() [1/2]

void print_object_infos ( bool  value)
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.

◆ print_object_infos() [2/2]

bool print_object_infos ( ) const
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.

◆ random_engine()

std::default_random_engine& random_engine ( )
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.

◆ random_seed() [1/2]

unsigned long random_seed ( ) const
inline

Returns the random seed that was used to initialize the engine.

Definition at line 134 of file options.hpp.

◆ random_seed() [2/2]

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 179 of file options.cpp.

◆ stderr_is_terminal()

bool stderr_is_terminal ( )
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 208 of file options.cpp.

◆ stdin_is_terminal()

bool stdin_is_terminal ( )
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 189 of file options.cpp.

◆ stdout_is_terminal()

bool stdout_is_terminal ( )
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 199 of file options.cpp.

◆ terminal_size()

std::pair< int, int > terminal_size ( )
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 217 of file options.cpp.

◆ using_openmp()

bool using_openmp ( )
static

Return whether the binary was compiled using OpenMP.

Definition at line 371 of file options.cpp.

◆ using_pthreads()

bool using_pthreads ( )
static

Return whether the binary was compiled using Pthreads.

Definition at line 362 of file options.cpp.

◆ using_zlib()

bool using_zlib ( )
static

Return whether the binary was compiled using zlib.

Definition at line 380 of file options.cpp.


The documentation for this class was generated from the following files: