Krita Source Code Documentation
Loading...
Searching...
No Matches
KisMetaData::Store Class Reference

#include <kis_meta_data_store.h>

Public Member Functions

bool addEntry (const Entry &entry)
 
void applyFilters (const QList< const Filter * > &filters)
 
QHash< QString, Entry >::const_iterator begin () const
 
bool containsEntry (const KisMetaData::Schema *schema, const QString &entryName) const
 
bool containsEntry (const QString &entryKey) const
 
bool containsEntry (const QString &uri, const QString &entryName) const
 
void copyFrom (const Store *store)
 
void debugDump () const
 
bool empty () const
 
QHash< QString, Entry >::const_iterator end () const
 
QList< Entryentries () const
 
EntrygetEntry (const KisMetaData::Schema *schema, const QString &entryName)
 
const EntrygetEntry (const KisMetaData::Schema *schema, const QString &entryName) const
 
EntrygetEntry (const QString &entryKey)
 
const EntrygetEntry (const QString &entryKey) const
 
EntrygetEntry (const QString &uri, const QString &entryName)
 
const EntrygetEntry (const QString &uri, const QString &entryName) const
 
const ValuegetValue (const QString &uri, const QString &entryName) const
 
bool isEmpty () const
 
QList< QString > keys () const
 
void removeEntry (const KisMetaData::Schema *schema, const QString &entryName)
 
void removeEntry (const QString &entryKey)
 
void removeEntry (const QString &uri, const QString &entryName)
 
 Store ()
 
 Store (const Store &)
 
 ~Store ()
 

Private Attributes

Private *const d
 

Detailed Description

This class holds the list of metadata entries and schemas (for instance the author of the image, copyright holder, license, aperture, speed...)

Definition at line 26 of file kis_meta_data_store.h.

Constructor & Destructor Documentation

◆ Store() [1/2]

Store::Store ( )

Definition at line 30 of file kis_meta_data_store.cc.

30 : d(new Private)
31{
32
33}

◆ Store() [2/2]

KisMetaData::Store::Store ( const Store & )

◆ ~Store()

Store::~Store ( )

Definition at line 40 of file kis_meta_data_store.cc.

41{
42 delete d;
43}

References d.

Member Function Documentation

◆ addEntry()

bool Store::addEntry ( const Entry & entry)

Insert a new entry.

Parameters
entrythe new entry to insert in the metadata store, it must be a key which doesn't already exist
Returns
false if the entry couldn't be included whether because the key already exists

Definition at line 60 of file kis_meta_data_store.cc.

61{
62 Q_ASSERT(!entry.name().isEmpty());
63 if (d->entries.contains(entry.qualifiedName()) && d->entries[entry.qualifiedName()].isValid()) {
64 dbgMetaData << "Entry" << entry.qualifiedName() << " already exists in the store, cannot be included twice";
65 return false;
66 }
67 d->entries.insert(entry.qualifiedName(), entry);
68 return true;
69}
#define dbgMetaData
Definition kis_debug.h:61

References d, dbgMetaData, KisMetaData::Entry::name(), and KisMetaData::Entry::qualifiedName().

◆ applyFilters()

void Store::applyFilters ( const QList< const Filter * > & filters)

Apply a list of filters on a store

Definition at line 188 of file kis_meta_data_store.cc.

189{
190 dbgMetaData << "Apply " << filters.size() << " filters";
191 Q_FOREACH (const Filter* filter, filters) {
192 filter->filter(this);
193 }
194}

References dbgMetaData, and KisMetaData::Filter::filter().

◆ begin()

QHash< QString, Entry >::const_iterator Store::begin ( ) const

Definition at line 165 of file kis_meta_data_store.cc.

166{
167 return d->entries.constBegin();
168}

References d.

◆ containsEntry() [1/3]

bool Store::containsEntry ( const KisMetaData::Schema * schema,
const QString & entryName ) const
Returns
true if the store contains this entry

Definition at line 92 of file kis_meta_data_store.cc.

93{
94 if (schema) {
95 return containsEntry(schema->generateQualifiedName(entryName));
96 }
97 return false;
98}
QString generateQualifiedName(const QString &) const
bool containsEntry(const QString &entryKey) const

References containsEntry(), and KisMetaData::Schema::generateQualifiedName().

◆ containsEntry() [2/3]

bool Store::containsEntry ( const QString & entryKey) const
Parameters
entryKeythe entryKey as the qualified name of the entry
Returns
true if an entry with the given key exist in the store

Definition at line 81 of file kis_meta_data_store.cc.

82{
83 return d->entries.contains(entryKey);
84}

References d.

◆ containsEntry() [3/3]

bool Store::containsEntry ( const QString & uri,
const QString & entryName ) const
Parameters
uri
entryName
Returns
true if an entry with the given uri and entry name exist in the store

Definition at line 86 of file kis_meta_data_store.cc.

87{
88 const Schema* schema = SchemaRegistry::instance()->schemaFromUri(uri);
89 return containsEntry(schema->generateQualifiedName(entryName));
90}
static KisMetaData::SchemaRegistry * instance()
const Schema * schemaFromUri(const QString &uri) const

References containsEntry(), KisMetaData::Schema::generateQualifiedName(), KisMetaData::SchemaRegistry::instance(), and KisMetaData::SchemaRegistry::schemaFromUri().

◆ copyFrom()

void Store::copyFrom ( const Store * store)

Copy the entries from store inside this store

Definition at line 45 of file kis_meta_data_store.cc.

46{
47 for (QHash<QString, Entry>::const_iterator entryIt = store->begin();
48 entryIt != store->end(); ++entryIt) {
49 const Entry& entry = entryIt.value();
50 if (entry.value().type() != KisMetaData::Value::Invalid) {
51 if (containsEntry(entry.qualifiedName())) {
52 getEntry(entry.qualifiedName()).value() = entry.value();
53 } else {
54 addEntry(entry);
55 }
56 }
57 }
58}
const KisMetaData::Value & value() const
bool addEntry(const Entry &entry)
Entry & getEntry(const QString &entryKey)
ValueType type() const

References addEntry(), begin(), containsEntry(), end(), getEntry(), KisMetaData::Value::Invalid, KisMetaData::Entry::qualifiedName(), KisMetaData::Value::type(), and KisMetaData::Entry::value().

◆ debugDump()

void Store::debugDump ( ) const

Dump on kdDebug the metadata store.

Definition at line 175 of file kis_meta_data_store.cc.

176{
177 dbgMetaData << "=== Dumping MetaData Store ===";
178 dbgMetaData << " - Metadata (there are" << d->entries.size() << " entries)";
179 Q_FOREACH (const Entry& e, d->entries) {
180 if (e.isValid()) {
181 dbgMetaData << e;
182 } else {
183 dbgMetaData << "Invalid entry";
184 }
185 }
186}

References d, dbgMetaData, and KisMetaData::Entry::isValid().

◆ empty()

bool Store::empty ( ) const
Returns
true if there is no metadata in this store.

Definition at line 71 of file kis_meta_data_store.cc.

72{
73 return d->entries.isEmpty();
74}

References d.

◆ end()

QHash< QString, Entry >::const_iterator Store::end ( ) const

Definition at line 170 of file kis_meta_data_store.cc.

171{
172 return d->entries.constEnd();
173}

References d.

◆ entries()

QList< Entry > KisMetaData::Store::entries ( ) const
Returns
the list of entries

◆ getEntry() [1/6]

Entry & Store::getEntry ( const KisMetaData::Schema * schema,
const QString & entryName )

Give access to a metadata entry

Parameters
schemathe schema
entryNamethe name of the entry

Definition at line 120 of file kis_meta_data_store.cc.

121{
122 return getEntry(schema->generateQualifiedName(entryName));
123}

References KisMetaData::Schema::generateQualifiedName(), and getEntry().

◆ getEntry() [2/6]

const Entry & Store::getEntry ( const KisMetaData::Schema * schema,
const QString & entryName ) const

Give access to a metadata entry

Parameters
schemathe schema
entryNamethe name of the entry

Definition at line 138 of file kis_meta_data_store.cc.

139{
140 return getEntry(schema->generateQualifiedName(entryName));
141}

References KisMetaData::Schema::generateQualifiedName(), and getEntry().

◆ getEntry() [3/6]

Entry & Store::getEntry ( const QString & entryKey)

Give access to a metadata entry

Parameters
entryKeythe entryKey as the qualified name of the entry

Definition at line 100 of file kis_meta_data_store.cc.

101{
102 if (!d->entries.contains(entryKey)) {
103 QStringList splitKey = entryKey.split(':');
104 QString prefix = splitKey[0];
105 splitKey.pop_front();
106 d->entries[entryKey] = Entry(SchemaRegistry::instance()->schemaFromPrefix(prefix),
107 splitKey.join(":"),
108 Value());
109 }
110 return d->entries [entryKey];
111}

References d, and KisMetaData::SchemaRegistry::instance().

◆ getEntry() [4/6]

const Entry & Store::getEntry ( const QString & entryKey) const

Give access to a metadata entry

Parameters
entryKeythe entryKey as the qualified name of the entry

Definition at line 126 of file kis_meta_data_store.cc.

127{
128 return d->entries[entryKey];
129}

References d.

◆ getEntry() [5/6]

Entry & Store::getEntry ( const QString & uri,
const QString & entryName )

Give access to a metadata entry

Parameters
urithe uri of the schema
entryNamethe name of the entry

Definition at line 113 of file kis_meta_data_store.cc.

114{
115 const Schema* schema = SchemaRegistry::instance()->schemaFromUri(uri);
116 Q_ASSERT(schema);
117 return getEntry(schema, entryName);
118}

References getEntry(), KisMetaData::SchemaRegistry::instance(), and KisMetaData::SchemaRegistry::schemaFromUri().

◆ getEntry() [6/6]

const Entry & Store::getEntry ( const QString & uri,
const QString & entryName ) const

Give access to a metadata entry

Parameters
urithe uri of the schema
entryNamethe name of the entry

Definition at line 131 of file kis_meta_data_store.cc.

132{
133 const Schema* schema = SchemaRegistry::instance()->schemaFromUri(uri);
134 Q_ASSERT(schema);
135 return getEntry(schema, entryName);
136}

References getEntry(), KisMetaData::SchemaRegistry::instance(), and KisMetaData::SchemaRegistry::schemaFromUri().

◆ getValue()

const Value & Store::getValue ( const QString & uri,
const QString & entryName ) const

Return the value associated with this entry name and uri.

Parameters
uri
entryName
Returns
the value

Definition at line 160 of file kis_meta_data_store.cc.

161{
162 return getEntry(uri, entryName).value();
163}

References getEntry(), and KisMetaData::Entry::value().

◆ isEmpty()

bool Store::isEmpty ( ) const

Definition at line 76 of file kis_meta_data_store.cc.

77{
78 return d->entries.isEmpty();
79}

References d.

◆ keys()

QList< QString > Store::keys ( ) const
Returns
the list of keys

Definition at line 196 of file kis_meta_data_store.cc.

197{
198 return d->entries.keys();
199}

References d.

◆ removeEntry() [1/3]

void Store::removeEntry ( const KisMetaData::Schema * schema,
const QString & entryName )

Remove an entry.

Parameters
schemathe schema
entryNamethe name of the entry

Definition at line 155 of file kis_meta_data_store.cc.

156{
157 removeEntry(schema->generateQualifiedName(entryName));
158}
void removeEntry(const QString &entryKey)

References KisMetaData::Schema::generateQualifiedName(), and removeEntry().

◆ removeEntry() [2/3]

void Store::removeEntry ( const QString & entryKey)

Remove an entry.

Parameters
entryKeythe entryKey as the qualified name of the entry

Definition at line 143 of file kis_meta_data_store.cc.

144{
145 d->entries.remove(entryKey);
146}

References d.

◆ removeEntry() [3/3]

void Store::removeEntry ( const QString & uri,
const QString & entryName )

Remove an entry.

Parameters
urithe uri of the schema
entryNamethe name of the entry

Definition at line 148 of file kis_meta_data_store.cc.

149{
150 const Schema* schema = SchemaRegistry::instance()->schemaFromUri(uri);
151 Q_ASSERT(schema);
152 removeEntry(schema, entryName);
153}

References KisMetaData::SchemaRegistry::instance(), removeEntry(), and KisMetaData::SchemaRegistry::schemaFromUri().

Member Data Documentation

◆ d

Private* const KisMetaData::Store::d
private

Definition at line 166 of file kis_meta_data_store.h.


The documentation for this class was generated from the following files: