File indexing completed on 2024-05-19 03:51:49
0001 /* 0002 SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 0008 // Own 0009 #include "GeoTagHandler.h" 0010 0011 // Marble 0012 #include "MarbleDebug.h" 0013 0014 0015 namespace Marble 0016 { 0017 0018 // Set to a value greater than 0, to dump tag handlers as they get registered 0019 #define DUMP_TAG_HANDLER_REGISTRATION 0 0020 0021 GeoTagHandler::TagHash* GeoTagHandler::s_tagHandlerHash = nullptr; 0022 0023 GeoTagHandler::GeoTagHandler() 0024 { 0025 } 0026 0027 GeoTagHandler::~GeoTagHandler() 0028 { 0029 } 0030 0031 GeoTagHandler::TagHash* GeoTagHandler::tagHandlerHash() 0032 { 0033 if (!s_tagHandlerHash) 0034 s_tagHandlerHash = new TagHash(); 0035 0036 Q_ASSERT(s_tagHandlerHash); 0037 return s_tagHandlerHash; 0038 } 0039 0040 void GeoTagHandler::registerHandler(const GeoParser::QualifiedName& qName, const GeoTagHandler* handler) 0041 { 0042 TagHash* hash = tagHandlerHash(); 0043 0044 Q_ASSERT(!hash->contains(qName)); 0045 hash->insert(qName, handler); 0046 Q_ASSERT(hash->contains(qName)); 0047 0048 #if DUMP_TAG_HANDLER_REGISTRATION > 0 0049 mDebug() << "[GeoTagHandler] -> Recognizing" << qName.first << "tag with namespace" << qName.second; 0050 #endif 0051 } 0052 0053 void GeoTagHandler::unregisterHandler(const GeoParser::QualifiedName& qName) 0054 { 0055 TagHash* hash = tagHandlerHash(); 0056 0057 Q_ASSERT(hash->contains(qName)); 0058 delete hash->value(qName); 0059 hash->remove(qName); 0060 Q_ASSERT(!hash->contains(qName)); 0061 } 0062 0063 const GeoTagHandler* GeoTagHandler::recognizes(const GeoParser::QualifiedName& qName) 0064 { 0065 TagHash* hash = tagHandlerHash(); 0066 0067 if (!hash->contains(qName)) 0068 return nullptr; 0069 0070 return (*hash)[qName]; 0071 } 0072 0073 }