expose list of registered plugins as a 'plugin_names()' method of DatasourceCache similar to the FontEngine.face_names() - closes #246
This commit is contained in:
parent
8c60753db6
commit
14ef2b36f0
2 changed files with 15 additions and 3 deletions
|
@ -49,6 +49,7 @@ namespace mapnik {
|
||||||
static bool registered_;
|
static bool registered_;
|
||||||
static bool insert(const std::string& name,const lt_dlhandle module);
|
static bool insert(const std::string& name,const lt_dlhandle module);
|
||||||
public:
|
public:
|
||||||
|
static std::vector<std::string> plugin_names ();
|
||||||
static void register_datasources(const std::string& path);
|
static void register_datasources(const std::string& path);
|
||||||
static boost::shared_ptr<datasource> create(parameters const& params);
|
static boost::shared_ptr<datasource> create(parameters const& params);
|
||||||
};
|
};
|
||||||
|
|
|
@ -109,11 +109,22 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
|
|
||||||
bool datasource_cache::insert(const std::string& type,const lt_dlhandle module)
|
bool datasource_cache::insert(const std::string& type,const lt_dlhandle module)
|
||||||
{
|
{
|
||||||
return plugins_.insert(make_pair(type,boost::shared_ptr<PluginInfo>
|
return plugins_.insert(make_pair(type,boost::shared_ptr<PluginInfo>
|
||||||
(new PluginInfo(type,module)))).second;
|
(new PluginInfo(type,module)))).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> datasource_cache::plugin_names ()
|
||||||
|
{
|
||||||
|
std::vector<std::string> names;
|
||||||
|
std::map<std::string,boost::shared_ptr<PluginInfo> >::const_iterator itr;
|
||||||
|
for (itr = plugins_.begin();itr!=plugins_.end();++itr)
|
||||||
|
{
|
||||||
|
names.push_back(itr->first);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
void datasource_cache::register_datasources(const std::string& str)
|
void datasource_cache::register_datasources(const std::string& str)
|
||||||
{
|
{
|
||||||
#ifdef MAPNIK_THREADSAFE
|
#ifdef MAPNIK_THREADSAFE
|
||||||
|
@ -146,14 +157,14 @@ namespace mapnik
|
||||||
if (ds_name && insert(ds_name(),module))
|
if (ds_name && insert(ds_name(),module))
|
||||||
{
|
{
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog<<"registered datasource : "<<ds_name()<<std::endl;
|
std::clog << "registered datasource : " << ds_name() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
registered_=true;
|
registered_=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::clog << lt_dlerror() << "\n";
|
std::clog << "plugin" << ds_name() << ": " << lt_dlerror() << "\n" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (...) {}
|
catch (...) {}
|
||||||
|
|
Loading…
Reference in a new issue