[datasource] add plugin_registered function
This commit is contained in:
parent
6fcdccaf83
commit
0f0e06c6b8
2 changed files with 27 additions and 4 deletions
|
@ -47,7 +47,8 @@ class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateSt
|
|||
friend class CreateStatic<datasource_cache>;
|
||||
|
||||
public:
|
||||
std::vector<std::string> plugin_names();
|
||||
bool plugin_registered(const std::string& plugin_name) const;
|
||||
std::vector<std::string> plugin_names() const;
|
||||
std::string plugin_directories();
|
||||
bool register_datasources(std::string const& path, bool recurse = false);
|
||||
bool register_datasource(std::string const& path);
|
||||
|
@ -62,7 +63,7 @@ class MAPNIK_DECL datasource_cache : public singleton<datasource_cache, CreateSt
|
|||
// but the instance also needs its own mutex to protect the
|
||||
// plugins_ and plugin_directories_ members which are potentially
|
||||
// modified recusrively by register_datasources(path, true);
|
||||
std::recursive_mutex instance_mutex_;
|
||||
mutable std::recursive_mutex instance_mutex_;
|
||||
};
|
||||
|
||||
extern template class MAPNIK_DECL singleton<datasource_cache, CreateStatic>;
|
||||
|
|
|
@ -113,7 +113,7 @@ datasource_ptr datasource_cache::create(parameters const& params)
|
|||
#ifdef __GNUC__
|
||||
__extension__
|
||||
#endif
|
||||
datasource_plugin* create_datasource = reinterpret_cast<datasource_plugin*>(itr->second->get_symbol("plugin"));
|
||||
datasource_plugin* create_datasource = reinterpret_cast<datasource_plugin*>(itr->second->get_symbol("plugin"));
|
||||
|
||||
if (!create_datasource)
|
||||
{
|
||||
|
@ -131,7 +131,29 @@ std::string datasource_cache::plugin_directories()
|
|||
return boost::algorithm::join(plugin_directories_, ", ");
|
||||
}
|
||||
|
||||
std::vector<std::string> datasource_cache::plugin_names()
|
||||
bool datasource_cache::plugin_registered(const std::string& plugin_name) const
|
||||
{
|
||||
#ifdef MAPNIK_STATIC_PLUGINS
|
||||
const auto static_names = get_static_datasource_names();
|
||||
const auto static_it = std::find(static_names.begin(), static_names.end(), plugin_name);
|
||||
if (static_it != static_names.end())
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
std::lock_guard<std::recursive_mutex> lock(instance_mutex_);
|
||||
#endif
|
||||
|
||||
std::map<std::string, std::shared_ptr<PluginInfo>>::const_iterator itr;
|
||||
for (itr = plugins_.begin(); itr != plugins_.end(); ++itr)
|
||||
{
|
||||
if (itr->second->name() == plugin_name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> datasource_cache::plugin_names() const
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
|
||||
|
|
Loading…
Reference in a new issue