Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
correlation::writers::WriterFactory Class Reference

Registry for all file writers, enabling automatic discovery. More...

#include <WriterFactory.hpp>

Public Member Functions

bool registerWriter (std::unique_ptr< BaseWriter > writer)
 Registers a new writer.
BaseWriter * getWriterForExtension (const std::string &extension)
 Finds a writer that supports the given file extension.
const std::vector< std::unique_ptr< BaseWriter > > & getWriters () const
 Returns all registered writers.
BaseWriter * getWriter (const std::string &name)
 Gets a writer by its name.

Static Public Member Functions

static WriterFactory & instance ()
template<typename T>
static bool registerTypeSafe (const char *name) noexcept
 Exception-safe template helper for static auto-registration.

Private Member Functions

 WriterFactory ()=default

Private Attributes

std::vector< std::unique_ptr< BaseWriter > > writers_
 Storage for writer instances.
std::map< std::string, BaseWriter * > extension_map_
 Lookup map for file extensions.
std::map< std::string, BaseWriter * > name_map_
 Lookup map for format names.

Detailed Description

Registry for all file writers, enabling automatic discovery.

Constructor & Destructor Documentation

◆ WriterFactory()

correlation::writers::WriterFactory::WriterFactory ( )
privatedefault
Here is the caller graph for this function:

Member Function Documentation

◆ getWriter()

BaseWriter * correlation::writers::WriterFactory::getWriter ( const std::string & name)

Gets a writer by its name.

Parameters
nameThe name of the writer.
Returns
Pointer to the writer, or nullptr if not found.
Here is the caller graph for this function:

◆ getWriterForExtension()

BaseWriter * correlation::writers::WriterFactory::getWriterForExtension ( const std::string & extension)

Finds a writer that supports the given file extension.

Parameters
extensionThe file extension (e.g., ".csv").
Returns
A pointer to the writer instance, or nullptr if not found.
Here is the caller graph for this function:

◆ getWriters()

const std::vector< std::unique_ptr< BaseWriter > > & correlation::writers::WriterFactory::getWriters ( ) const

Returns all registered writers.

Returns
Constant reference to the internal vector of writers.

◆ instance()

WriterFactory & correlation::writers::WriterFactory::instance ( )
static
Returns
Singleton instance of the WriterFactory.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerTypeSafe()

template<typename T>
bool correlation::writers::WriterFactory::registerTypeSafe ( const char * name)
inlinestaticnoexcept

Exception-safe template helper for static auto-registration.

Template Parameters
TThe specific Writer class type to instantiate.
Parameters
nameThe human-readable name of the writer (for error logging).
Returns
true if registration succeeded, false if an exception occurred.
Here is the call graph for this function:

◆ registerWriter()

bool correlation::writers::WriterFactory::registerWriter ( std::unique_ptr< BaseWriter > writer)

Registers a new writer.

Parameters
writerUnique pointer to the writer instance.
Returns
true if registration was successful.
Here is the caller graph for this function:

Member Data Documentation

◆ extension_map_

std::map<std::string, BaseWriter *> correlation::writers::WriterFactory::extension_map_
private

Lookup map for file extensions.

◆ name_map_

std::map<std::string, BaseWriter *> correlation::writers::WriterFactory::name_map_
private

Lookup map for format names.

◆ writers_

std::vector<std::unique_ptr<BaseWriter> > correlation::writers::WriterFactory::writers_
private

Storage for writer instances.


The documentation for this class was generated from the following files: