Marble

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

KDE's Doxygen guidelines are available online.