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:
Dane Springmeyer 2009-06-22 06:59:56 +00:00
parent 8c60753db6
commit 14ef2b36f0
2 changed files with 15 additions and 3 deletions

View file

@ -49,6 +49,7 @@ namespace mapnik {
static bool registered_;
static bool insert(const std::string& name,const lt_dlhandle module);
public:
static std::vector<std::string> plugin_names ();
static void register_datasources(const std::string& path);
static boost::shared_ptr<datasource> create(parameters const& params);
};

View file

@ -109,11 +109,22 @@ namespace mapnik
}
bool datasource_cache::insert(const std::string& type,const lt_dlhandle module)
{
{
return plugins_.insert(make_pair(type,boost::shared_ptr<PluginInfo>
(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)
{
#ifdef MAPNIK_THREADSAFE
@ -146,14 +157,14 @@ namespace mapnik
if (ds_name && insert(ds_name(),module))
{
#ifdef MAPNIK_DEBUG
std::clog<<"registered datasource : "<<ds_name()<<std::endl;
std::clog << "registered datasource : " << ds_name() << std::endl;
#endif
registered_=true;
}
}
else
{
std::clog << lt_dlerror() << "\n";
std::clog << "plugin" << ds_name() << ": " << lt_dlerror() << "\n" << std::endl;
}
}
catch (...) {}