GEOS 3.4.2

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

GeometryListHolder.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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 {
36 private:
37 typedef std::vector<geom::Geometry*> base_type;
38
39 public:
40 GeometryListHolder() {}
41 ~GeometryListHolder()
42 {
43 std::for_each(ownedItems.begin(), ownedItems.end(),
44 &GeometryListHolder::deleteItem);
45 }
46
47 // items need to be deleted in the end
48 void push_back_owned(geom::Geometry* item)
49 {
50 this->base_type::push_back(item);
51 ownedItems.push_back(item);
52 }
53
54 geom::Geometry* getGeometry(std::size_t index)
55 {
56 if (index >= this->base_type::size())
57 return NULL;
58 return (*this)[index];
59 }
60
61 private:
62 static void deleteItem(geom::Geometry* item);
63
64 private:
65 std::vector<geom::Geometry*> ownedItems;
66 };
67
68 } // namespace geos::operation::union
69 } // namespace geos::operation
70 } // namespace geos
71
72 #endif