TIOPluginHandler< I > Class Template Reference

Template for all plug-in handlers that are responsible for data IO. More...

#include <mia/core/iohandler.hh>

Inheritance diagram for TIOPluginHandler< I >:
[legend]
Collaboration diagram for TIOPluginHandler< I >:
[legend]

Public Types

typedef TPluginHandler< I >::const_iterator const_iterator
 an iterator over the available plug-ins More...
 
typedef std::multimap< std::string, std::string > CSuffixmap
 The map that maps file name suffixes to IO plug-ins. More...
 
typedef I::Data Data
 Data type handled by this plug-in. More...
 
typedef TDelayedParameter< PDataDataKey
 The type of the key used for the CDatapool access. More...
 
typedef TPluginHandler< I >::Interface Interface
 the IO interface provided by this handler More...
 
typedef std::shared_ptr< DataPData
 Shared pointer to the data hadnled by this plug-in. More...
 
- Public Types inherited from TPluginHandler< I >
typedef CPluginMap::const_iterator const_iterator
 the iterator to walk over the available plug-ins More...
 
typedef std::map< std::string, PInterfaceCPluginMap
 a map containing the names and the available plug-ins More...
 
typedef I Interface
 typedef for the plug-in interface provided by the class More...
 
typedef std::shared_ptr< I > PInterface
 

Public Member Functions

std::string get_preferred_suffix (const std::string &type) const
 
const CSuffixmapget_supported_filetype_map () const
 
const std::set< std::string > get_supported_suffix_set () const
 @ returns a saet containing the supported file type suffixes More...
 
const std::string get_supported_suffixes () const
 @ returns a string containing the supported file type suffixes More...
 
PData load (const std::string &fname) const
 
DataKey load_to_pool (const std::string &fname) const
 
const Interfacepreferred_plugin (const std::string &fname) const
 
const Interfacepreferred_plugin_ptr (const std::string &fname) const
 
bool save (const std::string &fname, const Data &data) const
 
- Public Member Functions inherited from TPluginHandler< I >
bool add_plugin (PInterface plugin)
 
const_iterator begin () const
 
const_iterator end () const
 
const std::string get_plugin_names () const
 
const std::set< std::string > get_set () const
 
size_t size () const
 
virtual ~TPluginHandler ()
 
- Public Member Functions inherited from CPluginHandlerBase
void add_dependend_handlers (HandlerHelpMap &handler_map) const
 
 CPluginHandlerBase (const char *data_descr, const char *type_descr)
 
 CPluginHandlerBase (const CPluginHandlerBase &other)=delete
 
const std::string & get_descriptor () const
 
std::string get_handler_type_string () const
 
void get_string_help_description_xml (std::ostream &os, CXMLElement &root) const
 
void get_xml_help (CXMLElement &root) const
 
CPluginHandlerBaseoperator= (const CPluginHandlerBase &other)=delete
 
void print_help (std::ostream &os) const
 
void print_short_help (std::ostream &os) const
 
bool validate_parameter_string (const std::string &s) const
 
virtual ~CPluginHandlerBase ()
 

Protected Member Functions

 TIOPluginHandler ()
 
- Protected Member Functions inherited from TPluginHandler< I >
void add_plugin_internal (PInterface plugin)
 
void initialise (const CPluginSearchpath &searchpath)
 
TPluginHandler< I >::Interfaceplugin (const char *plugin) const
 
 TPluginHandler ()
 Initializes the plugin handler based on the build-in search path. More...
 

Detailed Description

template<class I>
class TIOPluginHandler< I >

Template for all plug-in handlers that are responsible for data IO.

Input/Output plugin handler base class, derived privately from the standart plug-in handler to hide its interface. All IO plug-in handlers all proved a CDatapool as temporal storage to pass data around without disk-io.

Template Parameters
Ithe interface class that needs to be derived from TIOPlugin.

Definition at line 44 of file iohandler.hh.

Member Typedef Documentation

◆ const_iterator

template<class I>
typedef TPluginHandler<I>::const_iterator TIOPluginHandler< I >::const_iterator

an iterator over the available plug-ins

Definition at line 57 of file iohandler.hh.

◆ CSuffixmap

template<class I>
typedef std::multimap<std::string, std::string> TIOPluginHandler< I >::CSuffixmap

The map that maps file name suffixes to IO plug-ins.

Definition at line 60 of file iohandler.hh.

◆ Data

template<class I>
typedef I::Data TIOPluginHandler< I >::Data

Data type handled by this plug-in.

Definition at line 48 of file iohandler.hh.

◆ DataKey

template<class I>
typedef TDelayedParameter<PData> TIOPluginHandler< I >::DataKey

The type of the key used for the CDatapool access.

Definition at line 63 of file iohandler.hh.

◆ Interface

template<class I>
typedef TPluginHandler<I>::Interface TIOPluginHandler< I >::Interface

the IO interface provided by this handler

Definition at line 54 of file iohandler.hh.

◆ PData

template<class I>
typedef std::shared_ptr<Data > TIOPluginHandler< I >::PData

Shared pointer to the data hadnled by this plug-in.

Definition at line 51 of file iohandler.hh.

Constructor & Destructor Documentation

◆ TIOPluginHandler()

template<class I>
TIOPluginHandler< I >::TIOPluginHandler ( )
protected

constructor that is provided with a list of plugin search path.

Member Function Documentation

◆ get_preferred_suffix()

template<class I>
std::string TIOPluginHandler< I >::get_preferred_suffix ( const std::string &  type) const

Translate the file type decriptor to the file suffix.

Parameters
typetype descriptor (plugin name);
Returns
preferred suffix of the file type
Remarks
if the type is onkown it will throw and std::invalid_argument exception

◆ get_supported_filetype_map()

template<class I>
const CSuffixmap& TIOPluginHandler< I >::get_supported_filetype_map ( ) const
Returns
the a mapping of the supported file suffixes to their plugins

◆ get_supported_suffix_set()

template<class I>
const std::set<std::string> TIOPluginHandler< I >::get_supported_suffix_set ( ) const

@ returns a saet containing the supported file type suffixes

◆ get_supported_suffixes()

template<class I>
const std::string TIOPluginHandler< I >::get_supported_suffixes ( ) const

@ returns a string containing the supported file type suffixes

◆ load()

template<class I>
PData TIOPluginHandler< I >::load ( const std::string &  fname) const

Load data from a file. The suffix of fname is used to derive a preffered plug-in, which is then tried first. If this fails, all other plug-ins are tried as well.

Parameters
fnamethe file name
Returns
a shared pointer to the loaded data or an empty shared pointer if no data could be loaded.

◆ load_to_pool()

template<class I>
DataKey TIOPluginHandler< I >::load_to_pool ( const std::string &  fname) const

Load data from a file into the data pool, the key is the filename. The suffix of fname is used to derive a preffered plug-in, which is then tried first. If this fails, all other plug-ins are tried as well.

Parameters
fnamethe file name throws a std::runtime_error if loading fails

◆ preferred_plugin()

template<class I>
const Interface& TIOPluginHandler< I >::preferred_plugin ( const std::string &  fname) const

Search for the plug-in corresponding to the file name suffix, if the search fails, an std::invalid_argument exception is thrown.

Parameters
fnamea file name
Returns
the plug-in that is preferred for the suffix of fname

◆ preferred_plugin_ptr()

template<class I>
const Interface* TIOPluginHandler< I >::preferred_plugin_ptr ( const std::string &  fname) const

Tolerant search for the plug-in corresponding to the file name suffix

Parameters
fnamea file name
Returns
the plug-in that is preferred for the suffix of fname, or NULL if none was found.

◆ save()

template<class I>
bool TIOPluginHandler< I >::save ( const std::string &  fname,
const Data data 
) const

Save the data to a file. If type is empty, then the output plugin is derived from the fname suffix. if this fails, saving fails. If type is provided, the output plugin is selected accordingly.

Parameters
fnameoutput file name
datathe data to be saved
Returns
true if saving is successfull, false otherwise.

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