File indexing completed on 2024-05-12 15:59:16
0001 /* 0002 * SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 0008 #ifndef _KIS_META_DATA_STORE_H_ 0009 #define _KIS_META_DATA_STORE_H_ 0010 0011 #include <kritametadata_export.h> 0012 0013 #include <QHash> 0014 0015 namespace KisMetaData 0016 { 0017 class Schema; 0018 class Entry; 0019 class Filter; 0020 class Value; 0021 0022 /** 0023 * This class holds the list of metadata entries and schemas (for instance the 0024 * author of the image, copyright holder, license, aperture, speed...) 0025 */ 0026 class KRITAMETADATA_EXPORT Store 0027 { 0028 struct Private; 0029 public: 0030 Store(); 0031 Store(const Store&); 0032 ~Store(); 0033 public: 0034 0035 /** 0036 * Copy the entries from store inside this store 0037 */ 0038 void copyFrom(const Store* store); 0039 0040 /** 0041 * @return true if there is no metadata in this store. 0042 */ 0043 bool empty() const; 0044 bool isEmpty() const; 0045 0046 0047 /** 0048 * Insert a new entry. 0049 * 0050 * @param entry the new entry to insert in the metadata store, it 0051 * must be a key which doesn't already exist 0052 * 0053 * @return false if the entry couldn't be included whether because the key already 0054 * exists 0055 */ 0056 bool addEntry(const Entry& entry); 0057 0058 /** 0059 * Give access to a metadata entry 0060 * @param entryKey the entryKey as the qualified name of the entry 0061 */ 0062 Entry& getEntry(const QString & entryKey); 0063 0064 /** 0065 * Give access to a metadata entry 0066 * @param uri the uri of the schema 0067 * @param entryName the name of the entry 0068 */ 0069 Entry& getEntry(const QString & uri, const QString & entryName); 0070 0071 /** 0072 * Give access to a metadata entry 0073 * @param schema the schema 0074 * @param entryName the name of the entry 0075 */ 0076 Entry& getEntry(const KisMetaData::Schema* schema, const QString & entryName); 0077 0078 /** 0079 * Give access to a metadata entry 0080 * @param entryKey the entryKey as the qualified name of the entry 0081 */ 0082 const Entry& getEntry(const QString & entryKey) const; 0083 /** 0084 * Give access to a metadata entry 0085 * @param uri the uri of the schema 0086 * @param entryName the name of the entry 0087 */ 0088 const Entry& getEntry(const QString & uri, const QString & entryName) const; 0089 0090 /** 0091 * Give access to a metadata entry 0092 * @param schema the schema 0093 * @param entryName the name of the entry 0094 */ 0095 const Entry& getEntry(const KisMetaData::Schema* schema, const QString & entryName) const; 0096 0097 /** 0098 * Remove an entry. 0099 * @param entryKey the entryKey as the qualified name of the entry 0100 */ 0101 void removeEntry(const QString & entryKey); 0102 0103 /** 0104 * Remove an entry. 0105 * @param uri the uri of the schema 0106 * @param entryName the name of the entry 0107 */ 0108 void removeEntry(const QString & uri, const QString & entryName); 0109 0110 /** 0111 * Remove an entry. 0112 * @param schema the schema 0113 * @param entryName the name of the entry 0114 */ 0115 void removeEntry(const KisMetaData::Schema* schema, const QString & entryName); 0116 0117 /** 0118 * Return the value associated with this entry name and uri. 0119 * @param uri 0120 * @param entryName 0121 * @return the value 0122 */ 0123 const Value& getValue(const QString & uri, const QString & entryName) const; 0124 0125 QHash<QString, Entry>::const_iterator begin() const; 0126 QHash<QString, Entry>::const_iterator end() const; 0127 0128 /** 0129 * @param entryKey the entryKey as the qualified name of the entry 0130 * @return true if an entry with the given key exist in the store 0131 */ 0132 bool containsEntry(const QString & entryKey) const; 0133 0134 /** 0135 * @return true if the store contains this entry 0136 */ 0137 bool containsEntry(const KisMetaData::Schema* schema, const QString & entryName) const; 0138 0139 /** 0140 * @param uri 0141 * @param entryName 0142 * @return true if an entry with the given uri and entry name exist in the store 0143 */ 0144 bool containsEntry(const QString & uri, const QString & entryName) const; 0145 0146 /** 0147 * Dump on kdDebug the metadata store. 0148 */ 0149 void debugDump() const; 0150 0151 /** 0152 * Apply a list of filters on a store 0153 */ 0154 void applyFilters(const QList<const Filter*> & filters); 0155 0156 /** 0157 * @return the list of keys 0158 */ 0159 QList<QString> keys() const; 0160 0161 /** 0162 * @return the list of entries 0163 */ 0164 QList<Entry> entries() const; 0165 private: 0166 Private* const d; 0167 }; 0168 } 0169 0170 #endif