Switched to shared_ptr at the cost of a segfault

This commit is contained in:
Tom MacWright 2012-02-02 10:36:57 -05:00
parent f836a43bca
commit 9c1af869b6
7 changed files with 13 additions and 13 deletions

View file

@ -358,7 +358,7 @@ layer_descriptor postgis_datasource::get_descriptor() const
}
std::map<std::string, mapnik::parameters> postgis_datasource::get_statistics() const
mapnik::statistics_ptr postgis_datasource::get_statistics() const
{
if (! is_bound_) bind();
return stats_;

View file

@ -85,13 +85,13 @@ public:
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
std::map<std::string, mapnik::parameters> get_statistics() const;
mapnik::statistics_ptr get_statistics() const;
postgis_datasource(const parameters &params, bool bind=true);
~postgis_datasource();
void bind() const;
private:
std::string sql_bbox(box2d<double> const& env) const;
mutable std::map<std::string, mapnik::parameters> stats_;
mapnik::statistics_ptr stats_;
std::string populate_tokens(const std::string& sql, double scale_denom, box2d<double> const& env) const;
std::string populate_tokens(const std::string& sql) const;
static std::string unquote(const std::string& sql);

View file

@ -240,7 +240,7 @@ layer_descriptor shape_datasource::get_descriptor() const
return desc_;
}
std::map<std::string, mapnik::parameters> shape_datasource::get_statistics() const
mapnik::statistics_ptr shape_datasource::get_statistics() const
{
if (! is_bound_) bind();
return stats_;

View file

@ -52,7 +52,7 @@ public:
box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
layer_descriptor get_descriptor() const;
std::map<std::string, mapnik::parameters> get_statistics() const;
mapnik::statistics_ptr get_statistics() const;
void bind() const;
private:
shape_datasource(const shape_datasource&);
@ -63,7 +63,7 @@ private:
std::string shape_name_;
mutable boost::shared_ptr<shape_io> shape_;
mutable shape_io::shapeType shape_type_;
mutable std::map<std::string, mapnik::parameters> stats_;
mutable mapnik::statistics_ptr stats_;
mutable long file_length_;
mutable box2d<double> extent_;
mutable bool indexed_;

View file

@ -483,11 +483,11 @@ box2d<double> sqlite_datasource::envelope() const
return extent_;
}
std::map<std::string, mapnik::parameters> sqlite_datasource::get_statistics() const
mapnik::statistics_ptr sqlite_datasource::get_statistics() const
{
if (! is_bound_) bind();
std::map<std::string, mapnik::parameters> _stats;
mapnik::statistics_ptr _stats;
std::ostringstream s;
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
@ -534,7 +534,7 @@ std::map<std::string, mapnik::parameters> sqlite_datasource::get_statistics() c
col++;
p["mean"] = rs->column_double(col);
col++;
stats_[itr->get_name()] = p;
stats_->insert(std::pair<std::string, mapnik::parameters>(itr->get_name(), p));
}
}
}

View file

@ -49,7 +49,7 @@ public:
mapnik::box2d<double> envelope() const;
boost::optional<mapnik::datasource::geometry_t> get_geometry_type() const;
mapnik::layer_descriptor get_descriptor() const;
std::map<std::string, mapnik::parameters> get_statistics() const;
mapnik::statistics_ptr get_statistics() const;
void bind() const;
private:
@ -80,7 +80,7 @@ private:
mutable bool has_spatial_index_;
mutable bool using_subquery_;
mutable std::vector<std::string> init_statements_;
mutable std::map<std::string, mapnik::parameters> stats_;
mutable mapnik::statistics_ptr stats_;
// Fill init_statements with any statements
// needed to attach auxillary databases

View file

@ -120,7 +120,7 @@ layer_descriptor memory_datasource::get_descriptor() const
statistics_ptr memory_datasource::get_statistics() const
{
statistics_ptr(new std::map<std::string, mapnik::parameters>) _stats;
statistics_ptr _stats;
std::map<std::string, statistics_accumulator>::const_iterator it = accumulators_.begin();
std::map<std::string, statistics_accumulator>::const_iterator end = accumulators_.end();
for (; it != end; ++it) {
@ -130,7 +130,7 @@ statistics_ptr memory_datasource::get_statistics() const
p["min"] = boost::accumulators::min(it->second);
p["stddev"] = sqrt(boost::accumulators::variance(it->second));
p["max"] = boost::accumulators::max(it->second);
_stats[it->first] = p;
_stats->insert(std::pair<std::string, mapnik::parameters>(it->first, p));
}
return _stats;
}