BioDynaMo  v1.05.117-b1949764
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
bdm::CommandLineOptions Class Reference

Class to contain and parse command line options. More...

#include <command_line_options.h>

Collaboration diagram for bdm::CommandLineOptions:
[legend]

Public Member Functions

 CommandLineOptions (int argc, const char **argv)
 
 ~CommandLineOptions ()
 
template<typename T >
void AddOption (const std::string &opt, std::string def, const std::string &description="", std::string group="Simulation")
 Add an extra command line option. More...
 
std::string GetSimulationName () const
 Return the simulation name that was parsed from argv[0]. More...
 
bool IsSet (std::string option)
 Check if the argument for the specified option was set. More...
 
template<typename T >
Get (const std::string &val)
 

Private Member Functions

void AddCoreOptions ()
 
cxxopts::OptionAdder AddOption (std::string group="Simulation")
 Add an extra command line option. More...
 
void Parse ()
 Parse the options with the given command line arguments. More...
 
void ExtractSimulationName (const char *path)
 
void HandleCoreOptions ()
 Takes care of core options. More...
 

Private Attributes

int argc_
 
const char ** argv_
 
std::string sim_name_
 
bool first_parse_ = true
 
cxxopts::Options options_
 
cxxopts::ParseResult * parser_ = nullptr
 

Friends

std::ostream & operator<< (std::ostream &os, const CommandLineOptions &clo)
 

Detailed Description

Class to contain and parse command line options.

Definition at line 37 of file command_line_options.h.

Constructor & Destructor Documentation

◆ CommandLineOptions()

bdm::CommandLineOptions::CommandLineOptions ( int  argc,
const char **  argv 
)

Definition at line 27 of file command_line_options.cc.

◆ ~CommandLineOptions()

bdm::CommandLineOptions::~CommandLineOptions ( )

Definition at line 35 of file command_line_options.cc.

Member Function Documentation

◆ AddCoreOptions()

void bdm::CommandLineOptions::AddCoreOptions ( )
private

Definition at line 100 of file command_line_options.cc.

◆ AddOption() [1/2]

template<typename T >
void bdm::CommandLineOptions::AddOption ( const std::string &  opt,
std::string  def,
const std::string &  description = "",
std::string  group = "Simulation" 
)
inline

Add an extra command line option.

Definition at line 45 of file command_line_options.h.

◆ AddOption() [2/2]

cxxopts::OptionAdder bdm::CommandLineOptions::AddOption ( std::string  group = "Simulation")
private

Add an extra command line option.

◆ ExtractSimulationName()

void bdm::CommandLineOptions::ExtractSimulationName ( const char *  path)
private

Return only the executable name given the path

Parameters
pathpath and filename of the executable e.g. executable, ./executable, './build/executable'
Returns
executable

Definition at line 121 of file command_line_options.cc.

◆ Get()

template<typename T >
T bdm::CommandLineOptions::Get ( const std::string &  val)
inline

Definition at line 59 of file command_line_options.h.

◆ GetSimulationName()

std::string bdm::CommandLineOptions::GetSimulationName ( ) const

Return the simulation name that was parsed from argv[0].

Definition at line 51 of file command_line_options.cc.

◆ HandleCoreOptions()

void bdm::CommandLineOptions::HandleCoreOptions ( )
private

Takes care of core options.

Definition at line 131 of file command_line_options.cc.

◆ IsSet()

bool bdm::CommandLineOptions::IsSet ( std::string  option)

Check if the argument for the specified option was set.

Definition at line 92 of file command_line_options.cc.

◆ Parse()

void bdm::CommandLineOptions::Parse ( )
private

Parse the options with the given command line arguments.

Parse the given command line arguments.

Definition at line 54 of file command_line_options.cc.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const CommandLineOptions clo 
)
friend

Definition at line 212 of file command_line_options.cc.

Member Data Documentation

◆ argc_

int bdm::CommandLineOptions::argc_
private

Definition at line 87 of file command_line_options.h.

◆ argv_

const char** bdm::CommandLineOptions::argv_
private

Definition at line 88 of file command_line_options.h.

◆ first_parse_

bool bdm::CommandLineOptions::first_parse_ = true
private

Definition at line 93 of file command_line_options.h.

◆ options_

cxxopts::Options bdm::CommandLineOptions::options_
private

Definition at line 94 of file command_line_options.h.

◆ parser_

cxxopts::ParseResult* bdm::CommandLineOptions::parser_ = nullptr
private

Definition at line 95 of file command_line_options.h.

◆ sim_name_

std::string bdm::CommandLineOptions::sim_name_
private

Definition at line 90 of file command_line_options.h.


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