Chemical Data Processing Library C++ API - Version 1.1.1
Public Types | Static Public Member Functions | List of all members
CDPL::Base::DataIOManager< T > Class Template Reference

A singleton class that serves as a global registry for Base::DataInputHandler and Base::DataOutputHandler implementation instances. More...

#include <DataIOManager.hpp>

Public Types

typedef DataInputHandler< T > InputHandlerType
 
typedef DataOutputHandler< T > OutputHandlerType
 
typedef InputHandlerType::SharedPointer InputHandlerPointer
 
typedef OutputHandlerType::SharedPointer OutputHandlerPointer
 
typedef InputHandlerList::iterator InputHandlerIterator
 An iterator used to iterate over the list of registered input handlers. More...
 
typedef OutputHandlerList::iterator OutputHandlerIterator
 An iterator used to iterate over the list of registered output handlers. More...
 

Static Public Member Functions

static void registerInputHandler (const InputHandlerPointer &handler)
 Registers the specified Base::DataInputHandler implementation instance. More...
 
static void registerOutputHandler (const OutputHandlerPointer &handler)
 Registers the specified Base::DataOutputHandler implementation instance. More...
 
static bool unregisterInputHandler (const DataFormat &fmt)
 Unregisters the Base::DataInputHandler implementation instance for the specified data format. More...
 
static bool unregisterOutputHandler (const DataFormat &fmt)
 Unregisters the Base::DataOutputHandler implementation instance for the specified data format. More...
 
static bool unregisterInputHandler (const InputHandlerPointer &handler)
 Unregisters the specified Base::DataInputHandler implementation instance. More...
 
static bool unregisterOutputHandler (const OutputHandlerPointer &handler)
 Unregisters the specified Base::DataOutputHandler implementation instance. More...
 
static void unregisterInputHandler (std::size_t idx)
 Unregisters the Base::DataInputHandler implementation instance with the specified index. More...
 
static void unregisterOutputHandler (std::size_t idx)
 Unregisters the Base::DataOutputHandler implementation instance with the specified index. More...
 
static InputHandlerIterator unregisterInputHandler (const InputHandlerIterator &it)
 Unregisters the Base::DataInputHandler implementation instance pointed to by the iterator it. More...
 
static OutputHandlerIterator unregisterOutputHandler (const OutputHandlerIterator &it)
 Unregisters the Base::DataOutputHandler implementation instance implementation instance pointed to by the iterator it. More...
 
static std::size_t getNumInputHandlers ()
 Returns the number of registered Base::DataInputHandler implementation instances. More...
 
static std::size_t getNumOutputHandlers ()
 Returns the number of registered Base::DataOutputHandler implementation instances. More...
 
static const InputHandlerPointergetInputHandler (std::size_t idx)
 Returns a reference to the registered Base::DataInputHandler implementation instance with the specified index. More...
 
static const OutputHandlerPointergetOutputHandler (std::size_t idx)
 Returns a reference to the registered Base::DataOutputHandler implementation instance with the specified index. More...
 
static InputHandlerIterator getInputHandlersBegin ()
 Returns an iterator pointing to the beginning of the list of registered Base::DataInputHandler implementation instances. More...
 
static InputHandlerIterator getInputHandlersEnd ()
 Returns an iterator pointing to the end of the list of registered Base::DataInputHandler implementation instances. More...
 
static OutputHandlerIterator getOutputHandlersBegin ()
 Returns an iterator pointing to the beginning of the list of registered Base::DataOutputHandler implementation instances. More...
 
static OutputHandlerIterator getOutputHandlersEnd ()
 Returns an iterator pointing to the end of the list of registered Base::DataOutputHandler implementation instances. More...
 
static InputHandlerPointer getInputHandlerByFormat (const DataFormat &fmt)
 Returns a pointer to a Base::DataInputHandler implementation instance registered for the specified data format. More...
 
static InputHandlerPointer getInputHandlerByName (const std::string &name)
 Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified name. More...
 
static InputHandlerPointer getInputHandlerByFileExtension (const std::string &file_ext)
 Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified file extension. More...
 
static InputHandlerPointer getInputHandlerByMimeType (const std::string &mime_type)
 Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified mime-type. More...
 
static OutputHandlerPointer getOutputHandlerByFormat (const DataFormat &fmt)
 Returns a pointer to a Base::DataOutputHandler implementation instance registered for the specified data format. More...
 
static OutputHandlerPointer getOutputHandlerByName (const std::string &name)
 Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified name. More...
 
static OutputHandlerPointer getOutputHandlerByFileExtension (const std::string &file_ext)
 Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified file extension. More...
 
static OutputHandlerPointer getOutputHandlerByMimeType (const std::string &mime_type)
 Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified mime-type. More...
 

Detailed Description

template<typename T>
class CDPL::Base::DataIOManager< T >

A singleton class that serves as a global registry for Base::DataInputHandler and Base::DataOutputHandler implementation instances.

DataIOManager provides static methods for the registration and lookup of Base::DataInputHandler and Base::DataOutputHandler implementation instances that handle different input and output storage formats for a specific object type (specified by the template parameter T).

Input and output handlers are registered by the methods registerInputHandler() and registerOutputHandler(). These methods expect a reference to an instance of the respective handler implementation as an argument (please note that the registered instance must not be destroyed as long as it is accessible via the DataIOManager interface!).

For the removal of registered handlers the unregisterInputHandler() and unregisterOutputHandler() family of overloaded methods is provided. These methods accept a reference to the registered handler instance, the handler index, the handled data format or an iterator pointing to the handler as an argument.

Registered input handlers can be queried by the methods getInputHandlerByFormat(), getInputHandlerByName(), getInputHandlerByFileExtension() and getInputHandlerByMimeType(), which allow to find a suitable handler for a given data format, data format name, file extension or mime-type. For the registered output handlers similar methods are provided.

I/O handlers for data formats and object types supported by the CDPL are registered in the static library initialization code. These built-in handlers are accessible by the linking client code as soon as the library initialization has finished.

Template Parameters
TThe type of the data objects for which the registered input and output handlers are parameterized.

Member Typedef Documentation

◆ InputHandlerType

template<typename T >
typedef DataInputHandler<T> CDPL::Base::DataIOManager< T >::InputHandlerType

◆ OutputHandlerType

template<typename T >
typedef DataOutputHandler<T> CDPL::Base::DataIOManager< T >::OutputHandlerType

◆ InputHandlerPointer

◆ OutputHandlerPointer

◆ InputHandlerIterator

template<typename T >
typedef InputHandlerList::iterator CDPL::Base::DataIOManager< T >::InputHandlerIterator

An iterator used to iterate over the list of registered input handlers.

◆ OutputHandlerIterator

template<typename T >
typedef OutputHandlerList::iterator CDPL::Base::DataIOManager< T >::OutputHandlerIterator

An iterator used to iterate over the list of registered output handlers.

Member Function Documentation

◆ registerInputHandler()

template<typename T >
void CDPL::Base::DataIOManager< T >::registerInputHandler ( const InputHandlerPointer handler)
static

Registers the specified Base::DataInputHandler implementation instance.

Parameters
handlerThe Base::DataInputHandler implementation instance to register.

◆ registerOutputHandler()

template<typename T >
void CDPL::Base::DataIOManager< T >::registerOutputHandler ( const OutputHandlerPointer handler)
static

Registers the specified Base::DataOutputHandler implementation instance.

Parameters
handlerThe Base::DataOutputHandler implementation instance to register.

◆ unregisterInputHandler() [1/4]

template<typename T >
bool CDPL::Base::DataIOManager< T >::unregisterInputHandler ( const DataFormat fmt)
static

Unregisters the Base::DataInputHandler implementation instance for the specified data format.

Only one handler instance at a time will be unregistered (in a first in - first out manner). If more than one handler instance has been registered for the given data format, the method has to be called multiple times to unregister all instances.

Parameters
fmtSpecifies the data format that is associated with the handler instance to unregister.
Returns
true if a handler instance for the specified data format was found and has been unregistered, and false otherwise.

◆ unregisterOutputHandler() [1/4]

template<typename T >
bool CDPL::Base::DataIOManager< T >::unregisterOutputHandler ( const DataFormat fmt)
static

Unregisters the Base::DataOutputHandler implementation instance for the specified data format.

Only one handler instance at a time will be unregistered (in a first in - first out manner). If more than one handler instance has been registered for the given data format, the method has to be called multiple times to unregister all instances.

Parameters
fmtSpecifies the data format that is associated with the handler instance to unregister.
Returns
true if a handler instance for the specified data format was found and has been unregistered, and false otherwise.

◆ unregisterInputHandler() [2/4]

template<typename T >
bool CDPL::Base::DataIOManager< T >::unregisterInputHandler ( const InputHandlerPointer handler)
static

Unregisters the specified Base::DataInputHandler implementation instance.

Parameters
handlerThe Base::DataInputHandler implementation instance to unregister.
Returns
true if the handler instance was found and has been unregistered, and false otherwise.

◆ unregisterOutputHandler() [2/4]

template<typename T >
bool CDPL::Base::DataIOManager< T >::unregisterOutputHandler ( const OutputHandlerPointer handler)
static

Unregisters the specified Base::DataOutputHandler implementation instance.

Parameters
handlerThe Base::DataOutputHandler implementation instance to unregister.
Returns
true if the handler instance was found and has been unregistered, and false otherwise.

◆ unregisterInputHandler() [3/4]

template<typename T >
void CDPL::Base::DataIOManager< T >::unregisterInputHandler ( std::size_t  idx)
static

Unregisters the Base::DataInputHandler implementation instance with the specified index.

Parameters
idxThe zero-based index of the Base::DataInputHandler implementation instance to unregister.
Exceptions
Base::IndexErrorif idx is out of bounds.

◆ unregisterOutputHandler() [3/4]

template<typename T >
void CDPL::Base::DataIOManager< T >::unregisterOutputHandler ( std::size_t  idx)
static

Unregisters the Base::DataOutputHandler implementation instance with the specified index.

Parameters
idxThe zero-based index of the Base::DataOutputHandler implementation instance to unregister.
Exceptions
Base::IndexErrorif idx is out of bounds.

◆ unregisterInputHandler() [4/4]

template<typename T >
CDPL::Base::DataIOManager< T >::InputHandlerIterator CDPL::Base::DataIOManager< T >::unregisterInputHandler ( const InputHandlerIterator it)
static

Unregisters the Base::DataInputHandler implementation instance pointed to by the iterator it.

Parameters
itAn iterator pointing to the Base::DataInputHandler implementation instance to unregister.
Exceptions
Base::RangeErrorif it is not in the range [getInputHandlersBegin(), getInputHandlersEnd() - 1].

◆ unregisterOutputHandler() [4/4]

template<typename T >
CDPL::Base::DataIOManager< T >::OutputHandlerIterator CDPL::Base::DataIOManager< T >::unregisterOutputHandler ( const OutputHandlerIterator it)
static

Unregisters the Base::DataOutputHandler implementation instance implementation instance pointed to by the iterator it.

Parameters
itAn iterator pointing to the Base::DataOutputHandler implementation instance to unregister.
Exceptions
Base::RangeErrorif it is not in the range [getOutputHandlersBegin(), getOutputHandlersEnd() - 1].

◆ getNumInputHandlers()

template<typename T >
std::size_t CDPL::Base::DataIOManager< T >::getNumInputHandlers
static

Returns the number of registered Base::DataInputHandler implementation instances.

Returns
The number of registered Base::DataInputHandler implementation instances.

◆ getNumOutputHandlers()

template<typename T >
std::size_t CDPL::Base::DataIOManager< T >::getNumOutputHandlers
static

Returns the number of registered Base::DataOutputHandler implementation instances.

Returns
The number of registered Base::DataOutputHandler implementation instances.

◆ getInputHandler()

template<typename T >
const CDPL::Base::DataInputHandler< T >::SharedPointer & CDPL::Base::DataIOManager< T >::getInputHandler ( std::size_t  idx)
static

Returns a reference to the registered Base::DataInputHandler implementation instance with the specified index.

Parameters
idxThe zero-based index of the Base::DataInputHandler implementation instance to return.
Returns
A reference to the Base::DataInputHandler implementation instance with the specified index.
Exceptions
Base::IndexErrorif idx is out of bounds.

◆ getOutputHandler()

template<typename T >
const CDPL::Base::DataOutputHandler< T >::SharedPointer & CDPL::Base::DataIOManager< T >::getOutputHandler ( std::size_t  idx)
static

Returns a reference to the registered Base::DataOutputHandler implementation instance with the specified index.

Parameters
idxThe zero-based index of the Base::DataOutputHandler implementation instance to return.
Returns
A reference to the Base::DataOutputHandler implementation instance with the specified index.
Exceptions
Base::IndexErrorif idx is out of bounds.

◆ getInputHandlersBegin()

template<typename T >
CDPL::Base::DataIOManager< T >::InputHandlerIterator CDPL::Base::DataIOManager< T >::getInputHandlersBegin
static

Returns an iterator pointing to the beginning of the list of registered Base::DataInputHandler implementation instances.

Returns
An iterator pointing to the beginning of the list of registered Base::DataInputHandler implementation instances.

◆ getInputHandlersEnd()

template<typename T >
CDPL::Base::DataIOManager< T >::InputHandlerIterator CDPL::Base::DataIOManager< T >::getInputHandlersEnd
static

Returns an iterator pointing to the end of the list of registered Base::DataInputHandler implementation instances.

Returns
An iterator pointing to the end of the list of registered Base::DataInputHandler implementation instances.

◆ getOutputHandlersBegin()

template<typename T >
CDPL::Base::DataIOManager< T >::OutputHandlerIterator CDPL::Base::DataIOManager< T >::getOutputHandlersBegin
static

Returns an iterator pointing to the beginning of the list of registered Base::DataOutputHandler implementation instances.

Returns
An iterator pointing to the beginning of the list of registered Base::DataOutputHandler implementation instances.

◆ getOutputHandlersEnd()

template<typename T >
CDPL::Base::DataIOManager< T >::OutputHandlerIterator CDPL::Base::DataIOManager< T >::getOutputHandlersEnd
static

Returns an iterator pointing to the end of the list of registered Base::DataOutputHandler implementation instances.

Returns
An iterator pointing to the end of the list of registered Base::DataOutputHandler implementation instances.

◆ getInputHandlerByFormat()

template<typename T >
CDPL::Base::DataInputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getInputHandlerByFormat ( const DataFormat fmt)
static

Returns a pointer to a Base::DataInputHandler implementation instance registered for the specified data format.

Parameters
fmtSpecifies the data format that is associated with the requested Base::DataInputHandler implementation instance.
Returns
A pointer to a Base::DataInputHandler implementation instance registered for the specified data format, or null if not available.

◆ getInputHandlerByName()

template<typename T >
CDPL::Base::DataInputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getInputHandlerByName ( const std::string &  name)
static

Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified name.

Parameters
nameSpecifies the name of the data format that is associated with the requested Base::DataInputHandler implementation instance.
Returns
A pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified name, or null if not available.
Note
The matching of the name is not case-sensitive.

◆ getInputHandlerByFileExtension()

template<typename T >
CDPL::Base::DataInputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getInputHandlerByFileExtension ( const std::string &  file_ext)
static

Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified file extension.

Parameters
file_extSpecifies the file extension of the data format that is associated with the requested Base::DataInputHandler implementation instance.
Returns
A pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified file extension, or null if not available.
Note
The matching of the file extension is not case-sensitive.

◆ getInputHandlerByMimeType()

template<typename T >
CDPL::Base::DataInputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getInputHandlerByMimeType ( const std::string &  mime_type)
static

Returns a pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified mime-type.

Parameters
mime_typeSpecifies the mime-type of the data format that is associated with the requested Base::DataInputHandler implementation instance.
Returns
A pointer to a Base::DataInputHandler implementation instance registered for the data format with the specified mime-type, or null if not available.
Note
The matching of the mime-type is not case-sensitive.

◆ getOutputHandlerByFormat()

template<typename T >
CDPL::Base::DataOutputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getOutputHandlerByFormat ( const DataFormat fmt)
static

Returns a pointer to a Base::DataOutputHandler implementation instance registered for the specified data format.

Parameters
fmtSpecifies the data format that is associated with the requested Base::DataOutputHandler implementation instance.
Returns
A pointer to a Base::DataOutputHandler implementation instance registered for the specified data format, or null if not available.

◆ getOutputHandlerByName()

template<typename T >
CDPL::Base::DataOutputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getOutputHandlerByName ( const std::string &  name)
static

Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified name.

Parameters
nameSpecifies the name of the data format that is associated with the requested Base::DataOutputHandler implementation instance.
Returns
A pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified name, or null if not available.
Note
The matching of the name is not case-sensitive.

◆ getOutputHandlerByFileExtension()

template<typename T >
CDPL::Base::DataOutputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getOutputHandlerByFileExtension ( const std::string &  file_ext)
static

Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified file extension.

Parameters
file_extSpecifies the file extension of the data format that is associated with the requested Base::DataOutputHandler implementation instance.
Returns
A pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified file extension, or null if not available.
Note
The matching of the file extension is not case-sensitive.

◆ getOutputHandlerByMimeType()

template<typename T >
CDPL::Base::DataOutputHandler< T >::SharedPointer CDPL::Base::DataIOManager< T >::getOutputHandlerByMimeType ( const std::string &  mime_type)
static

Returns a pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified mime-type.

Parameters
mime_typeSpecifies the mime-type of the data format that is associated with the requested Base::DataOutputHandler implementation instance.
Returns
A pointer to a Base::DataOutputHandler implementation instance registered for the data format with the specified mime-type, or null if not available.
Note
The matching of the mime-type is not case-sensitive.

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