ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
Loading...
Searching...
No Matches
ppforest2::strategies Namespace Reference

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 &param)
 Register a strategy's primary (shorthand) parameter name.
 

Function Documentation

◆ primary_param_for()

std::optional< std::string > ppforest2::strategies::primary_param_for ( std::string const & strategy)
inline

Look up a strategy's primary shorthand parameter by name.

Returns
The parameter name if registered; std::nullopt otherwise (strategy not shorthand-eligible, or strategy unknown).

◆ primary_params_registry()

std::map< std::string, std::string > & ppforest2::strategies::primary_params_registry ( )
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.

◆ register_primary_param()

bool ppforest2::strategies::register_primary_param ( std::string const & strategy,
std::string const & param )
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.