Skip to main content

MLCore::MLModelRegistry

MLCore::MLModelRegistry

Factory registry for ML model operations. More…

#include <MLModelRegistry.hpp>

Public Types

Name
using std::function< std::unique_ptr< MLModelOperation >()> FactoryFn
Factory function type that returns a new, untrained model instance.

Public Functions

Name
MLModelRegistry()
Construct the registry and register all built-in models.
MLModelRegistry(MLModelRegistry const & ) =delete
MLModelRegistry & operator=(MLModelRegistry const & ) =delete
MLModelRegistry(MLModelRegistry && ) =delete
MLModelRegistry & operator=(MLModelRegistry && ) =delete
void registerModel(std::string const & name, MLTaskType task, FactoryFn factory)
Register a model factory.
template <typename ModelT >
void
registerModel()
Register by instantiating a model to extract metadata.
std::vector< std::string > getAllModelNames() const
Get names of all registered models.
std::vector< std::string > getModelNames(MLTaskType task) const
Get names of models that support a specific task type.
bool hasModel(std::string const & name) const
Check if a model with the given name is registered.
std::optional< MLTaskType > getTaskType(std::string const & name) const
Get the task type of a registered model.
std::size_t size() const
Number of registered models.
std::unique_ptr< MLModelOperation > create(std::string const & name) const
Create a new, untrained model instance by name.

Detailed Description

class MLCore::MLModelRegistry;

Factory registry for ML model operations.

Stores factory functions (not live instances) so that each [create()](/api_generated/Classes/classMLCore_1_1MLModelRegistry.md#function-create) call returns a fresh, untrained model. This avoids issues with shared mutable state between callers.

Public Types Documentation

using FactoryFn

using MLCore::MLModelRegistry::FactoryFn =  std::function<std::unique_ptr<MLModelOperation>()>;

Factory function type that returns a new, untrained model instance.

Public Functions Documentation

function MLModelRegistry

MLModelRegistry()

Construct the registry and register all built-in models.

Registers all six built-in models: RandomForest, NaiveBayes, LogisticRegression, KMeans, DBSCAN, and GaussianMixture.

function MLModelRegistry

MLModelRegistry(
    MLModelRegistry const & 
) =delete

function operator=

MLModelRegistry & operator=(
    MLModelRegistry const & 
) =delete

function MLModelRegistry

MLModelRegistry(
    MLModelRegistry && 
) =delete

function operator=

MLModelRegistry & operator=(
    MLModelRegistry && 
) =delete

function registerModel

void registerModel(
    std::string const & name,
    MLTaskType task,
    FactoryFn factory
)

Register a model factory.

Parameters:

  • name Unique name for the model (e.g., “Random Forest”). If a model with this name already exists, it is replaced.
  • task The ML task type this model supports
  • factory Factory function that creates a fresh, untrained instance

function registerModel

template <typename ModelT >
inline void registerModel()

Register by instantiating a model to extract metadata.

Template Parameters:

Creates one temporary instance to get the name and task type, then stores the factory for future [create()](/api_generated/Classes/classMLCore_1_1MLModelRegistry.md#function-create) calls.

function getAllModelNames

std::vector< std::string > getAllModelNames() const

Get names of all registered models.

function getModelNames

std::vector< std::string > getModelNames(
    MLTaskType task
) const

Get names of models that support a specific task type.

function hasModel

bool hasModel(
    std::string const & name
) const

Check if a model with the given name is registered.

function getTaskType

std::optional< MLTaskType > getTaskType(
    std::string const & name
) const

Get the task type of a registered model.

Return: The task type, or std::nullopt if not found

function size

std::size_t size() const

Number of registered models.

function create

std::unique_ptr< MLModelOperation > create(
    std::string const & name
) const

Create a new, untrained model instance by name.

Parameters:

  • name The registered model name

Return: A fresh model instance, or nullptr if the name is not found


Updated on 2026-11-13 at 20:25:41 +0000