#include <clasp_options.h>
Classes | |
struct | ParseContext |
class | ProgOption |
struct | RawConfig |
struct | ScopedSet |
Public Member Functions | |
ClaspCliConfig () | |
~ClaspCliConfig () | |
Raw interface | |
void | init (uint32 solverId, ConfigKey config=config_asp_default) |
Initializes the i'th solver with the given configuration. | |
void | initTester (uint32 solverId, ConfigKey config=config_default) |
Initializes the i'th tester solver with the given configuration. | |
bool | set (OptionKey o, const char *value) |
Sets the given option in the master configuration. | |
bool | set (uint32 solverId, OptionKey o, const char *value) |
Sets the given option in the i'th solver. | |
bool | setTester (uint32 solverId, OptionKey o, const char *value) |
Sets the given option in the i'th tester solver. | |
bool | finalize () |
Validates and finalizes this configuration. | |
App interface | |
void | addOptions (ProgramOptions::OptionContext &root) |
Adds all available options to root. | |
void | addDisabled (ProgramOptions::ParsedOptions &parsed) |
Adds options that are disabled by the options contained in parsed to parsed. | |
bool | finalize (const ProgramOptions::ParsedOptions &parsed, ProblemType type, bool applyDefaults) |
Applies the options in parsed and calls finalize(). | |
template<class IT > | |
bool | setConfig (IT first, IT last, ProblemType t) |
Populates this configuration with the options given in [first, last) and finalizes it. | |
Static Public Member Functions | |
static ConfigKey | allocConfig () |
Registers a new empty configuration and returns its key. | |
static void | appendConfig (ConfigKey k, const char *name, const char *cmd) |
Appends cmd to the given configuration. | |
static ConfigIter | getConfig (ConfigKey key) |
Returns the configuration with the given key as a double-null-terminated string list. | |
static const char * | getDefaults (ProblemType f) |
Returns defaults for the given problem type. | |
static ConfigKey | loadConfig (const char *fileName) |
Loads the configuration file with the given name and returns a configuration key for accessing it. | |
static bool | releaseConfig (ConfigKey key) |
Discards the configuration with the given key. | |
Private Types | |
enum | ConfigOption { opt_configuration = -1, opt_tester = -2 } |
typedef PodVector< std::string > ::type | ConfigVec |
typedef SingleOwnerPtr < ParseContext > | CtxPtr |
typedef ProgramOptions::OptionContext | OptionContext |
typedef ProgramOptions::ParsedOptions | ParsedOpts |
typedef SingleOwnerPtr < OptionContext > | RootPtr |
Private Member Functions | |
const UserConfig * | active () const |
UserConfig * | active () |
ProgOption * | createOption (int o) |
void | error (int opt) const |
const ParsedOpts & | finalizeParsed (UserConfig *active, const ParsedOpts &parsed, ParsedOpts &exclude) const |
bool | finalizeSolvers (UserConfig *active, const ParsedOpts &exclude, ProblemType t, bool defs) |
bool | finalizeTester (bool defs) |
int | get (OptionKey o, CtxOpts *&ctx, SolverParams *&solver, SolveParams *&solve) |
void | init (OptionContext *ctx, bool owned) |
bool | isGenerator () const |
bool | set (ConfigOption o, const char *value) |
bool | set (const ConfigIter &it, bool allowConfig, const ParsedOpts &exclude, ParsedOpts *out) |
bool | setConfig (const RawConfig &c, ProblemType t) |
bool | setDefaults (UserConfig *active, uint32 sId, const ParsedOpts &exclude, ProblemType t) |
Private Attributes | |
CtxPtr | opts_ |
Static Private Attributes | |
static ConfigVec | configs_g |
static const uint8 | mode_relaxed = 4u |
static const uint8 | mode_solver = 1u |
static const uint8 | mode_tester = 2u |
static const uint8 | opt_applied = 0x80u |
Definition at line 81 of file clasp_options.h.
typedef PodVector<std::string>::type Clasp::Cli::ClaspCliConfig::ConfigVec [private] |
Definition at line 159 of file clasp_options.h.
typedef SingleOwnerPtr<ParseContext> Clasp::Cli::ClaspCliConfig::CtxPtr [private] |
Definition at line 157 of file clasp_options.h.
typedef ProgramOptions::OptionContext Clasp::Cli::ClaspCliConfig::OptionContext [private] |
Definition at line 155 of file clasp_options.h.
typedef ProgramOptions::ParsedOptions Clasp::Cli::ClaspCliConfig::ParsedOpts [private] |
Definition at line 160 of file clasp_options.h.
typedef SingleOwnerPtr<OptionContext> Clasp::Cli::ClaspCliConfig::RootPtr [private] |
Definition at line 158 of file clasp_options.h.
enum Clasp::Cli::ClaspCliConfig::ConfigOption [private] |
Definition at line 150 of file clasp_options.h.
Definition at line 309 of file clasp_options.cpp.
Definition at line 310 of file clasp_options.cpp.
const UserConfig* Clasp::Cli::ClaspCliConfig::active | ( | ) | const [inline, private] |
Definition at line 183 of file clasp_options.h.
UserConfig* Clasp::Cli::ClaspCliConfig::active | ( | ) | [inline, private] |
Definition at line 184 of file clasp_options.h.
void Clasp::Cli::ClaspCliConfig::addDisabled | ( | ProgramOptions::ParsedOptions & | parsed | ) |
Adds options that are disabled by the options contained in parsed to parsed.
Definition at line 502 of file clasp_options.cpp.
Adds all available options to root.
Once options are added, an option source (e.g. the command-line) can be used to populate this object.
Definition at line 369 of file clasp_options.cpp.
ConfigKey Clasp::Cli::ClaspCliConfig::allocConfig | ( | ) | [static] |
Registers a new empty configuration and returns its key.
Definition at line 218 of file clasp_options.cpp.
void Clasp::Cli::ClaspCliConfig::appendConfig | ( | ConfigKey | k, |
const char * | name, | ||
const char * | cmd | ||
) | [static] |
Appends cmd to the given configuration.
k | The config to append to. |
name | The name of the new config. |
cmd | A space separated option-list in long-format (i.e. '--opt=value'). |
Definition at line 204 of file clasp_options.cpp.
ClaspCliConfig::ProgOption * Clasp::Cli::ClaspCliConfig::createOption | ( | int | o | ) | [private] |
Definition at line 311 of file clasp_options.cpp.
void Clasp::Cli::ClaspCliConfig::error | ( | int | opt | ) | const [private] |
Definition at line 566 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::finalize | ( | ) |
Validates and finalizes this configuration.
Definition at line 466 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::finalize | ( | const ProgramOptions::ParsedOptions & | parsed, |
ProblemType | type, | ||
bool | applyDefaults | ||
) |
Applies the options in parsed and calls finalize().
Definition at line 478 of file clasp_options.cpp.
const ClaspCliConfig::ParsedOpts & Clasp::Cli::ClaspCliConfig::finalizeParsed | ( | UserConfig * | active, |
const ParsedOpts & | parsed, | ||
ParsedOpts & | exclude | ||
) | const [private] |
Definition at line 506 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::finalizeSolvers | ( | UserConfig * | active, |
const ParsedOpts & | exclude, | ||
ProblemType | t, | ||
bool | defs | ||
) | [private] |
Definition at line 523 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::finalizeTester | ( | bool | defs | ) | [private] |
Definition at line 486 of file clasp_options.cpp.
int Clasp::Cli::ClaspCliConfig::get | ( | OptionKey | o, |
CtxOpts *& | ctx, | ||
SolverParams *& | solver, | ||
SolveParams *& | solve | ||
) | [private] |
Definition at line 373 of file clasp_options.cpp.
ConfigIter Clasp::Cli::ClaspCliConfig::getConfig | ( | ConfigKey | key | ) | [static] |
Returns the configuration with the given key as a double-null-terminated string list.
Definition at line 261 of file clasp_options.cpp.
const char * Clasp::Cli::ClaspCliConfig::getDefaults | ( | ProblemType | f | ) | [static] |
Returns defaults for the given problem type.
Definition at line 279 of file clasp_options.cpp.
void Clasp::Cli::ClaspCliConfig::init | ( | uint32 | solverId, |
ConfigKey | config = config_asp_default |
||
) |
Initializes the i'th solver with the given configuration.
Definition at line 386 of file clasp_options.cpp.
void Clasp::Cli::ClaspCliConfig::init | ( | OptionContext * | ctx, |
bool | owned | ||
) | [private] |
Definition at line 313 of file clasp_options.cpp.
void Clasp::Cli::ClaspCliConfig::initTester | ( | uint32 | solverId, |
ConfigKey | config = config_default |
||
) |
Initializes the i'th tester solver with the given configuration.
Definition at line 391 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::isGenerator | ( | ) | const [inline, private] |
Definition at line 182 of file clasp_options.h.
ConfigKey Clasp::Cli::ClaspCliConfig::loadConfig | ( | const char * | fileName | ) | [static] |
Loads the configuration file with the given name and returns a configuration key for accessing it.
Definition at line 228 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::releaseConfig | ( | ConfigKey | key | ) | [static] |
Discards the configuration with the given key.
Definition at line 252 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::set | ( | OptionKey | o, |
const char * | value | ||
) |
Sets the given option in the master configuration.
Definition at line 404 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::set | ( | uint32 | solverId, |
OptionKey | o, | ||
const char * | value | ||
) |
Sets the given option in the i'th solver.
Definition at line 401 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::set | ( | ConfigOption | o, |
const char * | value | ||
) | [private] |
Definition at line 426 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::set | ( | const ConfigIter & | it, |
bool | allowConfig, | ||
const ParsedOpts & | exclude, | ||
ParsedOpts * | out | ||
) | [private] |
Definition at line 458 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::setConfig | ( | IT | first, |
IT | last, | ||
ProblemType | t | ||
) | [inline] |
Populates this configuration with the options given in [first, last) and finalizes it.
[first,last) | a range of options in argv format. |
Definition at line 143 of file clasp_options.h.
bool Clasp::Cli::ClaspCliConfig::setConfig | ( | const RawConfig & | c, |
ProblemType | t | ||
) | [private] |
Definition at line 589 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::setDefaults | ( | UserConfig * | active, |
uint32 | sId, | ||
const ParsedOpts & | exclude, | ||
ProblemType | t | ||
) | [private] |
Definition at line 444 of file clasp_options.cpp.
bool Clasp::Cli::ClaspCliConfig::setTester | ( | uint32 | solverId, |
OptionKey | o, | ||
const char * | value | ||
) |
Sets the given option in the i'th tester solver.
Definition at line 397 of file clasp_options.cpp.
ClaspCliConfig::ConfigVec Clasp::Cli::ClaspCliConfig::configs_g [static, private] |
Definition at line 190 of file clasp_options.h.
const uint8 Clasp::Cli::ClaspCliConfig::mode_relaxed = 4u [static, private] |
Definition at line 153 of file clasp_options.h.
const uint8 Clasp::Cli::ClaspCliConfig::mode_solver = 1u [static, private] |
Definition at line 151 of file clasp_options.h.
const uint8 Clasp::Cli::ClaspCliConfig::mode_tester = 2u [static, private] |
Definition at line 152 of file clasp_options.h.
const uint8 Clasp::Cli::ClaspCliConfig::opt_applied = 0x80u [static, private] |
Definition at line 154 of file clasp_options.h.
CtxPtr Clasp::Cli::ClaspCliConfig::opts_ [private] |
Definition at line 191 of file clasp_options.h.