File indexing completed on 2024-05-12 03:50:31
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com> 0004 // SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> 0005 // 0006 0007 #include "GeoTagWriter.h" 0008 0009 #include "GeoWriter.h" 0010 0011 #include <QDebug> 0012 0013 namespace Marble 0014 { 0015 0016 GeoTagWriter::GeoTagWriter() 0017 { 0018 } 0019 0020 GeoTagWriter::~GeoTagWriter() 0021 { 0022 } 0023 0024 bool GeoTagWriter::writeElement( const GeoNode *object, 0025 GeoWriter &writer) 0026 { 0027 return writer.writeElement( object ); 0028 } 0029 0030 void GeoTagWriter::registerWriter(const QualifiedName& name, 0031 const GeoTagWriter* writer ) 0032 { 0033 TagHash* tagHash = tagWriterHash(); 0034 0035 if ( tagHash->contains( name ) ) { 0036 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."; 0037 } 0038 Q_ASSERT( !tagHash->contains( name ) ); 0039 tagHash->insert( name, writer ); 0040 Q_ASSERT( tagHash->contains( name ) ); 0041 } 0042 0043 void GeoTagWriter::unregisterWriter(const GeoTagWriter::QualifiedName &qName) 0044 { 0045 auto hash = tagWriterHash(); 0046 Q_ASSERT(hash->contains(qName)); 0047 delete hash->value(qName); 0048 hash->remove(qName); 0049 Q_ASSERT(!hash->contains(qName)); 0050 } 0051 0052 GeoTagWriter::TagHash* GeoTagWriter::tagWriterHash() 0053 { 0054 static TagHash s_tagWriterHash; 0055 return &s_tagWriterHash; 0056 } 0057 0058 const GeoTagWriter* GeoTagWriter::recognizes( const QualifiedName &qname ) 0059 { 0060 TagHash* hash = tagWriterHash(); 0061 0062 if( !hash->contains( qname ) ) { 0063 return nullptr; 0064 } 0065 0066 return hash->value( qname ); 0067 } 0068 0069 }