Loader

Base template for loading objects from files or streams.

Defined in Rodin/IO/Loader.h

template <
  class T>
class Loader;
Template parameters
T Type of object to load

Abstract base class template for loading objects from streams or files.

The Loader class provides a common interface for reading objects of type T from input streams or files. This class serves as the foundation for specialized loaders that handle different file formats and object types.

Derived classes must implement:

Usage Example

class MyObjectLoader : public Loader<MyObject>
{
public:
  void load(std::istream& is) override
  {
    // Read from stream and populate object
    is >> getObject();
  }

protected:
  ObjectType& getObject() override
  {
    return m_object;
  }

private:
  MyObject m_object;
};
Direct inheritance by class family
Loader
↓

Derived classes

Derived classDescription
GridFunctionLoader<FileFormat::HDF5, …>public
Full type
GridFunctionLoader< FileFormat::HDF5, FES, Math::Vector< Scalar > >
HDF5 grid function loader for local grid functions backed by Math::Vector<Scalar>.
GridFunctionLoaderBase<FES, DataType>public
Full type
GridFunctionLoaderBase< FES, DataType >
Base class for concrete grid function loaders.
MeshLoaderBase<ContextType>public
Full type
MeshLoaderBase< ContextType >
Base class for loading meshes from files or streams.
See moreSee less
Derived classDescription
GridFunctionLoader<FileFormat::MEDIT, …>public
Full type
GridFunctionLoader< FileFormat::MEDIT, FES, Math::Vector< typename FormLanguage::Traits< FES >::ScalarType > >
Reads matrix entries stored as independent MEDIT scalar vertex fields. Higher-order spaces interpolate the vertex field, as required by SolAtVertices.
GridFunctionLoader<FileFormat::MEDIT, …>public
Full type
GridFunctionLoader< FileFormat::MEDIT, Variational::H1< K, Range, Geometry::Mesh< Context::Local > >, Math::Vector< typename FormLanguage::Traits< Range >::ScalarType > >
MEDIT grid-function loader for local H1 finite element spaces.
GridFunctionLoader<FileFormat::MEDIT, …>public
Full type
GridFunctionLoader< FileFormat::MEDIT, Variational::P1< Range, Geometry::Mesh< Context::Local > >, Math::Vector< typename FormLanguage::Traits< Range >::ScalarType > >
MEDIT grid-function loader for local P1 finite element spaces.
GridFunctionLoader<FileFormat::MFEM, …>public
Full type
GridFunctionLoader< FileFormat::MFEM, FES, Math::Vector< Scalar > >
Loads each MFEM component through the scalar family's node mapping.
GridFunctionLoader<FileFormat::MFEM, …>public
Full type
GridFunctionLoader< FileFormat::MFEM, Variational::H1< K, Range, Geometry::Mesh< Context::Local > >, Math::Vector< typename FormLanguage::Traits< Range >::ScalarType > >
Specialization for loading H1 grid functions from MFEM format.
GridFunctionLoader<FileFormat::MFEM, …>public
Full type
GridFunctionLoader< FileFormat::MFEM, Variational::P0< Range, Geometry::Mesh< Context::Local > >, Math::Vector< typename FormLanguage::Traits< Range >::ScalarType > >
Loader for P0 (piecewise constant) grid functions in MFEM format.
GridFunctionLoader<FileFormat::MFEM, …>public
Full type
GridFunctionLoader< FileFormat::MFEM, Variational::P1< Range, Geometry::Mesh< Context::Local > >, Math::Vector< typename FormLanguage::Traits< Range >::ScalarType > >
Specialization for loading P1 grid functions from MFEM format.
GridFunctionLoaderBase<FESType, …>public
Full type
GridFunctionLoaderBase< FESType, DataType >
Base class for concrete grid function loaders.
GridFunctionLoaderBase<FES, …>public
Full type
GridFunctionLoaderBase< FES, Math::Vector< ScalarType > >
Base class for concrete grid function loaders.
GridFunctionLoaderBase<FES, …>public
Full type
GridFunctionLoaderBase< FES, Math::Vector< Scalar > >
Base class for concrete grid function loaders.

Public types

using ObjectType = T
Type of object being loaded.

Constructors, destructors, conversion operators

~Loader() defaulted virtual
Destroys the loader through its polymorphic interface.

Public functions

void load(std::istream& is) pure virtual
Loads object from an input stream.
void load(const boost::filesystem::path& is) virtual
Loads object from a file.

Protected functions

auto getObject() -> ObjectType& pure virtual
Gets a reference to the object being loaded.

Function documentation

void load(std::istream& is) pure virtual

Loads object from an input stream.

Parameters
is in Input stream to read from

This pure virtual method must be implemented by derived classes to read the object data from the provided stream.

void load(const boost::filesystem::path& is) virtual

Loads object from a file.

Parameters
is in Path to the file to load

Opens the file at the specified path and delegates to load(std::istream&). This provides a convenient file-based interface while reusing the stream loading logic.

ObjectType& getObject() pure virtual protected

Gets a reference to the object being loaded.

Returns Reference to the object

This method provides access to the object being populated during loading. Derived classes must implement this to return their internal object reference.