1 // SPDX-License-Identifier: LGPL-2.1-or-later 2 // 3 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org> 4 // 5 6 #ifndef MARBLE_GEOWRITERBACKEND_H 7 #define MARBLE_GEOWRITERBACKEND_H 8 9 #include "marble_export.h" 10 11 #include <QString> 12 13 class QIODevice; 14 15 namespace Marble 16 { 17 18 class GeoDataDocument; 19 20 class MARBLE_EXPORT GeoWriterBackend 21 { 22 public: 23 virtual ~GeoWriterBackend(); 24 25 /** 26 * Write the contents of the given document to the device. This method is to be implemented by plugins. 27 * @param device An I/O device open for writing 28 * @param document A GeoDataDocument with content to write 29 * @return True if the content is successfully written to the device, false otherwise 30 */ 31 virtual bool write(QIODevice* device, const GeoDataDocument &document) = 0; 32 }; 33 34 /** 35 * Helper class for writer backend registration. This class is commonly used through the MARBLE_ADD_WRITER macro 36 */ 37 class MARBLE_EXPORT GeoWriterBackendRegistrar 38 { 39 public: 40 GeoWriterBackendRegistrar(GeoWriterBackend* writer, const QString &fileExtension); 41 ~GeoWriterBackendRegistrar(); 42 43 private: 44 GeoWriterBackend* m_writer; 45 QString m_fileExtension; 46 }; 47 48 #ifndef STATIC_BUILD 49 #define MARBLE_ADD_WRITER(Class, fileExtension) \ 50 static GeoWriterBackendRegistrar s_##Class##Registrar(new Class, fileExtension); 51 #else 52 #define MARBLE_ADD_WRITER(Class, fileExtension) 53 #endif 54 55 } 56 57 #endif 58