GEOS  3.8.0dev
GeometryListHolder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2006 Refractions Research Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************/
15 
16 #ifndef GEOS_OP_UNION_GEOMETRYLISTHOLDER_H
17 #define GEOS_OP_UNION_GEOMETRYLISTHOLDER_H
18 
19 // Forward declarations
20 namespace geos {
21 namespace geom {
22 class Geometry;
23 }
24 }
25 
26 namespace geos {
27 namespace operation { // geos::operation
28 namespace geounion { // geos::operation::geounion
29 
34 class GeometryListHolder : public std::vector<geom::Geometry*> {
35 private:
36  typedef std::vector<geom::Geometry*> base_type;
37 
38 public:
41  {
42  std::for_each(ownedItems.begin(), ownedItems.end(),
43  &GeometryListHolder::deleteItem);
44  }
45 
46  // items need to be deleted in the end
47  void
48  push_back_owned(geom::Geometry* item)
49  {
50  this->base_type::push_back(item);
51  ownedItems.push_back(item);
52  }
53 
55  getGeometry(std::size_t index)
56  {
57  if(index >= this->base_type::size()) {
58  return nullptr;
59  }
60  return (*this)[index];
61  }
62 
63 private:
64  static void deleteItem(geom::Geometry* item);
65 
66 private:
67  std::vector<geom::Geometry*> ownedItems;
68 };
69 
70 } // namespace geos::operation::union
71 } // namespace geos::operation
72 } // namespace geos
73 
74 #endif
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Helper class holding Geometries, part of which are held by reference others are held exclusively...
Definition: GeometryListHolder.h:34