GEOS
3.4.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net> 00007 * Copyright (C) 2006 Refractions Research Inc. 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 **********************************************************************/ 00015 00016 #ifndef GEOS_OP_UNION_GEOMETRYLISTHOLDER_H 00017 #define GEOS_OP_UNION_GEOMETRYLISTHOLDER_H 00018 00019 // Forward declarations 00020 namespace geos { 00021 namespace geom { 00022 class Geometry; 00023 } 00024 } 00025 00026 namespace geos { 00027 namespace operation { // geos::operation 00028 namespace geounion { // geos::operation::geounion 00029 00034 class GeometryListHolder : public std::vector<geom::Geometry*> 00035 { 00036 private: 00037 typedef std::vector<geom::Geometry*> base_type; 00038 00039 public: 00040 GeometryListHolder() {} 00041 ~GeometryListHolder() 00042 { 00043 std::for_each(ownedItems.begin(), ownedItems.end(), 00044 &GeometryListHolder::deleteItem); 00045 } 00046 00047 // items need to be deleted in the end 00048 void push_back_owned(geom::Geometry* item) 00049 { 00050 this->base_type::push_back(item); 00051 ownedItems.push_back(item); 00052 } 00053 00054 geom::Geometry* getGeometry(std::size_t index) 00055 { 00056 if (index >= this->base_type::size()) 00057 return NULL; 00058 return (*this)[index]; 00059 } 00060 00061 private: 00062 static void deleteItem(geom::Geometry* item); 00063 00064 private: 00065 std::vector<geom::Geometry*> ownedItems; 00066 }; 00067 00068 } // namespace geos::operation::union 00069 } // namespace geos::operation 00070 } // namespace geos 00071 00072 #endif