Marble

GeoDataObject.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 2007 Murad Tagirov <[email protected]>
9 // Copyright 2008 Jens-Michael Hoffmann <[email protected]>
10 //
11 
12 
13 #ifndef MARBLE_GEODATAOBJECT_H
14 #define MARBLE_GEODATAOBJECT_H
15 
16 #include "geodata_export.h"
17 
18 #include "GeoDocument.h"
19 #include "Serializable.h"
20 
21 #include <QMetaType>
22 
23 namespace Marble
24 {
25 
26 class GeoDataObjectPrivate;
27 
48 class GEODATA_EXPORT GeoDataObject : public GeoNode,
49  public Serializable
50 {
51 public:
52  GeoDataObject();
53  GeoDataObject( const GeoDataObject & );
54  GeoDataObject & operator=( const GeoDataObject & );
55  ~GeoDataObject() override;
56 
58  const GeoDataObject *parent() const;
59  GeoDataObject *parent();
60 
62  void setParent(GeoDataObject *parent);
63 
67  QString id() const;
72  void setId( const QString &value );
73 
77  QString targetId() const;
82  void setTargetId( const QString &value );
83 
84  QString resolvePath( const QString &relativePath ) const;
85 
87  void pack( QDataStream& stream ) const override;
89  void unpack( QDataStream& steam ) override;
90 
91  private:
92 
93  GeoDataObjectPrivate * d;
94 
95  protected:
100  virtual bool equals(const GeoDataObject &other) const;
101 };
102 
103 
111 template<typename T>
113 {
114  if (node == nullptr) {
115  return nullptr;
116  }
117 
118  if (typeid(*node) == typeid(T)) {
119  return static_cast<T *>(node);
120  }
121 
122  return nullptr;
123 }
124 
132 template<typename T>
133 const T *geodata_cast(const GeoDataObject *node)
134 {
135  if (node == nullptr) {
136  return nullptr;
137  }
138 
139  if (typeid(*node) == typeid(T)) {
140  return static_cast<const T *>(node);
141  }
142 
143  return nullptr;
144 }
145 
146 }
147 
148 Q_DECLARE_METATYPE( Marble::GeoDataObject* )
149 
150 #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
A base class for all geodata objects.
Definition: GeoDataObject.h:48
T * geodata_cast(GeoDataObject *node)
Returns the given node cast to type T if the node was instantiated as type T; otherwise returns 0...
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Aug 12 2020 23:19:30 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.