• 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
  • data
GeoDataSchema.cpp
Go to the documentation of this file.
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 2014 Abhinav Gangwar <abhgang@gmail.com>
9 //
10 
11 // Qt
12 #include <QDataStream>
13 
14 // Marble
15 #include "GeoDataSchema.h"
16 #include "GeoDataTypes.h"
17 
18 namespace Marble
19 {
20 
21 class GeoDataSchemaPrivate
22 {
23  public:
24  QHash<QString, GeoDataSimpleField> m_simpleField;
25  QString m_name;
26 };
27 
28 GeoDataSchema::GeoDataSchema()
29  : d( new GeoDataSchemaPrivate )
30 {
31 }
32 
33 GeoDataSchema::GeoDataSchema( const QHash<QString, GeoDataSimpleField>& simplefields )
34  : d( new GeoDataSchemaPrivate )
35 {
36  d->m_simpleField = simplefields;
37 }
38 
39 GeoDataSchema::GeoDataSchema( const GeoDataSchema& other )
40  : GeoDataObject( other ),
41  d( new GeoDataSchemaPrivate( *other.d ) )
42 {
43 }
44 
45 GeoDataSchema &GeoDataSchema::operator=(const GeoDataSchema &other)
46 {
47  GeoDataObject::operator=( other );
48  *d = *other.d;
49  return *this;
50 }
51 
52 bool GeoDataSchema::operator==(const GeoDataSchema& other) const
53 {
54  return equals(other) &&
55  d->m_name == other.d->m_name &&
56  d->m_simpleField == other.d->m_simpleField;
57 }
58 
59 bool GeoDataSchema::operator!=(const GeoDataSchema& other) const
60 {
61  return !this->operator==( other );
62 }
63 
64 GeoDataSchema::~GeoDataSchema()
65 {
66  delete d;
67 }
68 
69 QString GeoDataSchema::schemaName() const
70 {
71  return d->m_name;
72 }
73 
74 void GeoDataSchema::setSchemaName( const QString& name )
75 {
76  d->m_name = name;
77 }
78 
79 GeoDataSimpleField& GeoDataSchema::simpleField( const QString& name ) const
80 {
81  return d->m_simpleField[ name ];
82 }
83 
84 void GeoDataSchema::addSimpleField( const GeoDataSimpleField &value )
85 {
86  d->m_simpleField.insert( value.name(), value );
87 }
88 
89 QList<GeoDataSimpleField> GeoDataSchema::simpleFields() const
90 {
91  return d->m_simpleField.values();
92 }
93 
94 const char* GeoDataSchema::nodeType() const
95 {
96  return GeoDataTypes::GeoDataSchemaType;
97 }
98 
99 void GeoDataSchema::pack( QDataStream& stream ) const
100 {
101  stream << d->m_simpleField.size();
102 
103  QHash<QString, GeoDataSimpleField>::const_iterator begin = d->m_simpleField.constBegin();
104  QHash<QString, GeoDataSimpleField>::const_iterator end = d->m_simpleField.constEnd();
105 
106  for( ; begin != end; ++begin ) {
107  begin.value().pack( stream );
108  }
109 }
110 
111 void GeoDataSchema::unpack( QDataStream& stream )
112 {
113  int size = 0;
114  stream >> size;
115  for( int i = 0; i < size; ++i ) {
116  GeoDataSimpleField simpleField;
117  simpleField.unpack( stream );
118  d->m_simpleField.insert( simpleField.name(), simpleField );
119  }
120 }
121 
122 }
Marble::GeoDataTypes::GeoDataSchemaType
const char * GeoDataSchemaType
Definition: GeoDataTypes.cpp:73
QDataStream
Marble::GeoDataSchema::pack
virtual void pack(QDataStream &stream) const
Reimplemented from Serializable.
Definition: GeoDataSchema.cpp:99
Marble::GeoDataSimpleField
Definition: GeoDataSimpleField.h:25
Marble::GeoDataObject
A base class for all geodata objects.
Definition: GeoDataObject.h:48
Marble::GeoDataSchema::setSchemaName
void setSchemaName(const QString &name)
Definition: GeoDataSchema.cpp:74
Marble::GeoDataSchema::unpack
virtual void unpack(QDataStream &stream)
Reimplemented from Serializable.
Definition: GeoDataSchema.cpp:111
Marble::GeoDataObject::equals
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
Definition: GeoDataObject.cpp:126
Marble::GeoDataSimpleField::unpack
virtual void unpack(QDataStream &stream)
Definition: GeoDataSimpleField.cpp:107
Marble::GeoDataSchema::addSimpleField
void addSimpleField(const GeoDataSimpleField &value)
Definition: GeoDataSchema.cpp:84
Marble::GeoDataSchema::operator!=
bool operator!=(const GeoDataSchema &other) const
Definition: GeoDataSchema.cpp:59
Marble::GeoDataSchema::simpleFields
QList< GeoDataSimpleField > simpleFields() const
Definition: GeoDataSchema.cpp:89
Marble::GeoDataSimpleField::name
QString name() const
Definition: GeoDataSimpleField.cpp:70
QHash
Marble::GeoDataSchema::operator==
bool operator==(const GeoDataSchema &other) const
Definition: GeoDataSchema.cpp:52
GeoDataSchema.h
QString
QList
Marble::GeoDataSchema::schemaName
QString schemaName() const
Definition: GeoDataSchema.cpp:69
QHash::const_iterator
Marble::GeoDataSchema
Definition: GeoDataSchema.h:30
Marble::GeoDataObject::operator=
GeoDataObject & operator=(const GeoDataObject &)
Definition: GeoDataObject.cpp:54
Marble::GeoDataSchema::~GeoDataSchema
~GeoDataSchema()
Definition: GeoDataSchema.cpp:64
Marble::GeoDataSchema::simpleField
GeoDataSimpleField & simpleField(const QString &name) const
Definition: GeoDataSchema.cpp:79
GeoDataTypes.h
Marble::GeoDataSchema::operator=
GeoDataSchema & operator=(const GeoDataSchema &other)
Definition: GeoDataSchema.cpp:45
Marble::GeoDataSchema::nodeType
virtual const char * nodeType() const
Provides type information for downcasting a GeoNode.
Definition: GeoDataSchema.cpp:94
Marble::GeoDataSchema::GeoDataSchema
GeoDataSchema()
Definition: GeoDataSchema.cpp:28
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