|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
CRTP base class providing self-registration for strategy types. More...
#include <Strategy.hpp>
Public Types | |
| using | Factory = Ptr (*)(nlohmann::json const&) |
| Factory function type for deserializing a strategy from JSON. | |
| using | Ptr = std::shared_ptr<Derived> |
Public Member Functions | |
| virtual | ~Strategy ()=default |
| virtual std::string | display_name () const =0 |
| Human-readable name for display in summaries. | |
| virtual void | to_json (nlohmann::json &j) const =0 |
| Serialize this strategy's configuration to JSON. | |
Static Public Member Functions | |
| static Ptr | from_json (nlohmann::json const &j) |
| Construct a strategy from its JSON representation. | |
| static bool | register_strategy (std::string const &name, Factory factory) |
| Register a concrete strategy for JSON deserialization. | |
CRTP base class providing self-registration for strategy types.
Each strategy family (PP, DR, SR) inherits from Strategy<Derived> to get a shared_ptr Ptr typedef, a static registry of named factory functions, and a from_json() dispatcher that looks up the "name" field and delegates to the registered factory.
Concrete strategies register themselves at static-init time via the PPFOREST2_REGISTER_STRATEGY macro.
| Derived | The strategy base class (e.g. PPStrategy). |
Factory function type for deserializing a strategy from JSON.
| using Strategy< Derived >::Ptr = std::shared_ptr<Derived> |
|
pure virtual |
Human-readable name for display in summaries.
Implemented in ppforest2::dr::DRNoopStrategy, ppforest2::dr::DRUniformStrategy, ppforest2::pp::PPPDAStrategy, and ppforest2::sr::SRMeanOfMeansStrategy.
|
inlinestatic |
Construct a strategy from its JSON representation.
Dispatches on the "name" field to the registered factory.
| j | JSON object (must contain "name"). |
|
inlinestatic |
Register a concrete strategy for JSON deserialization.
Called automatically by concrete strategies via inline static initialization. Adding a new strategy only requires defining a static from_json and the PPFOREST2_REGISTER_STRATEGY macro.
| name | Strategy name (must match the "name" field in JSON). |
| factory | Factory function that constructs the strategy. |
|
pure virtual |
Serialize this strategy's configuration to JSON.
Must include a "name" field identifying the strategy type, plus any strategy-specific parameters.
| j | JSON object to populate. |
Implemented in ppforest2::dr::DRNoopStrategy, ppforest2::dr::DRUniformStrategy, ppforest2::pp::PPPDAStrategy, and ppforest2::sr::SRMeanOfMeansStrategy.