LOOS  v2.3.2
loos::OptionsFramework::OptionsPackage Class Reference

Base class for options. More...

#include <OptionsFramework.hpp>

Inheritance diagram for loos::OptionsFramework::OptionsPackage:

Public Member Functions

virtual void addGeneric (po::options_description &opts)
 Appends generic options (those that the user can see)
 
virtual void addHidden (po::options_description &opts)
 Appends hidden options (these generally match positional)
 
virtual void addPositional (po::positional_options_description &opts)
 Appends positional options.
 
virtual std::string print () const
 Returns a string listing the encapsulated options, suitable for logging.
 
virtual bool check (po::variables_map &map)
 Validates passed options, returning true if there is a problem or false if not. More...
 
virtual bool postConditions (po::variables_map &map)
 Post-processing of options returning true if there were no problems, otherwise false. More...
 
virtual std::string help () const
 Returns a slice of the example command-line in the help output. More...
 

Detailed Description

Base class for options.

Options may have a short (1-letter) equivalent. The convention is that core options (i.e. those declared in OptionsFramework.cpp) should all be lower-case. Package options should be in upper-case. Tool-specific options should all be long-form, unless they are commonly used, in which case it's recommended that they be upper-case.

Definition at line 253 of file OptionsFramework.hpp.

Member Function Documentation

virtual bool loos::OptionsFramework::OptionsPackage::check ( po::variables_map &  map)
inlinevirtual

Validates passed options, returning true if there is a problem or false if not.

check() is typically used to validate positional options. For example, if you tool needs a command line that looks like:

* tool [options] min-value max-value number-of-bins
* 

then check() would verify that min-value, max-value, and number-of-bins were passed on the command-line. Another example is where there are mutually-exclusive options. This would be checked by check().

Definition at line 282 of file OptionsFramework.hpp.

virtual std::string loos::OptionsFramework::OptionsPackage::help ( ) const
inlinevirtual

Returns a slice of the example command-line in the help output.

This is used specifically for positional options. If your tool has a command line that looks like:

* tool [options] min-value max-value selection
* 

The required arguments min-value, max-value, and selection are actually "hidden" options and will not be printed out when boost::program_options generates its help message. The AggregateOptions class will build the full command line for the help message by using the help() methods from each OptionsPackage, printing out something like the above on the command line as part of the help output.

Definition at line 317 of file OptionsFramework.hpp.

virtual bool loos::OptionsFramework::OptionsPackage::postConditions ( po::variables_map &  map)
inlinevirtual

Post-processing of options returning true if there were no problems, otherwise false.

postConditions() is called after options parsing and validation is complete. This is a mechanism for a subclass to do additional processing with the options it has been provided. For example, a model option subclass might read in the specified model and copy coordinates from an optionally specified file.

Note that the return value from postConditions() is the opposite of check(). Here, a true is returned if there are no problems.

Reimplemented in loos::OptionsFramework::BasicWater, and loos::OptionsFramework::BasicConvergence.

Definition at line 297 of file OptionsFramework.hpp.


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