Marble

GeoTagWriter.h
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2009 Andrew Manson <g.real.ate@gmail.com>
4// SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
5//
6
7#ifndef MARBLE_GEOTAGWRITER_H
8#define MARBLE_GEOTAGWRITER_H
9
10#include <QHash>
11#include <QPair>
12
13#include <marble_export.h>
14
15namespace Marble
16{
17
18class GeoNode;
19class GeoWriter;
20
21/**
22 * @brief Base class intended to be subclassed by specific XML tag writers
23 * This class provides a base class that allows the writing of many different
24 * XML formats. The system used to implement this writing system is very strongly
25 * based on the @see GeoTagHandler system.
26 */
27class MARBLE_EXPORT GeoTagWriter
28{
29public:
30 virtual bool write(const GeoNode *node, GeoWriter &writer) const = 0;
31
32 /**
33 * @brief Object Name and Namespace Pair
34 * This type is intended to be used in a similar way to @see GeoParser::QualifiedName
35 * but in practice will act differently. The Namespace will not be an XML
36 * namespace directly but instead it will refere to a Document Type so that
37 * the GeoWriter will be able to identify what GeoTagWriter to use even in
38 * absence of an XML namespace. This also allows for the case where data
39 * using an internal representation of the KML classes can be outputted in
40 * alternative XML formats. For XML formats that have namespaces this
41 * document type will usually correspond with the XML namespace. Use in the
42 * order QPair<QString tagName, QString documentType>.
43 */
44 using QualifiedName = QPair<QString, QString>;
45
46protected:
48 virtual ~GeoTagWriter();
49
50 static bool writeElement(const GeoNode *object, GeoWriter &writer);
51
52private:
53 // Only our registrar is allowed to register tag writers.
54 friend struct GeoTagWriterRegistrar;
55 static void registerWriter(const QualifiedName &, const GeoTagWriter *);
56 static void unregisterWriter(const QualifiedName &);
57
58private:
59 // Collect the Tag Writers and provide a singleton like accessor
61 static TagHash *tagWriterHash();
62
63private:
64 // Only our writer is allowed to access tag handlers.
65 friend class GeoWriter;
66 friend class GeoDataDocumentWriter;
67 static const GeoTagWriter *recognizes(const QualifiedName &);
68};
69
70// Helper structure
71struct GeoTagWriterRegistrar {
72public:
73 GeoTagWriterRegistrar(const GeoTagWriter::QualifiedName &name, const GeoTagWriter *writer)
74 : m_name(name)
75 {
76 GeoTagWriter::registerWriter(name, writer);
77 }
78
79 ~GeoTagWriterRegistrar()
80 {
81 GeoTagWriter::unregisterWriter(m_name);
82 }
83
84private:
86};
87
88}
89
90#endif
Write GeoDataDocument content to I/O devices (e.g.
A shared base class for all classes that are mapped to a specific tag (ie.
Definition GeoDocument.h:35
Base class intended to be subclassed by specific XML tag writers This class provides a base class tha...
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition GeoWriter.h:26
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 Sat Dec 21 2024 17:04:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.