Marble

GeoTagHandler.cpp
1 /*
2  SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 
8 // Own
9 #include "GeoTagHandler.h"
10 
11 // Marble
12 #include "MarbleDebug.h"
13 
14 
15 namespace Marble
16 {
17 
18 // Set to a value greater than 0, to dump tag handlers as they get registered
19 #define DUMP_TAG_HANDLER_REGISTRATION 0
20 
21 GeoTagHandler::TagHash* GeoTagHandler::s_tagHandlerHash = nullptr;
22 
23 GeoTagHandler::GeoTagHandler()
24 {
25 }
26 
27 GeoTagHandler::~GeoTagHandler()
28 {
29 }
30 
31 GeoTagHandler::TagHash* GeoTagHandler::tagHandlerHash()
32 {
33  if (!s_tagHandlerHash)
34  s_tagHandlerHash = new TagHash();
35 
36  Q_ASSERT(s_tagHandlerHash);
37  return s_tagHandlerHash;
38 }
39 
40 void GeoTagHandler::registerHandler(const GeoParser::QualifiedName& qName, const GeoTagHandler* handler)
41 {
42  TagHash* hash = tagHandlerHash();
43 
44  Q_ASSERT(!hash->contains(qName));
45  hash->insert(qName, handler);
46  Q_ASSERT(hash->contains(qName));
47 
48 #if DUMP_TAG_HANDLER_REGISTRATION > 0
49  mDebug() << "[GeoTagHandler] -> Recognizing" << qName.first << "tag with namespace" << qName.second;
50 #endif
51 }
52 
53 void GeoTagHandler::unregisterHandler(const GeoParser::QualifiedName& qName)
54 {
55  TagHash* hash = tagHandlerHash();
56 
57  Q_ASSERT(hash->contains(qName));
58  delete hash->value(qName);
59  hash->remove(qName);
60  Q_ASSERT(!hash->contains(qName));
61 }
62 
63 const GeoTagHandler* GeoTagHandler::recognizes(const GeoParser::QualifiedName& qName)
64 {
65  TagHash* hash = tagHandlerHash();
66 
67  if (!hash->contains(qName))
68  return nullptr;
69 
70  return (*hash)[qName];
71 }
72 
73 }
Binds a QML item to a specific geodetic location in screen coordinates.
QDebug mDebug()
a function to replace qDebug() in Marble library code
Definition: MarbleDebug.cpp:31
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.