From f836a43bca48234c08d0eca572887c2966bb6b43 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 2 Feb 2012 10:06:37 -0500 Subject: [PATCH] Head of stats changes - moving towards shared_ptr --- bindings/python/mapnik_datasource.cpp | 4 ++-- include/mapnik/datasource.hpp | 3 ++- include/mapnik/memory_datasource.hpp | 2 +- src/memory_datasource.cpp | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bindings/python/mapnik_datasource.cpp b/bindings/python/mapnik_datasource.cpp index b079bb160..9de07a632 100644 --- a/bindings/python/mapnik_datasource.cpp +++ b/bindings/python/mapnik_datasource.cpp @@ -95,10 +95,10 @@ boost::python::dict describe(boost::shared_ptr const& ds) boost::python::dict statistics(boost::shared_ptr const& ds) { boost::python::dict description; - std::map stats = ds->get_statistics(); + mapnik::statistics_ptr stats = ds->get_statistics(); std::map::iterator it; - for (it = stats.begin(); it != stats.end(); it++) { + for (it = stats->begin(); it != stats->end(); it++) { boost::python::dict field; mapnik::parameters::const_iterator k = it->second.begin(); for (; k != it->second.end(); ++k) { diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 556ded18c..f72ea6af8 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -50,6 +50,7 @@ struct MAPNIK_DECL Featureset : private boost::noncopyable }; typedef MAPNIK_DECL boost::shared_ptr featureset_ptr; +typedef MAPNIK_DECL boost::shared_ptr< std::map > statistics_ptr; class MAPNIK_DECL datasource_exception : public std::exception { @@ -114,7 +115,7 @@ public: virtual box2d envelope() const=0; virtual boost::optional get_geometry_type() const=0; virtual layer_descriptor get_descriptor() const=0; - virtual std::map get_statistics() const=0; + virtual statistics_ptr get_statistics() const=0; virtual ~datasource() {}; protected: parameters params_; diff --git a/include/mapnik/memory_datasource.hpp b/include/mapnik/memory_datasource.hpp index 096621cbd..41418edfd 100644 --- a/include/mapnik/memory_datasource.hpp +++ b/include/mapnik/memory_datasource.hpp @@ -64,7 +64,7 @@ public: box2d envelope() const; boost::optional get_geometry_type() const; layer_descriptor get_descriptor() const; - std::map get_statistics() const; + statistics_ptr get_statistics() const; size_t size() const; void clear(); private: diff --git a/src/memory_datasource.cpp b/src/memory_datasource.cpp index 23487a70c..253ed2012 100644 --- a/src/memory_datasource.cpp +++ b/src/memory_datasource.cpp @@ -118,9 +118,9 @@ layer_descriptor memory_datasource::get_descriptor() const return desc_; } -std::map memory_datasource::get_statistics() const +statistics_ptr memory_datasource::get_statistics() const { - std::map _stats; + statistics_ptr(new std::map) _stats; std::map::const_iterator it = accumulators_.begin(); std::map::const_iterator end = accumulators_.end(); for (; it != end; ++it) {