• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • parser
GeoTagHandler.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 
4  This file is part of the KDE project
5 
6  This library is free software you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  aint with this library see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef MARBLE_GEOTAGHANDLER_H
23 #define MARBLE_GEOTAGHANDLER_H
24 
25 #include <QHash>
26 #include "marble_export.h"
27 #include "GeoParser.h"
28 
29 namespace Marble
30 {
31 
32 class GeoNode;
33 class GeoParser;
34 
43 class MARBLE_EXPORT GeoTagHandler
44 {
45 public:
46  // API to be implemented by child handlers.
47  virtual GeoNode* parse(GeoParser&) const = 0;
48 
49 protected: // This base class is not directly constructable nor is it copyable.
50  GeoTagHandler();
51  virtual ~GeoTagHandler();
52 
53 private:
54  GeoTagHandler(const GeoTagHandler&);
55  GeoTagHandler& operator=(const GeoTagHandler&);
56 
57 private: // Only our registrar is allowed to register tag handlers.
58  friend struct GeoTagHandlerRegistrar;
59  static void registerHandler(const GeoParser::QualifiedName&, const GeoTagHandler*);
60  static void unregisterHandler(const GeoParser::QualifiedName&);
61 
62 private: // Only our parser is allowed to access tag handlers.
63  friend class GeoParser;
64  static const GeoTagHandler* recognizes(const GeoParser::QualifiedName&);
65 
66 private:
67  typedef QHash<GeoParser::QualifiedName, const GeoTagHandler*> TagHash;
68 
69  static TagHash* tagHandlerHash();
70  static TagHash* s_tagHandlerHash;
71 };
72 
73 // Helper structure
74 struct GeoTagHandlerRegistrar
75 {
76 public:
77  GeoTagHandlerRegistrar(const GeoParser::QualifiedName& name, const GeoTagHandler* handler)
78  :m_name( name )
79  {
80  GeoTagHandler::registerHandler(name, handler);
81  }
82 
83  ~GeoTagHandlerRegistrar()
84  {
85  GeoTagHandler::unregisterHandler(m_name);
86  }
87 
88 private:
89  GeoParser::QualifiedName m_name;
90 };
91 
92 // Macros to ease registering new handlers
93 #define GEODATA_DEFINE_TAG_HANDLER(Module, UpperCaseModule, Name, NameSpace) \
94  static GeoTagHandlerRegistrar s_handler##Name##NameSpace(GeoParser::QualifiedName(Module##Tag_##Name, NameSpace), \
95  new UpperCaseModule##Name##TagHandler());
96 
97 }
98 
99 #endif
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoParser.h
Marble::GeoTagHandlerRegistrar::~GeoTagHandlerRegistrar
~GeoTagHandlerRegistrar()
Definition: GeoTagHandler.h:83
Marble::dgml::handler
static GeoTagHandlerRegistrar handler(GeoParser::QualifiedName(dgmlTag_DownloadPolicy, dgmlTag_nameSpace20), new DgmlDownloadPolicyTagHandler)
Marble::GeoParser
Definition: GeoParser.h:40
Marble::GeoTagHandlerRegistrar::GeoTagHandlerRegistrar
GeoTagHandlerRegistrar(const GeoParser::QualifiedName &name, const GeoTagHandler *handler)
Definition: GeoTagHandler.h:77
QHash
MARBLE_EXPORT
#define MARBLE_EXPORT
Definition: marble_export.h:20
QPair< QString, QString >
marble_export.h
Marble::GeoTagHandlerRegistrar
Definition: GeoTagHandler.h:74
Marble::GeoTagHandler
A base class for XML tag handlers This is a base class that is used in the GeoParser architecture...
Definition: GeoTagHandler.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal