Marble

GeoTagWriter.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2009 Andrew Manson <[email protected]>
4 // SPDX-FileCopyrightText: 2007, 2008 Nikolas Zimmermann <[email protected]>
5 //
6 
7 #ifndef MARBLE_GEOTAGWRITER_H
8 #define MARBLE_GEOTAGWRITER_H
9 
10 #include <QPair>
11 #include <QHash>
12 
13 #include <marble_export.h>
14 
15 namespace Marble
16 {
17 
18 class GeoNode;
19 class 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  */
27 class MARBLE_EXPORT GeoTagWriter
28 {
29 public:
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  */
45 
46 protected:
47  GeoTagWriter();
48  virtual ~GeoTagWriter();
49 
50  static bool writeElement(const GeoNode *object, GeoWriter &writer);
51 
52 private:
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 
58 private:
59  //Collect the Tag Writers and provide a singleton like accessor
61  static TagHash* tagWriterHash();
62 
63 private:
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
71 struct GeoTagWriterRegistrar
72 {
73 public:
74  GeoTagWriterRegistrar(const GeoTagWriter::QualifiedName& name, const GeoTagWriter* writer) :
75  m_name(name)
76  {
77  GeoTagWriter::registerWriter(name, writer);
78  }
79 
80  ~GeoTagWriterRegistrar()
81  {
82  GeoTagWriter::unregisterWriter(m_name);
83  }
84 
85 private:
87 };
88 
89 }
90 
91 #endif
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:44
Base class intended to be subclassed by specific XML tag writers This class provides a base class tha...
Definition: GeoTagWriter.h:27
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:34
Binds a QML item to a specific geodetic location in screen coordinates.
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:12:26 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.