File indexing completed on 2024-05-12 03:50:15

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
0004 //
0005 
0006 
0007 #ifndef MARBLE_GEODATAMULTIGEOMETRY_H
0008 #define MARBLE_GEODATAMULTIGEOMETRY_H
0009 
0010 
0011 #include "geodata_export.h"
0012 
0013 #include "GeoDataGeometry.h"
0014 #include <QVector>
0015 
0016 namespace Marble
0017 {
0018 
0019 class GeoDataMultiGeometryPrivate;
0020 
0021 /**
0022  * @short A class that can contain other GeoDataGeometry objects
0023  *
0024  * GeoDataMultiGeometry is a collection of other GeoDataGeometry objects.
0025  * As one can add GeoDataMultiGeometry to itself, you can make up a collection
0026  * of different objects to form one Placemark.
0027  */
0028 class GEODATA_EXPORT GeoDataMultiGeometry : public GeoDataGeometry
0029 {
0030  public:
0031     GeoDataMultiGeometry();
0032     explicit GeoDataMultiGeometry( const GeoDataGeometry& other );
0033 
0034     ~GeoDataMultiGeometry() override;
0035 
0036     const char *nodeType() const override;
0037 
0038     EnumGeometryId geometryId() const override;
0039 
0040     GeoDataGeometry *copy() const override;
0041 
0042     bool operator==(const GeoDataMultiGeometry &other) const;
0043     bool operator!=(const GeoDataMultiGeometry &other) const { return !(*this == other); }
0044 
0045     const GeoDataLatLonAltBox& latLonAltBox() const override;
0046 
0047     int size() const;
0048     GeoDataGeometry& at( int pos );
0049     const GeoDataGeometry& at( int pos ) const;
0050     GeoDataGeometry& operator[]( int pos );
0051     const GeoDataGeometry& operator[]( int pos ) const;
0052 
0053     GeoDataGeometry& first();
0054     const GeoDataGeometry& first() const;
0055     GeoDataGeometry& last();
0056     const GeoDataGeometry& last() const;
0057 
0058     /**
0059      * @brief  returns the requested child item
0060      */
0061     GeoDataGeometry* child( int );
0062 
0063     /**
0064      * @brief  returns the requested child item
0065      */
0066     const GeoDataGeometry* child( int ) const;
0067 
0068     /**
0069      * @brief returns the position of an item in the list
0070      */
0071     int childPosition( const GeoDataGeometry *child ) const;
0072 
0073     /**
0074     * @brief add an element
0075     */
0076     void append( GeoDataGeometry *other );
0077 
0078     GeoDataMultiGeometry& operator << ( const GeoDataGeometry& value );
0079     
0080     QVector<GeoDataGeometry*>::Iterator begin();
0081     QVector<GeoDataGeometry*>::Iterator end();
0082     QVector<GeoDataGeometry*>::ConstIterator constBegin() const;
0083     QVector<GeoDataGeometry*>::ConstIterator constEnd() const;
0084     void clear();
0085     QVector<GeoDataGeometry *> vector();
0086 
0087     QVector<GeoDataGeometry*>::Iterator erase ( QVector<GeoDataGeometry*>::Iterator pos );
0088     QVector<GeoDataGeometry*>::Iterator erase ( QVector<GeoDataGeometry*>::Iterator begin,
0089                                                   QVector<GeoDataGeometry*>::Iterator end );
0090 
0091     // Serialize the Placemark to @p stream
0092     void pack( QDataStream& stream ) const override;
0093     // Unserialize the Placemark from @p stream
0094     void unpack( QDataStream& stream ) override;
0095 
0096  private:
0097     Q_DECLARE_PRIVATE(GeoDataMultiGeometry)
0098 };
0099 
0100 }
0101 
0102 #endif