[geos-commits] r4111 - in trunk: include/geos/geom src/geom

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Oct 31 02:23:00 PDT 2015


Author: strk
Date: 2015-10-31 02:23:00 -0700 (Sat, 31 Oct 2015)
New Revision: 4111

Modified:
   trunk/include/geos/geom/GeometryFactory.h
   trunk/src/geom/Geometry.cpp
   trunk/src/geom/GeometryFactory.cpp
Log:
Make GeometryFactory refcount geometry-agnostic

Modified: trunk/include/geos/geom/GeometryFactory.h
===================================================================
--- trunk/include/geos/geom/GeometryFactory.h	2015-10-13 11:43:37 UTC (rev 4110)
+++ trunk/include/geos/geom/GeometryFactory.h	2015-10-31 09:23:00 UTC (rev 4111)
@@ -479,13 +479,13 @@
 	int SRID;
 	const CoordinateSequenceFactory *coordinateListFactory;
 
-	mutable int _geometryCount;
+	mutable int _refCount;
 	bool _autoDestroy;
 
 friend class Geometry;
 
-	void addChild(const Geometry *g) const;
-	void delChild(const Geometry *g) const;
+	void addRef() const;
+	void dropRef() const;
 
 };
 

Modified: trunk/src/geom/Geometry.cpp
===================================================================
--- trunk/src/geom/Geometry.cpp	2015-10-13 11:43:37 UTC (rev 4110)
+++ trunk/src/geom/Geometry.cpp	2015-10-31 09:23:00 UTC (rev 4111)
@@ -116,7 +116,7 @@
 		factory = GeometryFactory::getDefaultInstance();
 	} 
 	SRID=factory->getSRID();
-	factory->addChild(this);
+	factory->addRef();
 }
 
 Geometry::Geometry(const Geometry &geom)
@@ -133,7 +133,7 @@
 	//envelope(new Envelope(*(geom.envelope.get())));
 	//SRID=geom.getSRID();
 	//userData=NULL;
-	factory->addChild(this);
+	factory->addRef();
 }
 
 bool
@@ -810,7 +810,7 @@
 
 Geometry::~Geometry()
 {
-	factory->delChild(this);
+	factory->dropRef();
 }
 
 bool

Modified: trunk/src/geom/GeometryFactory.cpp
===================================================================
--- trunk/src/geom/GeometryFactory.cpp	2015-10-13 11:43:37 UTC (rev 4110)
+++ trunk/src/geom/GeometryFactory.cpp	2015-10-31 09:23:00 UTC (rev 4111)
@@ -84,7 +84,7 @@
 	precisionModel(new PrecisionModel()),
 	SRID(0),
 	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_geometryCount(0),_autoDestroy(false)
+	,_refCount(0),_autoDestroy(false)
 {
 #if GEOS_DEBUG
 	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory()" << std::endl;
@@ -101,7 +101,7 @@
 		CoordinateSequenceFactory* nCoordinateSequenceFactory)
 	:
 	SRID(newSRID)
-	,_geometryCount(0),_autoDestroy(false)
+	,_refCount(0),_autoDestroy(false)
 {
 #if GEOS_DEBUG
 	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"], SRID)" << std::endl;
@@ -135,7 +135,7 @@
 	:
 	precisionModel(new PrecisionModel()),
 	SRID(0)
-	,_geometryCount(0),_autoDestroy(false)
+	,_refCount(0),_autoDestroy(false)
 {
 #if GEOS_DEBUG
 	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(CoordinateSequenceFactory["<<nCoordinateSequenceFactory<<"])" << std::endl;
@@ -162,7 +162,7 @@
 	:
 	SRID(0),
 	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_geometryCount(0),_autoDestroy(false)
+	,_refCount(0),_autoDestroy(false)
 {
 #if GEOS_DEBUG
 	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"])" << std::endl;
@@ -188,7 +188,7 @@
 	:
 	SRID(newSRID),
 	coordinateListFactory(CoordinateArraySequenceFactory::instance())
-	,_geometryCount(0),_autoDestroy(false)
+	,_refCount(0),_autoDestroy(false)
 {
 #if GEOS_DEBUG
 	std::cerr << "GEOS_DEBUG: GeometryFactory["<<this<<"]::GeometryFactory(PrecisionModel["<<pm<<"], SRID)" << std::endl;
@@ -217,7 +217,7 @@
 	SRID=gf.SRID;
 	coordinateListFactory=gf.coordinateListFactory;
   _autoDestroy=false;
-  _geometryCount=0;
+  _refCount=0;
 }
 
 /*public static*/
@@ -789,16 +789,16 @@
 
 /*private*/
 void
-GeometryFactory::addChild(const Geometry *) const
+GeometryFactory::addRef() const
 {
-	++_geometryCount;
+	++_refCount;
 }
 
 /*private*/
 void
-GeometryFactory::delChild(const Geometry *) const
+GeometryFactory::dropRef() const
 {
-	if ( ! --_geometryCount )
+	if ( ! --_refCount )
 	{
 		if ( _autoDestroy ) delete this;
 	}
@@ -809,7 +809,7 @@
 {
 	assert(!_autoDestroy); // don't call me twice !
 	_autoDestroy = true;
-	if ( ! _geometryCount ) delete this;
+	if ( ! _refCount ) delete this;
 }
 
 } // namespace geos::geom



More information about the geos-commits mailing list