Class for program options on top of the Boost.Program_Options library. More...
Public Member Functions | |
program_options (unsigned line_length=m_default_line_length) | |
Default constructor. More... | |
program_options (const std::string &caption, unsigned line_length=m_default_line_length) | |
Constructor with setting a caption for usage output. More... | |
virtual | ~program_options () |
Default deconstructor. | |
bool | good () const |
Is help needed? Are all properties set properly? More... | |
void | parse (int argc, char **argv) |
Parses the command line. More... | |
bool | is_set (const std::string &option) const |
Checks whether a parameter was set or not. More... | |
program_options & | add_read_realization_option () |
Adds an option for an input as RevLib realization. More... | |
program_options & | add_read_specification_option () |
Adds an option for an input as RevLib specification. More... | |
program_options & | add_write_realization_option () |
Adds an option for an output as RevLib realization. More... | |
program_options & | add_costs_option () |
Adds an option for selecting a cost function. More... | |
const std::string & | read_realization_filename () const |
Returns the RevLib realization input if it was set. More... | |
const std::string & | read_specification_filename () const |
Returns the RevLib specification input if it was set. More... | |
const std::string & | write_realization_filename () const |
Returns the RevLib realization output if it was set. More... | |
bool | is_write_realization_filename_set () const |
Checks whether a filename for RevLib realization output was set. More... | |
cost_function | costs () const |
Returns a cost function. More... | |
Class for program options on top of the Boost.Program_Options library.
This class can be used when writing programs for accessing algorithms. It parses from C argc and argv variables and has some functions for adding program options for common used parameters like input realization or specification filename and output realization filename.
This could be used for a synthesis algorithm to read a specification and write the result to a realization.
|
explicit |
Default constructor.
Calls the constructor of the boost::program_options::options_description base class and adds a –help option.
line_length | Length of the terminal where to output |
|
explicit |
Constructor with setting a caption for usage output.
Calls the constructor of the boost::program_options::options_description base class and adds a –help option.
caption | A caption is primarily useful for output |
line_length | Length of the terminal where to output |
program_options& add_costs_option | ( | ) |
Adds an option for selecting a cost function.
This method adds an option called –costs which takes an integer value as argument representing a cost function, whereby 0 is gate costs, 1 is line costs, 2 is quantum costs, and 3 is transistor costs, respectively.
program_options& add_read_realization_option | ( | ) |
Adds an option for an input as RevLib realization.
This method adds an option called –filename which takes a RevLib realization (*.real) file as argument.
After calling this function, add_read_specification_option() cannot be called anymore.
program_options& add_read_specification_option | ( | ) |
Adds an option for an input as RevLib specification.
This method adds an option called –filename which takes a RevLib specification (*.spec) file as argument.
After calling this function, add_read_realization_option() cannot be called anymore.
program_options& add_write_realization_option | ( | ) |
Adds an option for an output as RevLib realization.
This method adds an option called –realname which takes a RevLib realization (*.real) file as argument.
To check whether this option was set or not, use is_write_realization_filename_set().
cost_function costs | ( | ) | const |
Returns a cost function.
Use this method together with add_costs_option() only. When adding that method, costs are ensured to be selected (e.g. the default ones). Then this method can create a corresponding cost function.
bool good | ( | ) | const |
Is help needed? Are all properties set properly?
This method returns true when the –help option is not set and when the –filename option is set, as far as either add_read_realization_option() or add_read_specification_option() was called before.
bool is_set | ( | const std::string & | option | ) | const |
Checks whether a parameter was set or not.
This method calls Boost's variable_map::count method and checks if the parameter was set at least once.
This class should be simple in general so there is no distinction between one or more options of the same name.
option | Name of the option |
option
was set, false otherwise.bool is_write_realization_filename_set | ( | ) | const |
Checks whether a filename for RevLib realization output was set.
This method evaluates to true, when add_write_realization_option was called before and –realname was set via the command line.
void parse | ( | int | argc, |
char ** | argv | ||
) |
Parses the command line.
argc | C argc argument of the main function |
argv | C argv argument of the main function |
const std::string& read_realization_filename | ( | ) | const |
Returns the RevLib realization input if it was set.
This method can just be called after the option was added with add_read_realization_option() and good() evaluated to true.
const std::string& read_specification_filename | ( | ) | const |
Returns the RevLib specification input if it was set.
This method can just be called after the option was added with add_read_specification_option() and good() evaluated to true.
const std::string& write_realization_filename | ( | ) | const |
Returns the RevLib realization output if it was set.
This method can just be called after the option was added with add_write_realization_option() and is_write_realization_filename_set() evaluated to true.