1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2006 Refractions Research Inc.
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.
14 **********************************************************************/
16 #ifndef GEOS_OP_UNION_GEOMETRYLISTHOLDER_H
17 #define GEOS_OP_UNION_GEOMETRYLISTHOLDER_H
19 // Forward declarations
27 namespace operation
{ // geos::operation
28 namespace geounion
{ // geos::operation::geounion
31 * \brief Helper class holding Geometries, part of which are held by reference
32 * others are held exclusively.
34 class GeometryListHolder
: public std::vector
<geom::Geometry
*>
37 typedef std::vector
<geom::Geometry
*> base_type
;
40 GeometryListHolder() {}
43 std::for_each(ownedItems
.begin(), ownedItems
.end(),
44 &GeometryListHolder::deleteItem
);
47 // items need to be deleted in the end
48 void push_back_owned(geom::Geometry
* item
)
50 this->base_type::push_back(item
);
51 ownedItems
.push_back(item
);
54 geom::Geometry
* getGeometry(std::size_t index
)
56 if (index
>= this->base_type::size())
58 return (*this)[index
];
62 static void deleteItem(geom::Geometry
* item
);
65 std::vector
<geom::Geometry
*> ownedItems
;
68 } // namespace geos::operation::union
69 } // namespace geos::operation