1/*
2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KABC_GEO_H
22#define KABC_GEO_H
23
24#include "kabc_export.h"
25#include <QtCore/QSharedDataPointer>
26#include <QtCore/QString>
27
28namespace KABC {
29
30/**
31 * @short Geographic position
32 *
33 * This class represents a geographic position.
34 */
35class KABC_EXPORT Geo
36{
37 friend KABC_EXPORT QDataStream &operator<<( QDataStream &, const Geo & );
38 friend KABC_EXPORT QDataStream &operator>>( QDataStream &, Geo & );
39
40 public:
41 /**
42 * Creates an invalid geographics position object.
43 */
44 Geo();
45
46 /**
47 * Creates a geographics position object.
48 *
49 * @param latitude Geographical latitude
50 * @param longitude Geographical longitude
51 */
52 Geo( float latitude, float longitude );
53
54 /**
55 * Copy constructor.
56 */
57 Geo( const Geo &other );
58
59 /**
60 * Destroys the geographics position object.
61 */
62 ~Geo();
63
64 /**
65 * Sets the @p latitude.
66 *
67 * @param latitude The location's latitude coordinate
68 */
69 void setLatitude( float latitude );
70
71 /**
72 * Returns the latitude.
73 */
74 float latitude() const;
75
76 /**
77 * Sets the @p longitude.
78 *
79 * @param longitude The location's longitude coordinate
80 */
81 void setLongitude( float longitude );
82
83 /**
84 * Returns the longitude.
85 */
86 float longitude() const;
87
88 /**
89 * Returns, whether this object contains a valid geographical position.
90 */
91 bool isValid() const;
92
93 /**
94 * Equality operator.
95 *
96 * @note Two invalid Geo instance will return @c true
97 */
98 bool operator==( const Geo & ) const;
99
100 /**
101 * Not-Equal operator.
102 */
103 bool operator!=( const Geo & ) const;
104
105 /**
106 * Assignment operator.
107 *
108 * @param other The Geo instance to assign to @c this
109 */
110 Geo &operator=( const Geo &other );
111
112 /**
113 * Returns string representation of geographical position.
114 */
115 QString toString() const;
116
117 private:
118 class Private;
119 QSharedDataPointer<Private> d;
120};
121
122/**
123 * Serializes the geographical position @p object into the @p stream.
124 */
125KABC_EXPORT QDataStream &operator<<( QDataStream &stream, const Geo &object );
126
127/**
128 * Initializes the geographical position @p object from the @p stream.
129 */
130KABC_EXPORT QDataStream &operator>>( QDataStream &stream, Geo &object );
131
132}
133
134#endif
135