Neuralyzer::Transforms::V2::ElementRegistry
Neuralyzer::Transforms::V2::ElementRegistry
Registry for element-level transforms. More…
#include <ElementRegistry.hpp>
Public Classes
| Name | |
|---|---|
| struct | ContainerOps |
| struct | TimeSeriesOps |
Public Functions
| Name | |
|---|---|
| ElementRegistry() =default | |
| ElementRegistry(ElementRegistry const & ) =delete | |
| ElementRegistry & | operator=(ElementRegistry const & ) =delete |
| ElementRegistry(ElementRegistry && ) =default | |
| ElementRegistry & | operator=(ElementRegistry && ) =default |
| template <typename In ,typename Out ,typename Params > void |
registerTransform(std::string const & name, std::function< Out(In const &, Params const &)> func, TransformMetadata metadata ={}) Register single-input element transform with parameters. |
| template <typename In ,typename Out > void |
registerTransform(std::string const & name, std::function< Out(In const &)> func, TransformMetadata metadata ={}) Register stateless transform (no parameters). |
| template <typename In ,typename Out ,typename Params > void |
registerTimeGroupedTransform(std::string const & name, std::function< std::vector< Out >(std::span< In const >, Params const &)> func, TransformMetadata metadata ={}) Register time-grouped transform. |
| template <typename In ,typename Out > void |
registerTimeGroupedTransform(std::string const & name, std::function< std::vector< Out >(std::span< In const >)> func, TransformMetadata metadata ={}) Register stateless time-grouped transform (no parameters). |
| template <typename In1 ,typename In2 ,typename Out ,typename Params > void |
registerBinaryTransform(std::string const & name, std::function< Out(In1 const &, In2 const &, Params const &)> func, TransformMetadata metadata ={}) Register binary element transform. |
| template <typename In ,typename Out ,typename Params > Out |
execute(std::string const & name, In const & input, Params const & params, ComputeContext const & ctx ={}) const Execute single-input transform. |
| template <typename In1 ,typename In2 ,typename Out ,typename Params > Out |
executeBinary(std::string const & name, In1 const & input1, In2 const & input2, Params const & params, ComputeContext const & ctx ={}) const Execute binary transform. |
| template <typename In ,typename Out ,typename Params > std::vector< Out > |
executeTimeGrouped(std::string const & name, std::span< In const > inputs, Params const & params) const Execute time-grouped transform. |
| template <typename InContainer ,typename OutContainer ,typename Params > void |
registerContainerTransform(std::string const & name, std::function< std::shared_ptr< OutContainer >(InContainer const &, Params const &, ComputeContext const &)> func, ContainerTransformMetadata metadata ={}) Register a container-level transform. |
| template <typename InContainer ,typename OutContainer ,typename Params > std::shared_ptr< OutContainer > |
executeContainerTransform(std::string const & name, InContainer const & input, Params const & params, ComputeContext const & ctx ={}) const Execute a container transform. |
| bool | isContainerTransform(std::string const & name) const Check if a transform is a container transform. |
| ContainerTransformMetadata const * | getContainerMetadata(std::string const & name) const Get container transform metadata. |
| std::vector< std::string > | getContainerTransformsForInputType(std::type_index input_type) const Get all container transforms for an input type. |
| std::shared_ptr< IContainerExecutor > | createContainerExecutor(std::string const & name, std::any const & params_any) const Create a container executor from parameters. |
| DataTypeVariant | executeContainerTransformDynamic(std::string const & name, DataTypeVariant const & input_variant, std::any const & params_any, ComputeContext const & ctx ={}) const Execute container transform with dynamic parameter dispatch. |
| template <typename InContainer1 ,typename InContainer2 ,typename OutContainer ,typename Params > void |
registerBinaryContainerTransform(std::string const & name, std::function< std::shared_ptr< OutContainer >(InContainer1 const &, InContainer2 const &, Params const &, ComputeContext const &)> func, ContainerTransformMetadata metadata ={}) Register binary container transform. |
| template <typename InContainer1 ,typename InContainer2 ,typename OutContainer ,typename Params > std::shared_ptr< OutContainer > |
executeBinaryContainerTransform(std::string const & name, InContainer1 & input1, InContainer2 & input2, Params const & params, ComputeContext const & ctx ={}) const Execute binary container transform. |
| template <typename In ,typename Out ,typename Params > auto |
getTransformFunction(std::string const & name, Params const & params) const Get a callable transform function from the registry. |
| std::vector< std::string > | getTransformsForInputType(std::type_index input_type) const Get all transform names applicable to an input type. |
| std::vector< std::string > | getTransformsForOutputType(std::type_index output_type) const Get all transform names that produce an output type. |
| template <typename In ,typename Out > std::vector< std::string > |
getCompatibleTransforms() const Get all transform names that take In and produce Out. |
| TransformMetadata const * | getMetadata(std::string const & name) const Get metadata for a transform. |
| ParameterSchema const * | getParameterSchema(std::string const & transform_name) const Get the parameter schema for a transform by name. |
| ParameterSchema const * | getParameterSchemaByType(std::type_index params_type) const Get the parameter schema for a params type_index directly. |
| bool | hasTransform(std::string const & name) const Check if transform exists (element or container). |
| bool | hasElementTransform(std::string const & name) const Check if an element-level transform exists (not container). |
| std::vector< std::string > | getAllTransformNames() const Get all registered transform names. |
| template <typename Params > void |
registerParamDeserializer(std::function< std::any(std::string const &)> deserializer) Register JSON parameter deserializer for a parameter type. |
| std::any | deserializeParameters(std::string const & transform_name, std::string const & json_str) const Deserialize JSON parameters for a transform by name. |
| bool | validateParameters(std::string const & transform_name, std::any const & params_any) const Validate that parameters match the expected type for a transform. |
| template <typename In ,typename Out ,typename Params > void |
registerTypedExecutorFactory(std::function< std::unique_ptr< IParamExecutor >(std::any const &)> factory) Register a typed executor factory for a specific type signature. |
| template <typename In ,typename Out ,typename Params > void |
registerTimeGroupedExecutorFactory(std::function< std::unique_ptr< ITimeGroupedParamExecutor >(std::any const &)> factory) Register a typed time-grouped executor factory. |
| std::unique_ptr< IParamExecutor > | createTypedExecutor(TypeTriple const & key, std::any const & params) const Create a typed executor for given parameters. |
| std::unique_ptr< ITimeGroupedParamExecutor > | createTimeGroupedExecutor(TypeTriple const & key, std::any const & params) const Create a typed time-grouped executor for given parameters. |
| ElementVariant | executeWithDynamicParams(std::string const & transform_name, ElementVariant const & input_element, std::any const & params, std::type_index in_type, std::type_index out_type, std::type_index param_type) const Execute transform with typed executor (zero per-element dispatch). |
| ElementVariant | executeWithDynamicParamsAny(std::string const & transform_name, std::any const & input_element, std::any const & params, std::type_index in_type, std::type_index out_type, std::type_index param_type) const Execute transform with dynamic parameters and arbitrary input type. |
| BatchVariant | executeTimeGroupedWithDynamicParams(std::string const & transform_name, BatchVariant const & input_span, std::any const & params, std::type_index in_type, std::type_index out_type, std::type_index param_type) const Execute time-grouped transform with typed executor. |
| template <typename T > void |
registerContainerOps() Register container operations for a type T. |
| ContainerOps const & | getContainerOps(std::type_index type_idx) const Get container operations for a type. |
| template <typename Container > void |
registerTimeSeriesOps() Register time series operations for a container type. |
| TimeSeriesOps const & | getTimeSeriesOps(std::type_index type_idx) const Get time series operations for a type. |
| ElementRegistry & | instance() Get global singleton instance. |
Detailed Description
class Neuralyzer::Transforms::V2::ElementRegistry;Registry for element-level transforms.
Maintains a compile-time typed registry of transforms that operate on individual elements (Mask2D, Line2D, float, etc.).
Features:
- Type-safe registration and lookup
- Query by input/output types
- Automatic container lifting
- Metadata for UI generation
Public Functions Documentation
function ElementRegistry
ElementRegistry() =defaultfunction ElementRegistry
ElementRegistry(
ElementRegistry const &
) =deletefunction operator=
ElementRegistry & operator=(
ElementRegistry const &
) =deletefunction ElementRegistry
ElementRegistry(
ElementRegistry &&
) =defaultfunction operator=
ElementRegistry & operator=(
ElementRegistry &&
) =defaultfunction registerTransform
template <typename In ,
typename Out ,
typename Params >
inline void registerTransform(
std::string const & name,
std::function< Out(In const &, Params const &)> func,
TransformMetadata metadata ={}
)Register single-input element transform with parameters.
Parameters:
- name Unique transform name
- func Transform function
- metadata Optional metadata for UI
Template Parameters:
- In Input element type (e.g., Mask2D)
- Out Output element type (e.g., float)
- Params Parameter type (must be default constructible)
function registerTransform
template <typename In ,
typename Out >
inline void registerTransform(
std::string const & name,
std::function< Out(In const &)> func,
TransformMetadata metadata ={}
)Register stateless transform (no parameters).
function registerTimeGroupedTransform
template <typename In ,
typename Out ,
typename Params >
inline void registerTimeGroupedTransform(
std::string const & name,
std::function< std::vector< Out >(std::span< In const >, Params const &)> func,
TransformMetadata metadata ={}
)Register time-grouped transform.
Template Parameters:
- In Input element type (e.g., float)
- Out Output element type (e.g., float)
- Params Parameter type
For transforms that operate on all elements at a single time point. Signature: (span
Example: Sum reduction (span
function registerTimeGroupedTransform
template <typename In ,
typename Out >
inline void registerTimeGroupedTransform(
std::string const & name,
std::function< std::vector< Out >(std::span< In const >)> func,
TransformMetadata metadata ={}
)Register stateless time-grouped transform (no parameters).
function registerBinaryTransform
template <typename In1 ,
typename In2 ,
typename Out ,
typename Params >
inline void registerBinaryTransform(
std::string const & name,
std::function< Out(In1 const &, In2 const &, Params const &)> func,
TransformMetadata metadata ={}
)Register binary element transform.
Wraps binary function as tuple-input function for consistency.
function execute
template <typename In ,
typename Out ,
typename Params >
inline Out execute(
std::string const & name,
In const & input,
Params const & params,
ComputeContext const & ctx ={}
) constExecute single-input transform.
Exceptions:
- std::runtime_error if transform not found or type mismatch
function executeBinary
template <typename In1 ,
typename In2 ,
typename Out ,
typename Params >
inline Out executeBinary(
std::string const & name,
In1 const & input1,
In2 const & input2,
Params const & params,
ComputeContext const & ctx ={}
) constExecute binary transform.
function executeTimeGrouped
template <typename In ,
typename Out ,
typename Params >
inline std::vector< Out > executeTimeGrouped(
std::string const & name,
std::span< In const > inputs,
Params const & params
) constExecute time-grouped transform.
Exceptions:
- std::runtime_error if transform not found or type mismatch
function registerContainerTransform
template <typename InContainer ,
typename OutContainer ,
typename Params >
inline void registerContainerTransform(
std::string const & name,
std::function< std::shared_ptr< OutContainer >(InContainer const &, Params const &, ComputeContext const &)> func,
ContainerTransformMetadata metadata ={}
)Register a container-level transform.
Parameters:
- name Unique transform name
- func Transform function: (Container const&, Params const&, Context const&) -> shared_ptr
- metadata Optional metadata
Template Parameters:
- InContainer Input container type (e.g., AnalogTimeSeries)
- OutContainer Output container type (e.g., DigitalEventSeries)
- Params Parameter type
These are transforms that need full container access (temporal dependencies, etc.) Transform function should be pure: take concrete types, return concrete types. No virtual inheritance, no variants - pipeline handles type erasure.
function executeContainerTransform
template <typename InContainer ,
typename OutContainer ,
typename Params >
inline std::shared_ptr< OutContainer > executeContainerTransform(
std::string const & name,
InContainer const & input,
Params const & params,
ComputeContext const & ctx ={}
) constExecute a container transform.
Parameters:
- name Transform name
- input Input container (concrete type, not variant)
- params Parameters (concrete type, not type-erased)
- ctx Compute context for progress/cancellation
Exceptions:
- std::runtime_error if transform not found
Template Parameters:
- InContainer Input container type
- OutContainer Output container type
- Params Parameter type
Return: Shared pointer to output container
function isContainerTransform
bool isContainerTransform(
std::string const & name
) constCheck if a transform is a container transform.
function getContainerMetadata
ContainerTransformMetadata const * getContainerMetadata(
std::string const & name
) constGet container transform metadata.
function getContainerTransformsForInputType
std::vector< std::string > getContainerTransformsForInputType(
std::type_index input_type
) constGet all container transforms for an input type.
function createContainerExecutor
std::shared_ptr< IContainerExecutor > createContainerExecutor(
std::string const & name,
std::any const & params_any
) constCreate a container executor from parameters.
Parameters:
- name Transform name
- params_any Type-erased parameters (must match registered type)
Return: Shared pointer to IContainerExecutor, or nullptr if not found
Uses the registered factory to create a typed executor with captured parameters. Returns the IContainerExecutor interface for type-erased execution.
function executeContainerTransformDynamic
DataTypeVariant executeContainerTransformDynamic(
std::string const & name,
DataTypeVariant const & input_variant,
std::any const & params_any,
ComputeContext const & ctx ={}
) constExecute container transform with dynamic parameter dispatch.
Parameters:
- name Transform name
- input_variant Input data as DataTypeVariant
- params_any Type-erased parameters
- ctx Compute context
Exceptions:
- std::runtime_error if transform not found or execution fails
Return: Output data as DataTypeVariant
Creates an executor from the parameters and executes the transform. This is the primary entry point for dynamic container transform execution.
function registerBinaryContainerTransform
template <typename InContainer1 ,
typename InContainer2 ,
typename OutContainer ,
typename Params >
inline void registerBinaryContainerTransform(
std::string const & name,
std::function< std::shared_ptr< OutContainer >(InContainer1 const &, InContainer2 const &, Params const &, ComputeContext const &)> func,
ContainerTransformMetadata metadata ={}
)Register binary container transform.
Template Parameters:
- InContainer1 First input container type
- InContainer2 Second input container type
- OutContainer Output container type
- Params Parameter type
For container-level transforms that need two full containers as input and handle their own time alignment and ragged structure.
Example: AnalogIntervalPeak(DigitalIntervalSeries, AnalogTimeSeries) → DigitalEventSeries
function executeBinaryContainerTransform
template <typename InContainer1 ,
typename InContainer2 ,
typename OutContainer ,
typename Params >
inline std::shared_ptr< OutContainer > executeBinaryContainerTransform(
std::string const & name,
InContainer1 & input1,
InContainer2 & input2,
Params const & params,
ComputeContext const & ctx ={}
) constExecute binary container transform.
Parameters:
- name Transform name
- input1 First input container
- input2 Second input container
- params Parameters
- ctx Compute context
Return: Shared pointer to output container
function getTransformFunction
template <typename In ,
typename Out ,
typename Params >
inline auto getTransformFunction(
std::string const & name,
Params const & params
) constGet a callable transform function from the registry.
Parameters:
- name Transform name
- params Parameters to bind to the transform
Exceptions:
- std::runtime_error if transform not found
Template Parameters:
- In Input element type
- Out Output element type
- Params Parameter type
Return: Callable that applies the transform
Returns a lambda that captures the transform and parameters, allowing it to be used with standard algorithms or materializers.
function getTransformsForInputType
std::vector< std::string > getTransformsForInputType(
std::type_index input_type
) constGet all transform names applicable to an input type.
function getTransformsForOutputType
std::vector< std::string > getTransformsForOutputType(
std::type_index output_type
) constGet all transform names that produce an output type.
function getCompatibleTransforms
template <typename In ,
typename Out >
inline std::vector< std::string > getCompatibleTransforms() constGet all transform names that take In and produce Out.
function getMetadata
TransformMetadata const * getMetadata(
std::string const & name
) constGet metadata for a transform.
function getParameterSchema
ParameterSchema const * getParameterSchema(
std::string const & transform_name
) constGet the parameter schema for a transform by name.
Parameters:
- transform_name Name of the transform
Return: Pointer to ParameterSchema, or nullptr if not found
Returns the ParameterSchema describing all fields and their types, constraints, and UI hints for the transform’s parameter struct.
function getParameterSchemaByType
ParameterSchema const * getParameterSchemaByType(
std::type_index params_type
) constGet the parameter schema for a params type_index directly.
function hasTransform
bool hasTransform(
std::string const & name
) constCheck if transform exists (element or container).
function hasElementTransform
bool hasElementTransform(
std::string const & name
) constCheck if an element-level transform exists (not container).
function getAllTransformNames
std::vector< std::string > getAllTransformNames() constGet all registered transform names.
function registerParamDeserializer
template <typename Params >
inline void registerParamDeserializer(
std::function< std::any(std::string const &)> deserializer
)Register JSON parameter deserializer for a parameter type.
Parameters:
- deserializer Function that converts JSON string to std::any containing Params
Template Parameters:
- Params Parameter type
This allows the registry to deserialize JSON strings into typed parameters without needing a variant or manual dispatch.
function deserializeParameters
std::any deserializeParameters(
std::string const & transform_name,
std::string const & json_str
) constDeserialize JSON parameters for a transform by name.
Parameters:
- transform_name Name of the transform
- json_str JSON string containing parameters
Return: std::any containing typed parameters, or empty std::any on failure
Looks up the transform’s parameter type and uses the registered deserializer.
function validateParameters
bool validateParameters(
std::string const & transform_name,
std::any const & params_any
) constValidate that parameters match the expected type for a transform.
Parameters:
- transform_name Name of the transform
- params_any Type-erased parameters to validate
Return: true if parameters are valid for this transform
This checks that the std::any contains parameters of the correct type for the given transform, based on registered metadata.
function registerTypedExecutorFactory
template <typename In ,
typename Out ,
typename Params >
inline void registerTypedExecutorFactory(
std::function< std::unique_ptr< IParamExecutor >(std::any const &)> factory
)Register a typed executor factory for a specific type signature.
Parameters:
- factory Function that creates executor from type-erased params
Template Parameters:
- In Input element type
- Out Output element type
- Params Parameter type
The factory creates executors with parameters already captured, eliminating per-element parameter casts and type dispatch.
function registerTimeGroupedExecutorFactory
template <typename In ,
typename Out ,
typename Params >
inline void registerTimeGroupedExecutorFactory(
std::function< std::unique_ptr< ITimeGroupedParamExecutor >(std::any const &)> factory
)Register a typed time-grouped executor factory.
function createTypedExecutor
inline std::unique_ptr< IParamExecutor > createTypedExecutor(
TypeTriple const & key,
std::any const & params
) constCreate a typed executor for given parameters.
Parameters:
- key Type triple identifying the transform signature
- params Type-erased parameters
Return: Unique pointer to executor with captured state
Creates a fresh executor with parameters captured. No caching to avoid stale data issues with preprocessing.
function createTimeGroupedExecutor
inline std::unique_ptr< ITimeGroupedParamExecutor > createTimeGroupedExecutor(
TypeTriple const & key,
std::any const & params
) constCreate a typed time-grouped executor for given parameters.
Creates a fresh executor with parameters captured. No caching to avoid stale data issues with preprocessing.
function executeWithDynamicParams
inline ElementVariant executeWithDynamicParams(
std::string const & transform_name,
ElementVariant const & input_element,
std::any const & params,
std::type_index in_type,
std::type_index out_type,
std::type_index param_type
) constExecute transform with typed executor (zero per-element dispatch).
Parameters:
- transform_name Name of the transform
- input_element Input element (variant)
- params Parameters (type-erased)
- in_type Input element type
- out_type Output element type
- param_type Parameter type
Return: Output element (variant)
Creates fresh executor with captured parameters and types, eliminating all per-element casts and dispatch overhead.
function executeWithDynamicParamsAny
inline ElementVariant executeWithDynamicParamsAny(
std::string const & transform_name,
std::any const & input_element,
std::any const & params,
std::type_index in_type,
std::type_index out_type,
std::type_index param_type
) constExecute transform with dynamic parameters and arbitrary input type.
Used for the “Head” of the pipeline where input might be a tuple or other type not supported by ElementVariant.
function executeTimeGroupedWithDynamicParams
inline BatchVariant executeTimeGroupedWithDynamicParams(
std::string const & transform_name,
BatchVariant const & input_span,
std::any const & params,
std::type_index in_type,
std::type_index out_type,
std::type_index param_type
) constExecute time-grouped transform with typed executor.
function registerContainerOps
template <typename T >
inline void registerContainerOps()Register container operations for a type T.
Enables generic pipeline execution by providing type-erased access to vector
function getContainerOps
inline ContainerOps const & getContainerOps(
std::type_index type_idx
) constGet container operations for a type.
function registerTimeSeriesOps
template <typename Container >
inline void registerTimeSeriesOps()Register time series operations for a container type.
function getTimeSeriesOps
inline TimeSeriesOps const & getTimeSeriesOps(
std::type_index type_idx
) constGet time series operations for a type.
function instance
static inline ElementRegistry & instance()Get global singleton instance.
Return: Reference to the global registry
Updated on 2026-11-13 at 20:25:41 +0000