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