Marble

GeoTagWriter.cpp
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Andrew Manson <[email protected]>
9 // Copyright (C) 2007, 2008 Nikolas Zimmermann <[email protected]>
10 //
11 
12 #include "GeoTagWriter.h"
13 
14 #include "GeoWriter.h"
15 
16 #include <QDebug>
17 
18 namespace Marble
19 {
20 
21 GeoTagWriter::GeoTagWriter()
22 {
23 }
24 
25 GeoTagWriter::~GeoTagWriter()
26 {
27 }
28 
29 bool GeoTagWriter::writeElement( const GeoNode *object,
30  GeoWriter &writer)
31 {
32  return writer.writeElement( object );
33 }
34 
35 void GeoTagWriter::registerWriter(const QualifiedName& name,
36  const GeoTagWriter* writer )
37 {
38  TagHash* tagHash = tagWriterHash();
39 
40  if ( tagHash->contains( name ) ) {
41  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.";
42  }
43  Q_ASSERT( !tagHash->contains( name ) );
44  tagHash->insert( name, writer );
45  Q_ASSERT( tagHash->contains( name ) );
46 }
47 
48 void GeoTagWriter::unregisterWriter(const GeoTagWriter::QualifiedName &qName)
49 {
50  auto hash = tagWriterHash();
51  Q_ASSERT(hash->contains(qName));
52  delete hash->value(qName);
53  hash->remove(qName);
54  Q_ASSERT(!hash->contains(qName));
55 }
56 
57 GeoTagWriter::TagHash* GeoTagWriter::tagWriterHash()
58 {
59  static TagHash s_tagWriterHash;
60  return &s_tagWriterHash;
61 }
62 
63 const GeoTagWriter* GeoTagWriter::recognizes( const QualifiedName &qname )
64 {
65  TagHash* hash = tagWriterHash();
66 
67  if( !hash->contains( qname ) ) {
68  return nullptr;
69  }
70 
71  return hash->value( qname );
72 }
73 
74 }
Binds a QML item to a specific geodetic location in screen coordinates.
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:49
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 03:33:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.