diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index f1a033c69..02c1799c2 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -27,6 +27,7 @@ // boost #include #include +#include // mapnik #include // ltdl @@ -34,108 +35,114 @@ namespace mapnik { - using namespace std; - using namespace boost; - - datasource_cache::datasource_cache() - { - if (lt_dlinit()) throw; - } + using namespace std; + using namespace boost; + + bool is_input_plugin (std::string const& filename) + { + return boost::algorithm::ends_with(filename,".input"); + } + - datasource_cache::~datasource_cache() - { - lt_dlexit(); - } + datasource_cache::datasource_cache() + { + if (lt_dlinit()) throw; + } - std::map > datasource_cache::plugins_; - bool datasource_cache::registered_=false; + datasource_cache::~datasource_cache() + { + lt_dlexit(); + } + + std::map > datasource_cache::plugins_; + bool datasource_cache::registered_=false; - datasource_ptr datasource_cache::create(const parameters& params) - { - datasource_ptr ds; - try - { - boost::optional type = params.get("type"); - if (type) - { - map >::iterator itr=plugins_.find(*type); - if (itr!=plugins_.end()) - { - if (itr->second->handle()) - { - create_ds* create_datasource = - (create_ds*) lt_dlsym(itr->second->handle(), "create"); - if (!create_datasource) - { - std::clog << "Cannot load symbols: " << lt_dlerror() << std::endl; - } - else - { - ds=datasource_ptr(create_datasource(params), datasource_deleter()); - } - } - else - { - std::clog << "Cannot load library: " << lt_dlerror() << std::endl; - } - } - } -#ifdef MAPNIK_DEBUG - std::clog<<"datasource="< - (new PluginInfo(type,module)))).second; - } - - void datasource_cache::register_datasources(const std::string& str) - { - mutex::scoped_lock lock(mapnik::singleton::mutex_); - filesystem::path path(str); - filesystem::directory_iterator end_itr; - if (exists(path) && is_directory(path)) - { - for (filesystem::directory_iterator itr(path);itr!=end_itr;++itr ) + datasource_ptr datasource_cache::create(const parameters& params) + { + datasource_ptr ds; + try + { + boost::optional type = params.get("type"); + if (type) + { + map >::iterator itr=plugins_.find(*type); + if (itr!=plugins_.end()) { - if (!is_directory( *itr ) && itr->leaf()[0]!='.') - { - try - { - lt_dlhandle module=lt_dlopen(itr->string().c_str()); - if (module) - { - datasource_name* ds_name = - (datasource_name*) lt_dlsym(module, "datasource_name"); - if (ds_name && insert(ds_name(),module)) - { + if (itr->second->handle()) + { + create_ds* create_datasource = + (create_ds*) lt_dlsym(itr->second->handle(), "create"); + if (!create_datasource) + { + std::clog << "Cannot load symbols: " << lt_dlerror() << std::endl; + } + else + { + ds=datasource_ptr(create_datasource(params), datasource_deleter()); + } + } + else + { + std::clog << "Cannot load library: " << lt_dlerror() << std::endl; + } + } + } #ifdef MAPNIK_DEBUG - std::clog<<"registered datasource : "< + (new PluginInfo(type,module)))).second; + } + + void datasource_cache::register_datasources(const std::string& str) + { + mutex::scoped_lock lock(mapnik::singleton::mutex_); + filesystem::path path(str); + filesystem::directory_iterator end_itr; + if (exists(path) && is_directory(path)) + { + for (filesystem::directory_iterator itr(path);itr!=end_itr;++itr ) + { + if (!is_directory( *itr ) && is_input_plugin(itr->leaf())) + { + try + { + lt_dlhandle module=lt_dlopen(itr->string().c_str()); + if (module) + { + datasource_name* ds_name = + (datasource_name*) lt_dlsym(module, "datasource_name"); + if (ds_name && insert(ds_name(),module)) + { +#ifdef MAPNIK_DEBUG + std::clog<<"registered datasource : "<