QGIS API Documentation  2.14.0-Essen
qgsfeature_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeature_p.h
3  ---------------
4 Date : May-2015
5 Copyright : (C) 2015 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSFEATURE_PRIVATE_H
17 #define QGSFEATURE_PRIVATE_H
18 
20 
21 //
22 // W A R N I N G
23 // -------------
24 //
25 // This file is not part of the QGIS API. It exists purely as an
26 // implementation detail. This header file may change from version to
27 // version without notice, or even be removed.
28 //
29 
30 /***************************************************************************
31  * This class is considered CRITICAL and any change MUST be accompanied with
32  * full unit tests in testqgsfeature.cpp.
33  * See details in QEP #17
34  ****************************************************************************/
35 
36 #include "qgsfield.h"
37 
38 #include "qgsgeometry.h"
39 
40 class QgsFeaturePrivate : public QSharedData
41 {
42  public:
43 
44  explicit QgsFeaturePrivate( QgsFeatureId id )
45  : fid( id )
46  , geometry( nullptr )
47  , ownsGeometry( false )
48  , valid( false )
49  {
50  }
51 
52  QgsFeaturePrivate( const QgsFeaturePrivate& other )
53  : QSharedData( other )
54  , fid( other.fid )
55  , attributes( other.attributes )
56  , geometry( other.ownsGeometry && other.geometry ? new QgsGeometry( *other.geometry ) : other.geometry )
57  , ownsGeometry( other.ownsGeometry )
58  , valid( other.valid )
59  , fields( other.fields )
60  {
61  }
62 
63  ~QgsFeaturePrivate()
64  {
65  if ( ownsGeometry )
66  delete geometry;
67  }
68 
70  QgsFeatureId fid;
71 
73  QgsAttributes attributes;
74 
79  QgsGeometry *geometry;
80 
84  bool ownsGeometry;
85 
87  bool valid;
88 
90  QgsFields fields;
91 
92 };
93 
95 
96 #endif //QGSFEATURE_PRIVATE_H
Container of fields for a vector layer.
Definition: qgsfield.h:187
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
qint64 QgsFeatureId
Definition: qgsfeature.h:31
A vector of attributes.
Definition: qgsfeature.h:115