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

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

#include <ReaderFactory.hpp>

Inheritance diagram for correlation::readers::ReaderFactory:
Collaboration diagram for correlation::readers::ReaderFactory:

Public Member Functions

bool registerReader (std::unique_ptr< BaseReader > reader)
 Registers a new reader.
BaseReader * getReaderForExtension (const ReaderExtensionQuery &query) const override
 Finds a reader that supports the given file extension.
BaseReader * getReaderForExtension (std::string_view extension) const override
 Finds a reader that supports the given file extension.
std::vector< std::string > getAllExtensions () const override
 Returns all registered extensions.
const std::vector< std::unique_ptr< BaseReader > > & getReaders () const override
 Returns all registered readers.
Public Member Functions inherited from correlation::readers::IReaderRegistry
 IReaderRegistry ()=default
virtual ~IReaderRegistry ()=default
 IReaderRegistry (const IReaderRegistry &)=delete
IReaderRegistry & operator= (const IReaderRegistry &)=delete
 IReaderRegistry (IReaderRegistry &&)=delete
IReaderRegistry & operator= (IReaderRegistry &&)=delete

Static Public Member Functions

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

Private Member Functions

 ReaderFactory ()=default

Private Attributes

std::vector< std::unique_ptr< BaseReader > > readers_
 Storage for reader instances.
std::map< std::string, BaseReader * > extension_map_
 Lookup map for file extensions.

Detailed Description

Registry for all file readers, enabling automatic discovery.

Constructor & Destructor Documentation

◆ ReaderFactory()

correlation::readers::ReaderFactory::ReaderFactory ( )
privatedefault
Here is the caller graph for this function:

Member Function Documentation

◆ getAllExtensions()

std::vector< std::string > correlation::readers::ReaderFactory::getAllExtensions ( ) const
nodiscardoverridevirtual

Returns all registered extensions.

Returns
A vector of extension strings (e.g., {".car", ".arc"}).

Implements correlation::readers::IReaderRegistry.

◆ getReaderForExtension() [1/2]

BaseReader * correlation::readers::ReaderFactory::getReaderForExtension ( const ReaderExtensionQuery & query) const
nodiscardoverridevirtual

Finds a reader that supports the given file extension.

Parameters
queryThe reader extension query parameters.
Returns
A pointer to the reader instance, or nullptr if not found.

Implements correlation::readers::IReaderRegistry.

Here is the caller graph for this function:

◆ getReaderForExtension() [2/2]

BaseReader * correlation::readers::ReaderFactory::getReaderForExtension ( std::string_view extension) const
nodiscardoverridevirtual

Finds a reader that supports the given file extension.

Parameters
extensionThe file extension (e.g., ".car", ".cif").
Returns
A pointer to the reader instance, or nullptr if not found.

Implements correlation::readers::IReaderRegistry.

Here is the call graph for this function:

◆ getReaders()

const std::vector< std::unique_ptr< BaseReader > > & correlation::readers::ReaderFactory::getReaders ( ) const
nodiscardoverridevirtual

Returns all registered readers.

Returns
Constant reference to the internal vector of readers.

Implements correlation::readers::IReaderRegistry.

◆ instance()

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

◆ registerReader()

bool correlation::readers::ReaderFactory::registerReader ( std::unique_ptr< BaseReader > reader)

Registers a new reader.

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

◆ registerTypeSafe()

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

Exception-safe template helper for static auto-registration.

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

Member Data Documentation

◆ extension_map_

std::map<std::string, BaseReader *> correlation::readers::ReaderFactory::extension_map_
private

Lookup map for file extensions.

◆ readers_

std::vector<std::unique_ptr<BaseReader> > correlation::readers::ReaderFactory::readers_
private

Storage for reader instances.


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