move context's typedef inside to avoid poluting global namespace

This commit is contained in:
Artem Pavlenko 2012-01-19 17:36:27 -05:00 committed by Artem Pavlenko
parent 3e016f52e7
commit 7601095e24
14 changed files with 39 additions and 39 deletions

View File

@ -47,7 +47,7 @@ namespace {
using mapnik::Feature;
using mapnik::geometry_utils;
using mapnik::from_wkt;
using mapnik::context;
using mapnik::context_type;
using mapnik::context_ptr;
using mapnik::feature_kv_iterator;
@ -150,9 +150,9 @@ void export_feature()
UnicodeString_from_python_str();
class_<context,context_ptr,boost::noncopyable>
class_<context_type,context_ptr,boost::noncopyable>
("Context",init<>("Default ctor."))
.def("push", &context::push)
.def("push", &context_type::push)
;
class_<Feature,boost::shared_ptr<Feature>,

View File

@ -47,25 +47,24 @@
namespace mapnik {
typedef boost::shared_ptr<raster> raster_ptr;
typedef std::string key_type;
typedef std::map<key_type,std::size_t> map_type;
typedef boost::associative_property_map<map_type> base_type;
class feature_impl;
template <typename T>
class context : private boost::noncopyable,
public base_type
public boost::associative_property_map<T>
{
friend class feature_impl;
public:
typedef map_type::value_type value_type;
typedef map_type::key_type key_type;
typedef map_type::size_type size_type;
typedef map_type::difference_type difference_type;
typedef map_type::iterator iterator;
typedef map_type::const_iterator const_iterator;
typedef T map_type;
typedef typename boost::associative_property_map<map_type> base_type;
typedef typename map_type::value_type value_type;
typedef typename map_type::key_type key_type;
typedef typename map_type::size_type size_type;
typedef typename map_type::difference_type difference_type;
typedef typename map_type::iterator iterator;
typedef typename map_type::const_iterator const_iterator;
context()
: base_type(mapping_) {}
@ -74,7 +73,7 @@ public:
{
mapping_.insert(std::make_pair(name,mapping_.size()));
}
std::size_t size() const { return mapping_.size(); }
size_type size() const { return mapping_.size(); }
const_iterator begin() const { return mapping_.begin();}
const_iterator end() const { return mapping_.end();}
@ -82,7 +81,8 @@ private:
map_type mapping_;
};
typedef boost::shared_ptr<context> context_ptr;
typedef context<std::map<std::string,std::size_t> > context_type;
typedef boost::shared_ptr<context_type> context_ptr;
class feature_impl : private boost::noncopyable
{
@ -104,9 +104,9 @@ public:
inline void set_id(int id) { id_ = id;}
template <typename T>
void put(key_type const& key, T const& val)
void put(context_type::key_type const& key, T const& val)
{
map_type::const_iterator itr = ctx_->mapping_.find(key);
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
@ -116,9 +116,9 @@ public:
throw std::out_of_range("Key doesn't exist");
}
void put(key_type const& key, value const& val)
void put(context_type::key_type const& key, value const& val)
{
map_type::const_iterator itr = ctx_->mapping_.find(key);
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
@ -128,14 +128,14 @@ public:
throw std::out_of_range("Key doesn't exist");
}
bool has_key(key_type const& key) const
bool has_key(context_type::key_type const& key) const
{
return (ctx_->mapping_.find(key) != ctx_->mapping_.end());
}
value_type const& get(key_type const& key) const
value_type const& get(context_type::key_type const& key) const
{
map_type::const_iterator itr = ctx_->mapping_.find(key);
context_type::map_type::const_iterator itr = ctx_->mapping_.find(key);
if (itr != ctx_->mapping_.end()
&& itr->second < data_.size())
{
@ -229,8 +229,8 @@ public:
{
std::stringstream ss;
ss << "Feature (" << std::endl;
map_type::const_iterator itr = ctx_->mapping_.begin();
map_type::const_iterator end = ctx_->mapping_.end();
context_type::map_type::const_iterator itr = ctx_->mapping_.begin();
context_type::map_type::const_iterator end = ctx_->mapping_.end();
for ( ;itr!=end; ++itr)
{
ss << " " << itr->first << ":" << data_[itr->second] << std::endl;

View File

@ -391,7 +391,7 @@ void csv_datasource::parse_csv(T& stream,
bool extent_initialized = false;
std::size_t num_headers = headers_.size();
ctx_ = boost::make_shared<mapnik::context>();
ctx_ = boost::make_shared<mapnik::context_type>();
for (std::size_t i = 0; i < headers_.size(); ++i)
{
ctx_->push(headers_[i]);

View File

@ -55,7 +55,7 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
double dy,
double filter_factor)
: dataset_(dataset),
ctx_(boost::make_shared<mapnik::context>()),
ctx_(boost::make_shared<mapnik::context_type>()),
band_(band),
gquery_(q),
raster_extent_(extent),

View File

@ -61,7 +61,7 @@ geos_featureset::geos_featureset(GEOSGeometry* geometry,
field_(field),
field_name_(field_name),
already_rendered_(false),
ctx_(boost::make_shared<mapnik::context>())
ctx_(boost::make_shared<mapnik::context_type>())
{
ctx_->push(field_name);
}

View File

@ -48,7 +48,7 @@ kismet_featureset::kismet_featureset(std::list<kismet_network_data> const& knd_l
feature_id_(1),
knd_list_it(knd_list_.begin()),
source_(srs),
ctx_(boost::make_shared<mapnik::context>())
ctx_(boost::make_shared<mapnik::context_type>())
{
ctx_->push("internet_access");
}

View File

@ -500,7 +500,7 @@ featureset_ptr occi_datasource::features(query const& q) const
std::set<std::string> const& props = q.property_names();
std::set<std::string>::const_iterator pos = props.begin();
std::set<std::string>::const_iterator end = props.end();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context>();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
for ( ;pos != end;++pos)
{
s << ", " << *pos;
@ -581,7 +581,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
s << "SELECT " << geometry_field_;
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context>();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
while (itr != end)
{
s << ", " << itr->get_name();

View File

@ -56,7 +56,7 @@ ogr_featureset::ogr_featureset(OGRDataSource & dataset,
tr_(new transcoder(encoding)),
fidcolumn_(layer_.GetFIDColumn ()),
count_(0),
ctx_(boost::make_shared<mapnik::context>())
ctx_(boost::make_shared<mapnik::context_type>())
{
layer_.SetSpatialFilter (&extent);
}

View File

@ -63,7 +63,7 @@ ogr_index_featureset<filterT>::ogr_index_featureset(OGRDataSource & dataset,
filter_(filter),
tr_(new transcoder(encoding)),
fidcolumn_(layer_.GetFIDColumn()),
ctx_(boost::make_shared<mapnik::context>())
ctx_(boost::make_shared<mapnik::context_type>())
{
boost::optional<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::find(index_file.c_str(),true);

View File

@ -508,7 +508,7 @@ featureset_ptr postgis_datasource::features(const query& q) const
std::set<std::string>::const_iterator pos=props.begin();
std::set<std::string>::const_iterator end=props.end();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context>();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
for ( ;pos != end;++pos)
{
@ -576,7 +576,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
if (!key_field_.empty())
mapnik::sql_utils::quote_attr(s,key_field_);
mapnik::context_ptr ctx = boost::make_shared<mapnik::context>();
mapnik::context_ptr ctx = boost::make_shared<mapnik::context_type>();
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();

View File

@ -50,7 +50,7 @@ raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
curIter_(policy_.begin()),
endIter_(policy_.end())
{
ctx_ = boost::make_shared<mapnik::context>();
ctx_ = boost::make_shared<mapnik::context_type>();
}
template <typename LookupPolicy>

View File

@ -48,7 +48,7 @@ shape_featureset<filterT>::shape_featureset(filterT const& filter,
row_limit_(row_limit),
count_(0)
{
ctx_ = boost::make_shared<mapnik::context>();
ctx_ = boost::make_shared<mapnik::context_type>();
shape_.shp().skip(100);
setup_attributes(ctx_, attribute_names, shape_name, shape_,attr_ids_);
}

View File

@ -49,7 +49,7 @@ shape_index_featureset<filterT>::shape_index_featureset(filterT const& filter,
row_limit_(row_limit),
count_(0)
{
ctx_ = boost::make_shared<mapnik::context>();
ctx_ = boost::make_shared<mapnik::context_type>();
shape_.shp().skip(100);
setup_attributes(ctx_, attribute_names, shape_name, shape_,attr_ids_);

View File

@ -8,7 +8,7 @@ hello_featureset::hello_featureset(mapnik::box2d<double> const& box, std::string
: box_(box),
feature_id_(1),
tr_(new mapnik::transcoder(encoding)),
ctx_(boost::make_shared<mapnik::context>()) { }
ctx_(boost::make_shared<mapnik::context_type>()) { }
hello_featureset::~hello_featureset() { }