Mapper  0.9.0
API documentation
Public Member Functions | List of all members
OpenOrienteering::FileFormatRegistry Class Reference

Provides a registry for file formats, and takes ownership of the supported format objects. More...

#include <file_format_registry.h>

Public Member Functions

 FileFormatRegistry () noexcept
 Creates an empty file format registry. More...
 
 FileFormatRegistry (const FileFormatRegistry &)=delete
 
 ~FileFormatRegistry ()
 Destroys a file format registry. More...
 
FileFormatRegistry & operator= (const FileFormatRegistry &)=delete
 
const std::vector< FileFormat * > & formats () const
 Returns an immutable list of the available file formats. More...
 
const FileFormat * findFormat (std::function< bool(const FileFormat *)> predicate) const
 Finds a file format which satisfies the given predicate, or returns nullptr if no format is found. More...
 
const FileFormat * findFormat (const char *id) const
 Finds a file format with the given internal ID, or returns nullptr if no format is found. More...
 
const FileFormat * findFormatByFilter (const QString &filter, bool(FileFormat::*predicate)() const) const
 Finds a file format which implements the given filter, or returns nullptr if no format is found. More...
 
const FileFormat * findFormatForFilename (const QString &filename, bool(FileFormat::*predicate)() const) const
 Finds a file format whose file extension matches the file extension of the given path, or returns nullptr if no matching format is found. More...
 
const FileFormat * findFormatForData (const QString &path, FileFormat::FileTypes types) const
 Finds an import file format by looking at the existing data. More...
 
const char * defaultFormat () const
 Returns the ID of default file format for this registry. More...
 
void registerFormat (FileFormat *format)
 Registers a new file format. More...
 
std::unique_ptr< FileFormat > unregisterFormat (const FileFormat *format)
 Unregisters a file format. More...
 
std::unique_ptr< Importer > makeImporter (const QString &path, Map &map, MapView *view=nullptr)
 Creates an importer for the given path, if possible. More...
 
std::unique_ptr< Exporter > makeExporter (const QString &path, const Map *map, const MapView *view)
 Creates an exporter for the given path, if possible. More...
 

Detailed Description

Provides a registry for file formats, and takes ownership of the supported format objects.

Constructor & Destructor Documentation

◆ FileFormatRegistry() [1/2]

OpenOrienteering::FileFormatRegistry::FileFormatRegistry ( )
noexcept

Creates an empty file format registry.

◆ FileFormatRegistry() [2/2]

OpenOrienteering::FileFormatRegistry::FileFormatRegistry ( const FileFormatRegistry &  )
delete

◆ ~FileFormatRegistry()

OpenOrienteering::FileFormatRegistry::~FileFormatRegistry ( )

Destroys a file format registry.

Member Function Documentation

◆ defaultFormat()

const char* OpenOrienteering::FileFormatRegistry::defaultFormat ( ) const
inline

Returns the ID of default file format for this registry.

This will automatically be set to the first registered format.

◆ findFormat() [1/2]

const FileFormat * OpenOrienteering::FileFormatRegistry::findFormat ( std::function< bool(const FileFormat *)>  predicate) const

Finds a file format which satisfies the given predicate, or returns nullptr if no format is found.

◆ findFormat() [2/2]

const FileFormat * OpenOrienteering::FileFormatRegistry::findFormat ( const char *  id) const

Finds a file format with the given internal ID, or returns nullptr if no format is found.

◆ findFormatByFilter()

const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatByFilter ( const QString &  filter,
bool(FileFormat::*)() const  predicate 
) const

Finds a file format which implements the given filter, or returns nullptr if no format is found.

Only the file format's filter string before the closing ')' is taken into account for matching, i.e. the given parameter 'filter' may contain additional extensions following the original ones.

The predicate is intended to select either import or export formats.

◆ findFormatForData()

const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatForData ( const QString &  path,
FileFormat::FileTypes  types 
) const

Finds an import file format by looking at the existing data.

◆ findFormatForFilename()

const FileFormat * OpenOrienteering::FileFormatRegistry::findFormatForFilename ( const QString &  filename,
bool(FileFormat::*)() const  predicate 
) const

Finds a file format whose file extension matches the file extension of the given path, or returns nullptr if no matching format is found.

The predicate is intended to select either import or export formats.

◆ formats()

const std::vector<FileFormat *>& OpenOrienteering::FileFormatRegistry::formats ( ) const
inline

Returns an immutable list of the available file formats.

◆ makeExporter()

std::unique_ptr< Exporter > OpenOrienteering::FileFormatRegistry::makeExporter ( const QString &  path,
const Map *  map,
const MapView *  view 
)

Creates an exporter for the given path, if possible.

◆ makeImporter()

std::unique_ptr< Importer > OpenOrienteering::FileFormatRegistry::makeImporter ( const QString &  path,
Map &  map,
MapView *  view = nullptr 
)

Creates an importer for the given path, if possible.

◆ operator=()

FileFormatRegistry& OpenOrienteering::FileFormatRegistry::operator= ( const FileFormatRegistry &  )
delete

◆ registerFormat()

void OpenOrienteering::FileFormatRegistry::registerFormat ( FileFormat *  format)

Registers a new file format.

The registry takes ownership of the provided Format.

◆ unregisterFormat()

std::unique_ptr< FileFormat > OpenOrienteering::FileFormatRegistry::unregisterFormat ( const FileFormat *  format)

Unregisters a file format.

Returns a non-const pointer to the file format and transfers ownership to the caller.


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