IFormatLoader
IFormatLoader
Interface for format-specific loaders. More…
#include <IFormatLoader.hpp>
Inherited by BinaryFormatLoader, CSVLoader, CapnProtoFormatLoader, HDF5FormatLoader, NumpyFormatLoader, OpenCVFormatLoader, Spike2PythonFormatLoader
Public Functions
| Name | |
|---|---|
| virtual | ~IFormatLoader() =default |
| virtual LoadResult | load(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const =0 Load a single data object from file. |
| virtual bool | supportsBatchLoading(std::string const & format, DM_DataType dataType) const Check if this loader supports batch loading for the given format/type. |
| virtual BatchLoadResult | loadBatch(std::string const & filepath, DM_DataType dataType, nlohmann::json const & config) const Load multiple data objects from a single file. |
| virtual LoadResult | save(std::string const & , DM_DataType , nlohmann::json const & , void const * ) const Save data to file (optional - not all loaders support saving). |
| virtual bool | supportsFormat(std::string const & format, DM_DataType dataType) const =0 Check if this loader supports the given format and data type. |
| virtual std::string | getLoaderName() const =0 Get the name of this loader (for logging/debugging). |
| virtual std::vector< SaverInfo > | getSaverInfo() const Return metadata for all save operations this loader supports. |
| virtual std::vector< LoaderInfo > | getLoaderInfo() const Return metadata for all load operations this loader supports. |
Detailed Description
class IFormatLoader;Interface for format-specific loaders.
Loaders now directly create data objects by linking to the data type libraries. This removes the need for the DataFactory abstraction.
The interface supports both single-object loading via load() and multi-object batch loading via loadBatch(). Loaders should override supportsBatchLoading() to indicate when they can return multiple objects from a single file.
Public Functions Documentation
function ~IFormatLoader
virtual ~IFormatLoader() =defaultfunction load
virtual LoadResult load(
std::string const & filepath,
DM_DataType dataType,
nlohmann::json const & config
) const =0Load a single data object from file.
Parameters:
- filepath Path to the file to load
- dataType Type of data being loaded
- config JSON configuration for loading
Return: LoadResult containing loaded data or error
Reimplemented by: BinaryFormatLoader::load, CapnProtoFormatLoader::load, CSVLoader::load, HDF5FormatLoader::load, NumpyFormatLoader::load, OpenCVFormatLoader::load, Spike2PythonFormatLoader::load
For files containing multiple data objects (e.g., multi-channel binary), this method returns only the first object. Use loadBatch() for full multi-object support.
function supportsBatchLoading
inline virtual bool supportsBatchLoading(
std::string const & format,
DM_DataType dataType
) constCheck if this loader supports batch loading for the given format/type.
Parameters:
- format Format string (e.g., “binary”, “csv”)
- dataType Type of data (e.g., DM_DataType::Analog)
Return: true if loadBatch() can return multiple objects for this combination
Reimplemented by: BinaryFormatLoader::supportsBatchLoading, CSVLoader::supportsBatchLoading, Spike2PythonFormatLoader::supportsBatchLoading
Batch loading allows a single file to produce multiple data objects. Examples: multi-channel binary files, multi-series CSV files, DLC files with multiple bodyparts.
function loadBatch
inline virtual BatchLoadResult loadBatch(
std::string const & filepath,
DM_DataType dataType,
nlohmann::json const & config
) constLoad multiple data objects from a single file.
Parameters:
- filepath Path to the file to load
- dataType Type of data being loaded
- config JSON configuration for loading
Return: BatchLoadResult containing all loaded data objects
Reimplemented by: BinaryFormatLoader::loadBatch, CSVLoader::loadBatch, Spike2PythonFormatLoader::loadBatch
This method is used for files that contain multiple data objects, such as multi-channel binary recordings or CSV files with multiple series.
The default implementation wraps load() in a BatchLoadResult. Loaders that support multi-object files should override this method and return all objects in the file.
function save
inline virtual LoadResult save(
std::string const & ,
DM_DataType ,
nlohmann::json const & ,
void const *
) constSave data to file (optional - not all loaders support saving).
Parameters:
- filepath Path where to save the file
- dataType Type of data being saved
- config JSON configuration for saving
- data Pointer to the data object to save
Return: LoadResult indicating success/failure (data field unused)
Reimplemented by: BinaryFormatLoader::save, CapnProtoFormatLoader::save, CSVLoader::save, OpenCVFormatLoader::save
function supportsFormat
virtual bool supportsFormat(
std::string const & format,
DM_DataType dataType
) const =0Check if this loader supports the given format and data type.
Parameters:
- format Format string (e.g., “csv”, “capnp”, “hdf5”)
- dataType Type of data (e.g., DM_DataType::Line, DM_DataType::Points)
Return: true if this loader can handle the format/dataType combination
Reimplemented by: BinaryFormatLoader::supportsFormat, CapnProtoFormatLoader::supportsFormat, CSVLoader::supportsFormat, HDF5FormatLoader::supportsFormat, NumpyFormatLoader::supportsFormat, OpenCVFormatLoader::supportsFormat, Spike2PythonFormatLoader::supportsFormat
function getLoaderName
virtual std::string getLoaderName() const =0Get the name of this loader (for logging/debugging).
Reimplemented by: BinaryFormatLoader::getLoaderName, CapnProtoFormatLoader::getLoaderName, CSVLoader::getLoaderName, HDF5FormatLoader::getLoaderName, NumpyFormatLoader::getLoaderName, OpenCVFormatLoader::getLoaderName, Spike2PythonFormatLoader::getLoaderName
function getSaverInfo
inline virtual std::vector< SaverInfo > getSaverInfo() constReturn metadata for all save operations this loader supports.
Return: Vector of SaverInfo (one per supported format/dataType save combination). Empty by default.
Reimplemented by: CapnProtoFormatLoader::getSaverInfo, CSVLoader::getSaverInfo, OpenCVFormatLoader::getSaverInfo
Subclasses that implement save() should override this to advertise their capabilities with typed parameter schemas.
function getLoaderInfo
inline virtual std::vector< LoaderInfo > getLoaderInfo() constReturn metadata for all load operations this loader supports.
Return: Vector of LoaderInfo (one per supported format/dataType load combination). Empty by default.
Reimplemented by: Spike2PythonFormatLoader::getLoaderInfo
Subclasses should override this to advertise their loading capabilities with typed parameter schemas, enabling automatic UI generation via AutoParamWidget.
Updated on 2026-11-13 at 20:25:40 +0000