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// Own
8#include "GeoTagHandler.h"
9
10// Marble
11#include "MarbleDebug.h"
12
13namespace Marble
14{
15
16// Set to a value greater than 0, to dump tag handlers as they get registered
17#define DUMP_TAG_HANDLER_REGISTRATION 0
18
19GeoTagHandler::TagHash *GeoTagHandler::s_tagHandlerHash = nullptr;
20
21GeoTagHandler::GeoTagHandler() = default;
22
23GeoTagHandler::~GeoTagHandler() = default;
24
25GeoTagHandler::TagHash *GeoTagHandler::tagHandlerHash()
26{
27 if (!s_tagHandlerHash)
28 s_tagHandlerHash = new TagHash();
29
30 Q_ASSERT(s_tagHandlerHash);
31 return s_tagHandlerHash;
32}
33
34void GeoTagHandler::registerHandler(const GeoParser::QualifiedName &qName, const GeoTagHandler *handler)
35{
36 TagHash *hash = tagHandlerHash();
37
38 Q_ASSERT(!hash->contains(qName));
39 hash->insert(qName, handler);
40 Q_ASSERT(hash->contains(qName));
41
42#if DUMP_TAG_HANDLER_REGISTRATION > 0
43 mDebug() << "[GeoTagHandler] -> Recognizing" << qName.first << "tag with namespace" << qName.second;
44#endif
45}
46
47void GeoTagHandler::unregisterHandler(const GeoParser::QualifiedName &qName)
48{
49 TagHash *hash = tagHandlerHash();
50
51 Q_ASSERT(hash->contains(qName));
52 delete hash->value(qName);
53 hash->remove(qName);
54 Q_ASSERT(!hash->contains(qName));
55}
56
57const GeoTagHandler *GeoTagHandler::recognizes(const GeoParser::QualifiedName &qName)
58{
59 TagHash *hash = tagHandlerHash();
60
61 if (!hash->contains(qName))
62 return nullptr;
63
64 return (*hash)[qName];
65}
66
67}
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 Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.