KOSMIndoorMap

ioplugin.h
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef OSM_IOPLUGIN_H
7#define OSM_IOPLUGIN_H
8
9#include "kosm_export.h"
10#include "abstractwriter.h"
11
12#include <QtPlugin>
13
14#include <memory>
15
16namespace OSM {
17
18class AbstractReader;
19class AbstractWriter;
20class DataSet;
21
22/** Plugin interface for OSM file/data readers. */
23class KOSM_EXPORT IOPluginInterface
24{
25public:
26 virtual ~IOPluginInterface();
27
28 /** Create a new reader instance. */
29 [[nodiscard]] virtual std::unique_ptr<AbstractReader> createReader(OSM::DataSet *dataSet) = 0;
30 /** Create a new writer instance. */
31 [[nodiscard]] virtual std::unique_ptr<AbstractWriter> createWriter() = 0;
32};
33
34template <typename ReaderT, typename WriterT = std::nullptr_t>
35class IOPlugin : public IOPluginInterface
36{
37public:
38 [[nodiscard]] inline std::unique_ptr<AbstractReader> createReader(OSM::DataSet *dataSet) override
39 {
40 return std::make_unique<ReaderT>(dataSet);
41 }
42 [[nodiscard]] inline std::unique_ptr<AbstractWriter> createWriter() override
43 {
44 if constexpr(!std::is_same_v<WriterT, std::nullptr_t>) {
45 return std::make_unique<WriterT>();
46 }
47 return {};
48 }
49};
50
51}
52
53#define OSMIOPluginInteraface_iid "org.kde.kosm.IOPluginInterface/1.0"
54Q_DECLARE_INTERFACE(OSM::IOPluginInterface, OSMIOPluginInteraface_iid)
55
56#endif // OSM_IOPLUGIN_H
57
A set of nodes, ways and relations.
Definition datatypes.h:340
Plugin interface for OSM file/data readers.
Definition ioplugin.h:24
virtual std::unique_ptr< AbstractWriter > createWriter()=0
Create a new writer instance.
virtual std::unique_ptr< AbstractReader > createReader(OSM::DataSet *dataSet)=0
Create a new reader instance.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.