|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
Functions | |
| std::optional< std::string > | primary_param_for (std::string const &strategy) |
| Look up a strategy's primary shorthand parameter by name. | |
| std::map< std::string, std::string > & | primary_params_registry () |
Cross-family registry for strategies that accept a CLI positional-shorthand value (e.g. min_size:5 instead of min_size:min_size=5). | |
| bool | register_primary_param (std::string const &strategy, std::string const ¶m) |
| Register a strategy's primary (shorthand) parameter name. | |
|
inline |
Look up a strategy's primary shorthand parameter by name.
std::nullopt otherwise (strategy not shorthand-eligible, or strategy unknown).
|
inline |
Cross-family registry for strategies that accept a CLI positional-shorthand value (e.g. min_size:5 instead of min_size:min_size=5).
Keyed on the strategy's registered name (e.g. "min_size", "pda"). Single global map across all families, relying on the codebase's existing convention that strategy names are unique across families (registered via PPFOREST2_REGISTER_STRATEGY). Collisions are caught at static-init time and raise a clear error rather than silently overwriting.
The registration is co-located with the strategy class in its header (via PPFOREST2_REGISTER_PRIMARY_PARAM) so the shorthand metadata travels with the class definition — not as an out-of- band lookup in the parser. Consumers (currently only cli::strategy_string_to_json) query via primary_param_for.
|
inline |
Register a strategy's primary (shorthand) parameter name.
Called via PPFOREST2_REGISTER_PRIMARY_PARAM alongside the existing PPFOREST2_REGISTER_STRATEGY macro.
Fires an invariant if strategy is already in the registry — a programmer error (two strategies declared shorthand for the same name) that can only originate from source code, not runtime input. Double-registration with identical values is also caught: the inline static definition of registered_primary_param_ in the macro is ODR-merged across TUs to a single initializer, so each strategy reaches this function exactly once per program; any second entry is a name collision, not an idempotent retry. An invariant abort is safer than throwing from a static initializer: the abort prints the reason cleanly, whereas an exception escaping a global constructor can trigger std::terminate with confusing diagnostics.