A toolkit for working with phylogenetic data.
v0.20.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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...
 
std::string info () const
 Return a list with compile time and run time options with their values. 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 random_seed () const
 Returns the random seed that was used to initialize the engine. More...
 
void random_seed (const unsigned seed)
 Set a specific seed for the random engine. More...
 
bool stderr_is_terminal () const
 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...
 
bool stdin_is_terminal () const
 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...
 
bool stdout_is_terminal () const
 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...
 
std::pair< int, int > terminal_size () const
 Return the width and height of the terminal that is used to run the program, in number of columns and lines. More...
 
bool using_openmp () const
 Return whether the binary was compiled using OpenMP. More...
 
bool using_pthreads () const
 Return whether the binary was compiled using Pthreads. 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 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...
 

Member Function Documentation

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 169 of file options.hpp.

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 185 of file options.hpp.

std::string build_type ( )
static

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

Definition at line 338 of file options.cpp.

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.

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

std::string command_line_string ( ) const

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

Definition at line 100 of file options.cpp.

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

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

std::string cpp_version ( )
static

Return the CPP version that was used to compile genesis.

Definition at line 307 of file options.cpp.

static Options& get ( )
inlinestatic

Returns a single instance of this class.

Definition at line 60 of file options.hpp.

std::string info ( ) const

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

Definition at line 353 of file options.cpp.

bool is_big_endian ( )
static

Return whether the system uses big endian memory.

Definition at line 235 of file options.cpp.

bool is_debug ( )
static

Return whether the binary was compiled with build type DEBUG.

Definition at line 320 of file options.cpp.

bool is_little_endian ( )
static

Return whether the system uses little endian memory.

Definition at line 229 of file options.cpp.

bool is_release ( )
static

Return whether the binary was compiled with build type RELEASE.

Definition at line 329 of file options.cpp.

unsigned int number_of_threads ( ) const
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 123 of file options.cpp.

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

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 327 of file options.hpp.

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 337 of file options.hpp.

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 296 of file options.hpp.

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 306 of file options.hpp.

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 155 of file options.hpp.

unsigned random_seed ( ) const
inline

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

Definition at line 131 of file options.hpp.

void random_seed ( const unsigned  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 167 of file options.cpp.

bool stderr_is_terminal ( ) const

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

bool stdin_is_terminal ( ) const

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

bool stdout_is_terminal ( ) const

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

std::pair< int, int > terminal_size ( ) const

Return the width and height of the terminal that is used to run the program, in number of columns and lines.

Definition at line 205 of file options.cpp.

bool using_openmp ( ) const

Return whether the binary was compiled using OpenMP.

Definition at line 154 of file options.cpp.

bool using_pthreads ( ) const

Return whether the binary was compiled using Pthreads.

Definition at line 145 of file options.cpp.


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