From a6191fade0eac5b90dbcd9501b00a0712ac1e34f Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Mon, 12 Dec 2005 13:15:33 +0000 Subject: [PATCH] 1. corrected LIBS in SConsctipt files 2. use boost::shared_ptr instead of ref_ptr --- SConstruct | 6 +- agg/SConscript | 2 +- boost/SConscript | 4 +- datasources/postgis/connection.hpp | 6 +- datasources/postgis/connection_manager.hpp | 15 +-- datasources/postgis/postgis.cpp | 17 +-- datasources/postgis/postgis.hpp | 4 +- datasources/postgis/postgisfs.cpp | 4 +- datasources/raster/raster_featureset.cpp | 2 +- datasources/shape/SConscript | 2 +- datasources/shape/shape_featureset.cpp | 6 +- datasources/shape/shape_index_featureset.cpp | 2 +- include/datasource.hpp | 25 +++-- include/datasource_cache.hpp | 12 +-- include/feature.hpp | 2 +- include/feature_type_style.hpp | 1 - include/filter.hpp | 2 +- include/filter_factory.hpp | 9 +- include/filter_parser.hpp | 97 ++++++++--------- include/geometry.hpp | 5 +- include/layer.hpp | 10 +- include/mapnik.hpp | 1 - include/pool.hpp | 7 +- include/ptr.hpp | 107 ------------------- include/render.hpp | 2 - include/rule.hpp | 6 +- include/style.hpp | 12 +-- include/style_cache.hpp | 1 - include/text.hpp | 4 +- include/text_symbolizer.hpp | 7 +- python/SConscript | 4 +- python/mapnik_python.cpp | 51 +++------ settings.py | 2 +- src/datasource_cache.cpp | 12 +-- src/layer.cpp | 10 +- src/style.cpp | 2 +- src/style_cache.cpp | 2 +- 37 files changed, 168 insertions(+), 295 deletions(-) delete mode 100644 include/ptr.hpp diff --git a/SConstruct b/SConstruct index 8ac65debe..991b5ca41 100644 --- a/SConstruct +++ b/SConstruct @@ -67,13 +67,17 @@ if not conf.CheckLib('z'): Exit(1) if not conf.CheckLibWithHeader('png','png.h','C'): - print 'Could not find libpng/headers, exiting!' + print 'Could not find png lib and/or headers, exiting!' Exit(1) if not conf.CheckLib('jpeg'): print 'Could not find jpeg lib, exiting!' Exit(1) +if not conf.CheckLibWithHeader('tiff','tiff.h','C'): + print 'Could not find tiff lib and/or headers, exiting!' + Exit(1) + env = conf.Finish() Export('env') diff --git a/agg/SConscript b/agg/SConscript index 810972d28..8ce860d15 100644 --- a/agg/SConscript +++ b/agg/SConscript @@ -25,4 +25,4 @@ agg_root = env['AGG_ROOT'] agg_headers = agg_root + '/include' agg_src_dir = agg_root + '/src/' agg_src = glob.glob(agg_src_dir + '*.cpp') -agg_lib = env.StaticLibrary('libagg',agg_src,CPPPATH=agg_headers) +agg_lib = env.StaticLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers) diff --git a/boost/SConscript b/boost/SConscript index 94b6416be..b015e7c2d 100644 --- a/boost/SConscript +++ b/boost/SConscript @@ -27,12 +27,12 @@ boost_root = env['BOOST_ROOT'] # boost filesystem filesystem_src_dir = boost_root + '/libs/filesystem/src/' boost_fs_src= glob.glob(filesystem_src_dir + '*.cpp') -lib_boost_filesystem = env.SharedLibrary('libboost-filesystem',boost_fs_src,CPPPATH=boost_root) +lib_boost_filesystem = env.SharedLibrary('libboost-filesystem',boost_fs_src,LIBS=[],CPPPATH=boost_root) env.Install(prefix+'/lib',lib_boost_filesystem) #boost regex regex_src_dir = boost_root + '/libs/regex/src/' boost_regex_src = glob.glob(regex_src_dir+ '*.cpp') -lib_boost_regex = env.SharedLibrary('libboost-regex',boost_regex_src,CPPPATH=boost_root) +lib_boost_regex = env.SharedLibrary('libboost-regex',boost_regex_src,LIBS=[],CPPPATH=boost_root) env.Install(prefix+'/lib',lib_boost_regex) diff --git a/datasources/postgis/connection.hpp b/datasources/postgis/connection.hpp index e28610bcb..1977cf5a4 100644 --- a/datasources/postgis/connection.hpp +++ b/datasources/postgis/connection.hpp @@ -56,16 +56,16 @@ public: PQclear(result); return ok; } - ref_ptr executeQuery(const std::string& sql,int type=0) const + boost::shared_ptr executeQuery(const std::string& sql,int type=0) const { PGresult *result=0; if (type==1) { result=PQexecParams(conn_,sql.c_str(),0,0,0,0,0,1); - return ref_ptr(new ResultSet(result)); + return boost::shared_ptr(new ResultSet(result)); } result=PQexec(conn_,sql.c_str()); - return ref_ptr(new ResultSet(result)); + return boost::shared_ptr(new ResultSet(result)); } bool isOK() const { diff --git a/datasources/postgis/connection_manager.hpp b/datasources/postgis/connection_manager.hpp index 1ed8f3567..4379d65e4 100644 --- a/datasources/postgis/connection_manager.hpp +++ b/datasources/postgis/connection_manager.hpp @@ -25,6 +25,7 @@ #include "pool.hpp" #include "utils.hpp" #include "connection.hpp" +#include using namespace mapnik; using std::string; @@ -59,8 +60,8 @@ class ConnectionManager : public singleton friend class CreateStatic; typedef Pool PoolType; - typedef std::map > ContType; - typedef ref_ptr HolderType; + typedef std::map > ContType; + typedef boost::shared_ptr HolderType; ContType pools_; public: @@ -71,13 +72,13 @@ public: if (pools_.find(creator.id())==pools_.end()) { return pools_.insert(std::make_pair(creator.id(), - ref_ptr(new PoolType(creator,initialSize,maxSize)))).second; + boost::shared_ptr(new PoolType(creator,initialSize,maxSize)))).second; } return false; } - const ref_ptr& getPool(const std::string& key) + const boost::shared_ptr& getPool(const std::string& key) { Lock lock(&mutex_); ContType::const_iterator itr=pools_.find(key); @@ -85,7 +86,7 @@ public: { return itr->second; } - static const ref_ptr emptyPool(0); + static const boost::shared_ptr emptyPool; return emptyPool; } @@ -95,10 +96,10 @@ public: ContType::const_iterator itr=pools_.find(key); if (itr!=pools_.end()) { - ref_ptr pool=itr->second; + boost::shared_ptr pool=itr->second; return pool->borrowObject(); } - static const HolderType EmptyConn(0); + static const HolderType EmptyConn; return EmptyConn; } diff --git a/datasources/postgis/postgis.cpp b/datasources/postgis/postgis.cpp index 1f6848439..273f1c9b6 100644 --- a/datasources/postgis/postgis.cpp +++ b/datasources/postgis/postgis.cpp @@ -36,6 +36,7 @@ using std::endl; using boost::lexical_cast; using boost::bad_lexical_cast; +using boost::shared_ptr; postgis_datasource::postgis_datasource(const Parameters& params) : table_(params.get("table")), @@ -50,13 +51,13 @@ postgis_datasource::postgis_datasource(const Parameters& params) ConnectionManager *mgr=ConnectionManager::instance(); mgr->registerPool(creator_,10,20); - ref_ptr > pool=mgr->getPool(creator_.id()); + shared_ptr > pool=mgr->getPool(creator_.id()); if (pool) { - const ref_ptr& conn = pool->borrowObject(); + const shared_ptr& conn = pool->borrowObject(); if (conn && conn->isOK()) { - PoolGuard,ref_ptr > > guard(conn,pool); + PoolGuard,shared_ptr > > guard(conn,pool); std::string table_name=table_from_sql(table_); @@ -64,7 +65,7 @@ postgis_datasource::postgis_datasource(const Parameters& params) s << "select f_geometry_column,srid,type from "; s << GEOMETRY_COLUMNS <<" where f_table_name='"< rs=conn->executeQuery(s.str()); + shared_ptr rs=conn->executeQuery(s.str()); if (rs->next()) { @@ -179,13 +180,13 @@ featureset_ptr postgis_datasource::features(const query& q) const Featureset *fs=0; Envelope const& box=q.get_bbox(); ConnectionManager *mgr=ConnectionManager::instance(); - ref_ptr > pool=mgr->getPool(creator_.id()); + shared_ptr > pool=mgr->getPool(creator_.id()); if (pool) { - const ref_ptr& conn = pool->borrowObject(); + const shared_ptr& conn = pool->borrowObject(); if (conn && conn->isOK()) { - PoolGuard,ref_ptr > > guard(conn,pool); + PoolGuard,shared_ptr > > guard(conn,pool); std::ostringstream s; // can we rely on 'gid' name??? s << "select gid,asbinary("< rs=conn->executeQuery(s.str(),1); + shared_ptr rs=conn->executeQuery(s.str(),1); fs=new postgis_featureset(rs,props.size()); } } diff --git a/datasources/postgis/postgis.hpp b/datasources/postgis/postgis.hpp index d067bdbd8..a2ad1bc60 100644 --- a/datasources/postgis/postgis.hpp +++ b/datasources/postgis/postgis.hpp @@ -65,12 +65,12 @@ private: class postgis_featureset : public Featureset { private: - ref_ptr rs_; + boost::shared_ptr rs_; unsigned num_attrs_; mutable int totalGeomSize_; mutable int count_; public: - postgis_featureset(const ref_ptr& rs,unsigned num_attrs); + postgis_featureset(const boost::shared_ptr& rs,unsigned num_attrs); void dispose(); feature_ptr next(); ~postgis_featureset(); diff --git a/datasources/postgis/postgisfs.cpp b/datasources/postgis/postgisfs.cpp index 6e1e18a62..83c76709a 100644 --- a/datasources/postgis/postgisfs.cpp +++ b/datasources/postgis/postgisfs.cpp @@ -27,7 +27,7 @@ using boost::lexical_cast; using boost::bad_lexical_cast; using std::string; -postgis_featureset::postgis_featureset(const ref_ptr& rs, +postgis_featureset::postgis_featureset(boost::shared_ptr const& rs, unsigned num_attrs=0) : rs_(rs), num_attrs_(num_attrs), @@ -97,7 +97,7 @@ feature_ptr postgis_featureset::next() rs_->close(); std::cout << "totalGeomSize="<::next() } else { - return feature_ptr(0); + return feature_ptr(); } } @@ -152,7 +152,7 @@ feature_ptr shape_featureset::next() break; } default: - return feature_ptr(0); + return feature_ptr(); } if (attr_ids_.size()) @@ -178,7 +178,7 @@ feature_ptr shape_featureset::next() else { std::cout<<" total shapes read="<::next() else { std::cout< #include -#include "ptr.hpp" #include "ctrans.hpp" #include "params.hpp" #include "feature.hpp" #include "query.hpp" #include "feature_layer_desc.hpp" +//#include "ptr.hpp" +#include + namespace mapnik { - typedef ref_ptr feature_ptr; + typedef shared_ptr feature_ptr; struct Featureset { virtual feature_ptr next()=0; virtual ~Featureset() {}; }; - typedef ref_ptr featureset_ptr; + typedef shared_ptr featureset_ptr; class datasource_exception : public std::exception { private: @@ -73,17 +75,18 @@ namespace mapnik typedef datasource* create_ds(const Parameters& params); typedef void destroy_ds(datasource *ds); - template - struct datasource_delete + + class datasource_deleter { - static void destroy(DATASOURCE* ds) - { + public: + void operator() (datasource* ds) + { delete ds; - } + } }; - typedef ref_ptr datasource_p; - + typedef boost::shared_ptr datasource_p; + /////////////////////////////////////////// #define DATASOURCE_PLUGIN(classname) \ extern "C" std::string datasource_name() \ @@ -92,7 +95,7 @@ namespace mapnik }\ extern "C" datasource* create(const Parameters ¶ms) \ { \ - return new classname(params);\ + return new classname(params); \ }\ extern "C" void destroy(datasource *ds) \ { \ diff --git a/include/datasource_cache.hpp b/include/datasource_cache.hpp index ca00d82d5..c71744424 100644 --- a/include/datasource_cache.hpp +++ b/include/datasource_cache.hpp @@ -18,14 +18,14 @@ //$Id: datasource_cache.hpp 39 2005-04-10 20:39:53Z pavlenko $ -#ifndef DSFACTORY_HPP -#define DSFACTORY_HPP +#ifndef DATASOURCE_CACHE_HPP +#define DATASOURCE_CACHE_HPP #include "utils.hpp" -#include "ptr.hpp" #include "params.hpp" #include "plugin.hpp" #include "datasource.hpp" +#include #include namespace mapnik @@ -38,12 +38,12 @@ namespace mapnik ~datasource_cache(); datasource_cache(const datasource_cache&); datasource_cache& operator=(const datasource_cache&); - static std::map > plugins_; + static std::map > plugins_; static bool registered_; static bool insert(const std::string& name,const lt_dlhandle module); public: static void register_datasources(const std::string& path); - static ref_ptr create(const Parameters& params); + static boost::shared_ptr create(Parameters const& params); }; } -#endif //DSFACTORY_HPP +#endif //DATASOURCE_CACHE_HPP diff --git a/include/feature.hpp b/include/feature.hpp index 4ec93080f..2f7f42326 100644 --- a/include/feature.hpp +++ b/include/feature.hpp @@ -28,7 +28,7 @@ namespace mapnik { - typedef ref_ptr raster_ptr; + typedef boost::shared_ptr raster_ptr; typedef std::vector properties; template diff --git a/include/feature_type_style.hpp b/include/feature_type_style.hpp index 952f76ccd..4cce62909 100644 --- a/include/feature_type_style.hpp +++ b/include/feature_type_style.hpp @@ -23,7 +23,6 @@ #include "rule.hpp" #include "feature.hpp" -#include "ptr.hpp" #include namespace mapnik diff --git a/include/filter.hpp b/include/filter.hpp index 53396bf24..99f6c889b 100644 --- a/include/filter.hpp +++ b/include/filter.hpp @@ -25,7 +25,7 @@ #include "feature.hpp" namespace mapnik { - typedef ref_ptr > filter_ptr; + typedef boost::shared_ptr > filter_ptr; template class filter_visitor; template diff --git a/include/filter_factory.hpp b/include/filter_factory.hpp index ef8910ad8..6c840b89f 100644 --- a/include/filter_factory.hpp +++ b/include/filter_factory.hpp @@ -18,6 +18,9 @@ //$Id$ +#ifndef FILTER_FACTORY_HPP +#define FILTER_FACTORY_HPP + #include "filter_parser.hpp" using std::string; @@ -30,8 +33,8 @@ namespace mapnik public: static filter_ptr compile(string const& str) { - stack > > filters; - stack > > exps; + stack > > filters; + stack > > exps; filter_grammar grammar(filters,exps); char const *text = str.c_str(); parse_info<> info = parse(text,text+strlen(text),grammar,space_p); @@ -47,3 +50,5 @@ namespace mapnik } }; } + +#endif //FILTER_FACTORY_HPP diff --git a/include/filter_parser.hpp b/include/filter_parser.hpp index 9bf9fd7c1..2ea16db1d 100644 --- a/include/filter_parser.hpp +++ b/include/filter_parser.hpp @@ -21,6 +21,7 @@ #ifndef FILTER_PARSER_HPP #define FILTER_PARSER_HPP +#include #include #include #include @@ -46,32 +47,32 @@ namespace mapnik template struct push_integer { - push_integer(stack > >& exprs) + push_integer(stack > >& exprs) : exprs_(exprs) {} void operator() (int val) const { - exprs_.push(ref_ptr >(new literal(val))); + exprs_.push(shared_ptr >(new literal(val))); } - stack > >& exprs_; + stack > >& exprs_; }; template struct push_real { - push_real(stack > >& exprs) + push_real(stack > >& exprs) : exprs_(exprs) {} void operator() (double val) const { - exprs_.push(ref_ptr >(new literal(val))); + exprs_.push(shared_ptr >(new literal(val))); } - stack > >& exprs_; + stack > >& exprs_; }; template struct push_string { - push_string(stack > >& exprs) + push_string(stack > >& exprs) : exprs_(exprs) {} template @@ -86,30 +87,30 @@ namespace mapnik str.erase(idx,1); idx = str.find(quote); } - exprs_.push(ref_ptr >(new literal(str))); + exprs_.push(shared_ptr >(new literal(str))); } - stack > >& exprs_; + stack > >& exprs_; }; template struct push_property { - push_property(stack > >& exprs) + push_property(stack > >& exprs) : exprs_(exprs) {} template void operator() (Iter start,Iter end) const { string str(start,end); - exprs_.push(ref_ptr >(new property(str))); + exprs_.push(shared_ptr >(new property(str))); } - stack > >& exprs_; + stack > >& exprs_; }; template struct compose_expression { - compose_expression(stack > >& exprs) + compose_expression(stack > >& exprs) : exprs_(exprs) {} template @@ -117,24 +118,24 @@ namespace mapnik { if (exprs_.size()>=2) { - ref_ptr > right = exprs_.top(); + shared_ptr > right = exprs_.top(); exprs_.pop(); - ref_ptr > left = exprs_.top(); + shared_ptr > left = exprs_.top(); exprs_.pop(); if (left && right) { - exprs_.push(ref_ptr >(new math_expr_b(*left,*right))); + exprs_.push(shared_ptr >(new math_expr_b(*left,*right))); } } } - stack > >& exprs_; + stack > >& exprs_; }; template struct compose_regex { - compose_regex(stack > >& filters, - stack > >& exprs) + compose_regex(stack > >& filters, + stack > >& exprs) : filters_(filters),exprs_(exprs) {} template @@ -142,14 +143,14 @@ namespace mapnik { if (exprs_.size()>=1) { - ref_ptr > exp = exprs_.top(); + shared_ptr > exp = exprs_.top(); exprs_.pop(); if (exp) { std::string pattern(start,end); try { - filters_.push(ref_ptr >(new regex_filter(*exp,pattern))); + filters_.push(shared_ptr >(new regex_filter(*exp,pattern))); } catch (...)//boost::regex_error& ex) { @@ -159,16 +160,16 @@ namespace mapnik } } } - stack > >& filters_; - stack > >& exprs_; + stack > >& filters_; + stack > >& exprs_; }; template struct compose_filter { - compose_filter(stack > >& filters, - stack > >& exprs) + compose_filter(stack > >& filters, + stack > >& exprs) : filters_(filters),exprs_(exprs) {} template @@ -176,24 +177,24 @@ namespace mapnik { if (exprs_.size()>=2) { - ref_ptr > right = exprs_.top(); + shared_ptr > right = exprs_.top(); exprs_.pop(); - ref_ptr > left = exprs_.top(); + shared_ptr > left = exprs_.top(); exprs_.pop(); if (left && right) { - filters_.push(ref_ptr >(new compare_filter(*left,*right))); + filters_.push(shared_ptr >(new compare_filter(*left,*right))); } } } - stack > >& filters_; - stack > >& exprs_; + stack > >& filters_; + stack > >& exprs_; }; template struct compose_and_filter { - compose_and_filter(stack > >& filters) + compose_and_filter(stack > >& filters) : filters_(filters) {} template @@ -201,23 +202,23 @@ namespace mapnik { if (filters_.size()>=2) { - ref_ptr > right = filters_.top(); + shared_ptr > right = filters_.top(); filters_.pop(); - ref_ptr > left = filters_.top(); + shared_ptr > left = filters_.top(); filters_.pop(); if (left && right) { - filters_.push(ref_ptr >(new logical_and(*left,*right))); + filters_.push(shared_ptr >(new logical_and(*left,*right))); } } } - stack > >& filters_; + stack > >& filters_; }; template struct compose_or_filter { - compose_or_filter(stack > >& filters) + compose_or_filter(stack > >& filters) : filters_(filters) {} template @@ -225,23 +226,23 @@ namespace mapnik { if (filters_.size()>=2) { - ref_ptr > right = filters_.top(); + shared_ptr > right = filters_.top(); filters_.pop(); - ref_ptr > left = filters_.top(); + shared_ptr > left = filters_.top(); filters_.pop(); if (left && right) { - filters_.push(ref_ptr >(new logical_or(*left,*right))); + filters_.push(shared_ptr >(new logical_or(*left,*right))); } } } - stack > >& filters_; + stack > >& filters_; }; template struct compose_not_filter { - compose_not_filter(stack > >& filters) + compose_not_filter(stack > >& filters) : filters_(filters) {} template @@ -249,22 +250,22 @@ namespace mapnik { if (filters_.size()>=1) { - ref_ptr > filter_ = filters_.top(); + shared_ptr > filter_ = filters_.top(); filters_.pop(); if (filter_) { - filters_.push(ref_ptr >(new logical_not(*filter_))); + filters_.push(shared_ptr >(new logical_not(*filter_))); } } } - stack > >& filters_; + stack > >& filters_; }; template struct filter_grammar : public grammar > { - filter_grammar(stack > >& filters_, - stack > >& exprs_) + filter_grammar(stack > >& filters_, + stack > >& exprs_) : filters(filters_),exprs(exprs_) {} template @@ -430,8 +431,8 @@ namespace mapnik symbols func2_op; symbols spatial_op; }; - stack > >& filters; - stack > >& exprs; + stack > >& filters; + stack > >& exprs; }; } diff --git a/include/geometry.hpp b/include/geometry.hpp index 312514104..cd9ec71d2 100644 --- a/include/geometry.hpp +++ b/include/geometry.hpp @@ -24,9 +24,10 @@ #include "vertex_vector.hpp" #include "vertex_transform.hpp" #include "ctrans.hpp" -#include "ptr.hpp" #include "geom_util.hpp" +#include + namespace mapnik { enum { @@ -259,7 +260,7 @@ namespace mapnik typedef polygon polygon_impl; typedef geometry geometry_type; - typedef ref_ptr geometry_ptr; + typedef boost::shared_ptr geometry_ptr; } #endif //GEOMETRY_HPP diff --git a/include/layer.hpp b/include/layer.hpp index eb86e8807..88b1c110b 100644 --- a/include/layer.hpp +++ b/include/layer.hpp @@ -23,8 +23,8 @@ #include #include "feature.hpp" -#include "ptr.hpp" #include "datasource.hpp" +#include namespace mapnik { @@ -40,7 +40,7 @@ namespace mapnik datasource_p ds_; std::vector styles_; std::string selection_style_; - mutable std::vector > selection_; + mutable std::vector > selection_; public: explicit Layer(const Parameters& params); @@ -62,8 +62,8 @@ namespace mapnik void setSelectable(bool selectable); bool isSelectable() const; bool isVisible(double scale) const; - void add_to_selection(ref_ptr& feature) const; - std::vector >& selection() const; + void add_to_selection(boost::shared_ptr& feature) const; + std::vector >& selection() const; void clear_selection() const; datasource_p const& datasource() const; Envelope envelope() const; @@ -72,4 +72,4 @@ namespace mapnik void swap(const Layer& other); }; } -#endif //LAYER_HPP +#endif //LAYER_HPP diff --git a/include/mapnik.hpp b/include/mapnik.hpp index 0c07e7b24..8ade5f884 100644 --- a/include/mapnik.hpp +++ b/include/mapnik.hpp @@ -25,7 +25,6 @@ #include #include #include "global.hpp" -#include "ptr.hpp" #include "factory.hpp" #include "filter.hpp" #include "query.hpp" diff --git a/include/pool.hpp b/include/pool.hpp index ede9a6990..97567bbd1 100644 --- a/include/pool.hpp +++ b/include/pool.hpp @@ -25,9 +25,8 @@ #include #include #include - -#include "ptr.hpp" #include "utils.hpp" +#include namespace mapnik { @@ -56,7 +55,7 @@ namespace mapnik template class Creator> class Pool { - typedef ref_ptr HolderType; + typedef boost::shared_ptr HolderType; typedef std::deque ContType; Creator creator_; @@ -90,7 +89,7 @@ namespace mapnik mutex_.unlock(); return usedPool_[usedPool_.size()-1]; } - static const HolderType defaultObj(0); + static const HolderType defaultObj; return defaultObj; } diff --git a/include/ptr.hpp b/include/ptr.hpp deleted file mode 100644 index 01a340b28..000000000 --- a/include/ptr.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* This file is part of Mapnik (c++ mapping toolkit) - * Copyright (C) 2005 Artem Pavlenko - * - * Mapnik is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -//$Id: ptr.hpp 39 2005-04-10 20:39:53Z pavlenko $ - -#ifndef PTR_HPP -#define PTR_HPP - -namespace mapnik -{ - - template struct DefaultDeletePolicy - { - static void destroy(T* p) - { - delete p; - } - }; - - template class DeallocPolicy=DefaultDeletePolicy> - class ref_ptr - { - private: - T* ptr_; - int* pCount_; - public: - T* operator->() {return ptr_;} - const T* operator->() const {return ptr_;} - T* get() {return ptr_;} - const T* get() const {return ptr_;} - const T& operator *() const {return *ptr_;} - T& operator *() {return *ptr_;} - explicit ref_ptr(T* ptr=0) - :ptr_(ptr),pCount_(new int(1)) {} - ref_ptr(const ref_ptr& rhs) - :ptr_(rhs.ptr_),pCount_(rhs.pCount_) - { - (*pCount_)++; - } - ref_ptr& operator=(const ref_ptr& rhs) - { - if (ptr_==rhs.ptr_) return *this; - if (--(*pCount_)==0) - { - DeallocPolicy::destroy(ptr_); - delete pCount_; - } - ptr_=rhs.ptr_; - pCount_=rhs.pCount_; - (*pCount_)++; - return *this; - } - bool operator !() const - { - return ptr_==0; - } - operator bool () const - { - return ptr_!=0; - } - inline friend bool operator==(const ref_ptr& lhs, - const T* rhs) - { - return lhs.ptr_==rhs; - } - inline friend bool operator==(const T* lhs, - const ref_ptr& rhs) - { - return lhs==rhs.ptr_; - } - inline friend bool operator!=(const ref_ptr& lhs, - const T* rhs) - { - return lhs.ptr_!=rhs; - } - inline friend bool operator!=(const T* lhs, - const ref_ptr& rhs) - { - return lhs!=rhs.ptr_; - } - ~ref_ptr() - { - if (--(*pCount_)==0) - { - DeallocPolicy::destroy(ptr_); - delete pCount_; - } - } - }; -} -#endif //PTR_HPP diff --git a/include/render.hpp b/include/render.hpp index ee2f328ef..cc7e0cd7c 100644 --- a/include/render.hpp +++ b/include/render.hpp @@ -22,8 +22,6 @@ #define RENDER_HPP #include -#include "memory.hpp" -#include "ptr.hpp" #include "style.hpp" #include "envelope.hpp" #include "graphics.hpp" diff --git a/include/rule.hpp b/include/rule.hpp index 397226b23..bab36104e 100644 --- a/include/rule.hpp +++ b/include/rule.hpp @@ -21,13 +21,13 @@ #include "symbolizer.hpp" #include "filter.hpp" -#include +#include #include #include namespace mapnik { - typedef ref_ptr symbolizer_ptr; + typedef boost::shared_ptr symbolizer_ptr; typedef std::vector symbolizers; template class all_filter; @@ -35,7 +35,7 @@ namespace mapnik class rule { typedef Filter filter_type; - typedef ref_ptr filter_ptr; + typedef boost::shared_ptr filter_ptr; private: std::string name_; diff --git a/include/style.hpp b/include/style.hpp index 13bcfc492..96aa6a696 100644 --- a/include/style.hpp +++ b/include/style.hpp @@ -22,26 +22,26 @@ #define STYLE_HPP #include "color.hpp" -#include "ptr.hpp" #include "symbolizer.hpp" #include #include #include +#include namespace mapnik { class Style { private: - std::vector > symbols_; - static ref_ptr zero_symbol_; + std::vector > symbols_; + static boost::shared_ptr zero_symbol_; public: - typedef std::vector >::const_iterator Iterator; + typedef std::vector >::const_iterator Iterator; Style() {} - Style(const ref_ptr& symbol) + Style(const boost::shared_ptr& symbol) { symbols_.push_back(symbol); } @@ -58,7 +58,7 @@ namespace mapnik return *this; } - void add(const ref_ptr& symbol) + void add(const boost::shared_ptr& symbol) { symbols_.push_back(symbol); } diff --git a/include/style_cache.hpp b/include/style_cache.hpp index 725981a59..a71e77758 100644 --- a/include/style_cache.hpp +++ b/include/style_cache.hpp @@ -22,7 +22,6 @@ #define STYLE_CACHE_HPP #include "utils.hpp" -#include "ptr.hpp" #include "style.hpp" #include #include "feature_type_style.hpp" diff --git a/include/text.hpp b/include/text.hpp index df70c28d7..6fc32e7d3 100644 --- a/include/text.hpp +++ b/include/text.hpp @@ -39,8 +39,8 @@ namespace mapnik std::string fontName_; public: TextRasterizer(PixBuffer& pixbuf,const char* fontName) - :pixbuf_(&pixbuf), - fontName_(fontName) {} + : pixbuf_(&pixbuf), + fontName_(fontName) {} void render(const char* text); private: TextRasterizer(const TextRasterizer&); diff --git a/include/text_symbolizer.hpp b/include/text_symbolizer.hpp index b69b5292e..fc724201a 100644 --- a/include/text_symbolizer.hpp +++ b/include/text_symbolizer.hpp @@ -45,11 +45,10 @@ namespace mapnik } private: expression* label_; - fill fill_; - + fill fill_; private: - text_symbolizer(const text_symbolizer&); - text_symbolizer& operator=(const text_symbolizer&); + text_symbolizer(text_symbolizer const&); + text_symbolizer& operator=(text_symbolizer const&); }; } diff --git a/python/SConscript b/python/SConscript index ee8adf2ee..2bd846a43 100644 --- a/python/SConscript +++ b/python/SConscript @@ -93,8 +93,8 @@ mapnik_python_src=Split( headers =[ '#include',boost_root,freetype2_root,agg_headers,python_headers] -libraries=['mapnik','agg','boost-filesystem','boost-regex','boost-python'] -libpaths = [prefix+"/lib",'#agg'] +libraries=['mapnik','boost-python'] +libpaths = [prefix+"/lib"] _mapnik_python = env.PythonExtension(target='_mapnik',\ source=mapnik_python_src,\ diff --git a/python/mapnik_python.cpp b/python/mapnik_python.cpp index 2a9b8f858..e222ed3e3 100644 --- a/python/mapnik_python.cpp +++ b/python/mapnik_python.cpp @@ -27,31 +27,6 @@ using namespace mapnik; -namespace boost -{ - namespace python - { - - template class DeallocPolicy> - T* get_pointer(ref_ptr< T , DeallocPolicy> const& ptr) - { - return ( T* )ptr.get(); - } - - template - struct pointee > - { - typedef T type; - }; - - template <> struct pointee > - { - typedef datasource type; - }; - } -} - void export_color(); void export_layer(); void export_parameters(); @@ -78,36 +53,36 @@ void render(const Map& map,Image32& image) } -ref_ptr create_point_symbolizer(std::string const& file,unsigned w,unsigned h) +boost::shared_ptr create_point_symbolizer(std::string const& file,unsigned w,unsigned h) { - return ref_ptr(new image_symbolizer(file,"png",w,h)); + return boost::shared_ptr(new image_symbolizer(file,"png",w,h)); } -ref_ptr create_line_symbolizer(const Color& pen,float width) +boost::shared_ptr create_line_symbolizer(const Color& pen,float width) { - return ref_ptr(new line_symbolizer(pen,width)); + return boost::shared_ptr(new line_symbolizer(pen,width)); } -ref_ptr create_line_symbolizer2(stroke const& strk) +boost::shared_ptr create_line_symbolizer2(stroke const& strk) { - return ref_ptr(new line_symbolizer(strk)); + return boost::shared_ptr(new line_symbolizer(strk)); } -ref_ptr create_polygon_symbolizer(const Color& fill) +boost::shared_ptr create_polygon_symbolizer(const Color& fill) { - return ref_ptr(new polygon_symbolizer(fill)); + return boost::shared_ptr(new polygon_symbolizer(fill)); } -ref_ptr create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h) +boost::shared_ptr create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h) { - return ref_ptr(new pattern_symbolizer(file,"png",w,h)); + return boost::shared_ptr(new pattern_symbolizer(file,"png",w,h)); } BOOST_PYTHON_MODULE(_mapnik) { using namespace boost::python; - class_, + class_, boost::noncopyable>("datasource",no_init) .def("envelope",&datasource::envelope, return_value_policy()) @@ -115,7 +90,7 @@ BOOST_PYTHON_MODULE(_mapnik) class_ ("symbolizer_",no_init) ; - class_, + class_, boost::noncopyable>("symbolizer",no_init) ; export_parameters(); @@ -144,6 +119,6 @@ BOOST_PYTHON_MODULE(_mapnik) def("line_symbolizer",&create_line_symbolizer2); def("polygon_symbolizer",&create_polygon_symbolizer); def("polygon_symbolizer",&create_polygon_symbolizer2); - register_ptr_to_python >(); + register_ptr_to_python >(); register_ptr_to_python(); } diff --git a/settings.py b/settings.py index 80d9b6d3b..6c36e1b2f 100644 --- a/settings.py +++ b/settings.py @@ -20,7 +20,7 @@ #edit this file PREFIX = '/opt/mapnik' BOOST_ROOT = '/opt/boost/boost_1_33_1' -FREETYPE2_ROOT = '/usr/include/freetype2' +FREETYPE2_ROOT = '/opt/freetype' PYTHON_VERSION = '2.4' PYTHON_ROOT = '/opt/python' AGG_ROOT = '/opt/agg-2.4' diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 93f463f7c..49f8f467c 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -39,16 +39,16 @@ namespace mapnik lt_dlexit(); } - std::map > datasource_cache::plugins_; + std::map > datasource_cache::plugins_; bool datasource_cache::registered_=false; datasource_p datasource_cache::create(const Parameters& params) { - datasource *ds=0; + datasource_p ds; try { std::string type=params.get("type"); - map >::iterator itr=plugins_.find(type); + map >::iterator itr=plugins_.find(type); if (itr!=plugins_.end()) { if (itr->second->handle()) @@ -60,7 +60,7 @@ namespace mapnik } else { - ds=create_datasource(params); + ds=datasource_p(create_datasource(params),datasource_deleter()); } } else @@ -78,12 +78,12 @@ namespace mapnik { std::cerr<<"exception caught "<(ds); + return ds; } bool datasource_cache::insert(const std::string& type,const lt_dlhandle module) { - return plugins_.insert(make_pair(type,ref_ptr(new PluginInfo(type,module)))).second; + return plugins_.insert(make_pair(type,boost::shared_ptr(new PluginInfo(type,module)))).second; } void datasource_cache::register_datasources(const std::string& str) diff --git a/src/layer.cpp b/src/layer.cpp index 9389a6ba5..57d44d664 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -19,7 +19,6 @@ //$Id: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $ #include -#include "ptr.hpp" #include "style.hpp" #include "datasource.hpp" #include "datasource_cache.hpp" @@ -41,17 +40,14 @@ namespace mapnik try { name_=params_.get("name"); - //volatile datasource_cache* factory=datasource_cache::instance(); - //ds_=factory->create(params_); ds_=datasource_cache::instance()->create(params_); - } catch (...) { throw; } } - + Layer::Layer(const Layer& rhs) :params_(rhs.params_), name_(rhs.name_), @@ -177,12 +173,12 @@ namespace mapnik return selection_style_; } - void Layer::add_to_selection(ref_ptr& feature) const + void Layer::add_to_selection(shared_ptr& feature) const { selection_.push_back(feature); } - vector >& Layer::selection() const + vector >& Layer::selection() const { return selection_; } diff --git a/src/style.cpp b/src/style.cpp index 3521bc9d9..55cbbaa50 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -22,5 +22,5 @@ namespace mapnik { - ref_ptr Style::zero_symbol_=ref_ptr(0); + boost::shared_ptr Style::zero_symbol_ = boost::shared_ptr(); } diff --git a/src/style_cache.cpp b/src/style_cache.cpp index 93179724c..317b73e48 100644 --- a/src/style_cache.cpp +++ b/src/style_cache.cpp @@ -49,7 +49,7 @@ namespace mapnik { return itr->second; } - static const Style default_style(ref_ptr(new line_symbolizer(Color(255,0,0)))); + static const Style default_style(boost::shared_ptr(new line_symbolizer(Color(255,0,0)))); return default_style; } ////////////////////////////////////////////////////////////////////////////