File indexing completed on 2025-01-05 03:59:12
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2016 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 #ifndef MARBLE_GEOWRITERBACKEND_H 0007 #define MARBLE_GEOWRITERBACKEND_H 0008 0009 #include "digikam_export.h" 0010 0011 #include <QString> 0012 0013 class QIODevice; 0014 0015 namespace Marble 0016 { 0017 0018 class GeoDataDocument; 0019 0020 class DIGIKAM_EXPORT GeoWriterBackend 0021 { 0022 public: 0023 virtual ~GeoWriterBackend(); 0024 0025 /** 0026 * Write the contents of the given document to the device. This method is to be implemented by plugins. 0027 * @param device An I/O device open for writing 0028 * @param document A GeoDataDocument with content to write 0029 * @return True if the content is successfully written to the device, false otherwise 0030 */ 0031 virtual bool write(QIODevice* device, const GeoDataDocument &document) = 0; 0032 }; 0033 0034 /** 0035 * Helper class for writer backend registration. This class is commonly used through the MARBLE_ADD_WRITER macro 0036 */ 0037 class DIGIKAM_EXPORT GeoWriterBackendRegistrar 0038 { 0039 public: 0040 GeoWriterBackendRegistrar(GeoWriterBackend* writer, const QString &fileExtension); 0041 ~GeoWriterBackendRegistrar(); 0042 0043 private: 0044 GeoWriterBackend* m_writer; 0045 QString m_fileExtension; 0046 }; 0047 0048 #ifndef STATIC_BUILD 0049 #define MARBLE_ADD_WRITER(Class, fileExtension) \ 0050 static GeoWriterBackendRegistrar s_##Class##Registrar(new Class, fileExtension); 0051 #else 0052 #define MARBLE_ADD_WRITER(Class, fileExtension) 0053 #endif 0054 0055 } 0056 0057 #endif