Marble

GeoTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
4// SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
5//
6
7#include "GeoTagWriter.h"
8
9#include "GeoWriter.h"
10
11#include <QDebug>
12
13namespace Marble
14{
15
16GeoTagWriter::GeoTagWriter() = default;
17
18GeoTagWriter::~GeoTagWriter() = default;
19
20bool GeoTagWriter::writeElement(const GeoNode *object, GeoWriter &writer)
21{
22 return writer.writeElement(object);
23}
24
25void GeoTagWriter::registerWriter(const QualifiedName &name, const GeoTagWriter *writer)
26{
27 TagHash *tagHash = tagWriterHash();
28
29 if (tagHash->contains(name)) {
30 qWarning()
31 << "Warning: The tag" << name
32 << "is already registered. Often this indicates that multiple versions of the marblewidget library are loaded at the same time. This will likely "
33 "lead to problems. Please check your installation, especially internal Marble plugins and external applications that install Marble plugins.";
34 }
35 Q_ASSERT(!tagHash->contains(name));
36 tagHash->insert(name, writer);
37 Q_ASSERT(tagHash->contains(name));
38}
39
40void GeoTagWriter::unregisterWriter(const GeoTagWriter::QualifiedName &qName)
41{
42 auto hash = tagWriterHash();
43 Q_ASSERT(hash->contains(qName));
44 delete hash->value(qName);
45 hash->remove(qName);
46 Q_ASSERT(!hash->contains(qName));
47}
48
49GeoTagWriter::TagHash *GeoTagWriter::tagWriterHash()
50{
51 static TagHash s_tagWriterHash;
52 return &s_tagWriterHash;
53}
54
55const GeoTagWriter *GeoTagWriter::recognizes(const QualifiedName &qname)
56{
57 TagHash *hash = tagWriterHash();
58
59 if (!hash->contains(qname)) {
60 return nullptr;
61 }
62
63 return hash->value(qname);
64}
65
66}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
QString name(StandardAction id)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.