Marble

GeoTagWriter.h
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2009 Andrew Manson <[email protected]>
9 // Copyright (C) 2007, 2008 Nikolas Zimmermann <[email protected]>
10 //
11 
12 #ifndef MARBLE_GEOTAGWRITER_H
13 #define MARBLE_GEOTAGWRITER_H
14 
15 #include <QPair>
16 #include <QHash>
17 
18 #include <marble_export.h>
19 
20 namespace Marble
21 {
22 
23 class GeoNode;
24 class GeoWriter;
25 
26 /**
27  * @brief Base class intended to be subclassed by specific XML tag writers
28  * This class provides a base class that allows the writing of many different
29  * XML formats. The system used to implement this writing system is very strongly
30  * based on the @see GeoTagHandler system.
31  */
32 class MARBLE_EXPORT GeoTagWriter
33 {
34 public:
35  virtual bool write( const GeoNode *node, GeoWriter& writer ) const = 0;
36 
37  /**
38  * @brief Object Name and Namespace Pair
39  * This type is intended to be used in a similar way to @see GeoParser::QualifiedName
40  * but in practice will act differently. The Namespace will not be an XML
41  * namespace directly but instead it will refere to a Document Type so that
42  * the GeoWriter will be able to identify what GeoTagWriter to use even in
43  * absence of an XML namespace. This also allows for the case where data
44  * using an internal representation of the KML classes can be outputted in
45  * alternative XML formats. For XML formats that have namespaces this
46  * document type will usually correspond with the XML namespace. Use in the
47  * order QPair<QString tagName, QString documentType>.
48  */
50 
51 protected:
52  GeoTagWriter();
53  virtual ~GeoTagWriter();
54 
55  static bool writeElement(const GeoNode *object, GeoWriter &writer);
56 
57 private:
58  // Only our registrar is allowed to register tag writers.
59  friend struct GeoTagWriterRegistrar;
60  static void registerWriter(const QualifiedName&, const GeoTagWriter*);
61  static void unregisterWriter(const QualifiedName&);
62 
63 private:
64  //Collect the Tag Writers and provide a singleton like accessor
66  static TagHash* tagWriterHash();
67 
68 private:
69  // Only our writer is allowed to access tag handlers.
70  friend class GeoWriter;
71  friend class GeoDataDocumentWriter;
72  static const GeoTagWriter* recognizes(const QualifiedName&);
73 };
74 
75 // Helper structure
76 struct GeoTagWriterRegistrar
77 {
78 public:
79  GeoTagWriterRegistrar(const GeoTagWriter::QualifiedName& name, const GeoTagWriter* writer) :
80  m_name(name)
81  {
82  GeoTagWriter::registerWriter(name, writer);
83  }
84 
85  ~GeoTagWriterRegistrar()
86  {
87  GeoTagWriter::unregisterWriter(m_name);
88  }
89 
90 private:
92 };
93 
94 }
95 
96 #endif
Binds a QML item to a specific geodetic location in screen coordinates.
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:49
Base class intended to be subclassed by specific XML tag writers This class provides a base class tha...
Definition: GeoTagWriter.h:32
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:30
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:49
Write GeoDataDocument content to I/O devices (e.g.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Mar 2 2021 03:33:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.