Marble

GeoTagHandler.cpp
1/*
2 SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
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
15namespace 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
21GeoTagHandler::TagHash* GeoTagHandler::s_tagHandlerHash = nullptr;
22
23GeoTagHandler::GeoTagHandler()
24{
25}
26
27GeoTagHandler::~GeoTagHandler()
28{
29}
30
31GeoTagHandler::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
40void 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
53void 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
63const 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.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.