File indexing completed on 2024-05-12 15:59:15
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net> 0003 * SPDX-FileCopyrightText: 2021 L. E. Segovia <amy@amyspark.me> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef _KIS_META_DATA_IO_BACKEND_H_ 0009 #define _KIS_META_DATA_IO_BACKEND_H_ 0010 0011 #include <kritametadata_export.h> 0012 0013 class QIODevice; 0014 class QString; 0015 0016 namespace KisMetaData 0017 { 0018 class Store; 0019 /** 0020 * This is a the interface for input or output backend to KisMetaData. 0021 * For instance, to add support to exif or xmp or iptc or dublin core 0022 * or anything else, it is needed to extend this interface. 0023 */ 0024 class KRITAMETADATA_EXPORT IOBackend 0025 { 0026 public: 0027 /** 0028 * Tell whether the backend input/output from/to binary data 0029 * or text (XML or RDF) data. 0030 */ 0031 enum BackendType { Binary, Text }; 0032 0033 enum HeaderType { 0034 NoHeader, ///< Don't append any header 0035 JpegHeader ///< Append Jpeg-style header 0036 }; 0037 0038 public: 0039 virtual ~IOBackend(){}; 0040 0041 virtual QString id() const = 0; 0042 0043 virtual QString name() const = 0; 0044 0045 /** 0046 * @return the type of the backend 0047 */ 0048 virtual BackendType type() const = 0; 0049 0050 /** 0051 * @return tell if this backend support saving 0052 */ 0053 virtual bool supportSaving() const = 0; 0054 0055 /** 0056 * @param store the list of metadata to save 0057 * @param ioDevice the device to where the metadata will be saved 0058 * @param headerType determine if an header must be prepend to the binary header, and if it does, 0059 * which type of header 0060 * @return true if the save was successful (XXX: actually, all backends always return true...) 0061 */ 0062 virtual bool saveTo(Store *store, QIODevice *ioDevice, HeaderType headerType = NoHeader) const = 0; 0063 0064 /** 0065 * @param store the list of metadata 0066 * @return true if this backend is capable of saving all the metadata 0067 * of the store 0068 */ 0069 virtual bool canSaveAllEntries(Store *store) const = 0; 0070 0071 /** 0072 * @return true if this backend support loading 0073 */ 0074 virtual bool supportLoading() const = 0; 0075 0076 /** 0077 * @param store the list of metadata to load 0078 * @param ioDevice the device from where the metadata will be loaded 0079 * @return true if the load was successful 0080 */ 0081 virtual bool loadFrom(Store *store, QIODevice *ioDevice) const = 0; 0082 }; 0083 } 0084 0085 #endif