Printer
Base template for printing objects to streams.
Defined in Rodin/IO/Printer.h
template < class T> class Printer;
| Template parameters | |
|---|---|
| T | Type of object to print |
Abstract base class template for printing objects to streams.
The Printer class provides a common interface for writing objects of type T to output streams. This class serves as the foundation for specialized printers that handle different file formats and object types.
Derived classes must implement:
- print(std::ostream&) - Write object to an output stream
- getObject() - Access the object being printed
Usage Example
class MyObjectPrinter : public Printer<MyObject> { public: MyObjectPrinter(const MyObject& obj) : m_object(obj) {} void print(std::ostream& os) override { // Write object to stream os << getObject(); } const ObjectType& getObject() const override { return m_object; } private: const MyObject& m_object; }; // Usage MyObject obj; MyObjectPrinter printer(obj); printer.print(std::cout);
Derived classes
| Derived class | Description |
|---|---|
GridFunctionPrinter<FileFormat::MFEM, …>publicFull typeGridFunctionPrinter< FileFormat::MFEM, Variational::H1< K, Range, Geometry::Mesh< Context::Local > >, ::Vec > | Printer template for grid functions with specific file format. |
GridFunctionPrinterBase<FileFormat::HDF5, …>publicFull typeGridFunctionPrinterBase< FileFormat::HDF5, FES, DataType > | Base class for concrete grid function printers. |
MeshPrinterBase<ContextType>publicFull typeMeshPrinterBase< ContextType > | Base class for printing meshes to streams or files. |
See moreSee less
| Derived class | Description |
|---|---|
GridFunctionPrinter<FileFormat::MFEM, …>publicFull typeGridFunctionPrinter< FileFormat::MFEM, Variational::H1< K, Range, Geometry::Mesh< Context::MPI > >, ::Vec > | Printer template for grid functions with specific file format. |
GridFunctionPrinter<FileFormat::MEDIT, …>publicFull typeGridFunctionPrinter< FileFormat::MEDIT, FES, Math::Vector< typename FormLanguage::Traits< FES >::ScalarType > > | MEDIT grid-function printer for vector-backed grid functions. |
GridFunctionPrinterBase<Format, …>publicFull typeGridFunctionPrinterBase< Format, FES, DataType > | Base class for concrete grid function printers. |
GridFunctionPrinterBase<FileFormat::MFEM, …>publicFull typeGridFunctionPrinterBase< FileFormat::MFEM, FES, DataType > | Base class for concrete grid function printers. |
GridFunctionPrinterBase<FileFormat::MFEM, …>publicFull typeGridFunctionPrinterBase< FileFormat::MFEM, FESType, DataType > | Base class for concrete grid function printers. |
GridFunctionPrinterBase<FileFormat::MEDIT, …>publicFull typeGridFunctionPrinterBase< FileFormat::MEDIT, FES, DataType > | Base class for concrete grid function printers. |
Public types
- using ObjectType = T
- Type of object being printed.
Constructors, destructors, conversion operators
- ~Printer() defaulted virtual
- Destroys the printer through its polymorphic interface.
Public functions
- void print(std::ostream& os) pure virtual
- Prints object to an output stream.
- void print(const boost::filesystem::path& filename) virtual
- Prints object to a file path.
- auto getObject() const -> const ObjectType& pure virtual
- Gets a const reference to the object being printed.
Function documentation
void print(std::ostream& os) pure virtual
Prints object to an output stream.
| Parameters | |
|---|---|
| os in/out | Output stream to write to |
This pure virtual method must be implemented by derived classes to write the object data to the provided stream.
void print(const boost::filesystem::path& filename) virtual
Prints object to a file path.
| Parameters | |
|---|---|
| filename in | Output file path. |
const ObjectType& getObject() const pure virtual
Gets a const reference to the object being printed.
| Returns | Const reference to the object |
|---|
This method provides read-only access to the object being written. Derived classes must implement this to return their internal object reference.