split up code that handles datasource plugin registration
This commit is contained in:
parent
5df056ae4c
commit
d33496baa7
2 changed files with 51 additions and 43 deletions
|
@ -54,7 +54,8 @@ private:
|
|||
public:
|
||||
static std::vector<std::string> plugin_names();
|
||||
static std::string plugin_directories();
|
||||
static void register_datasources(const std::string& path);
|
||||
static void register_datasources(std::string const& path);
|
||||
static bool register_datasource(std::string const& path);
|
||||
static boost::shared_ptr<datasource> create(parameters const& params, bool bind=true);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
|
|||
return ds;
|
||||
}
|
||||
|
||||
bool datasource_cache::insert(const std::string& type,const lt_dlhandle module)
|
||||
bool datasource_cache::insert(std::string const& type,const lt_dlhandle module)
|
||||
{
|
||||
return plugins_.insert(make_pair(type,boost::make_shared<PluginInfo>
|
||||
(type,module))).second;
|
||||
|
@ -140,7 +140,7 @@ std::vector<std::string> datasource_cache::plugin_names ()
|
|||
return names;
|
||||
}
|
||||
|
||||
void datasource_cache::register_datasources(const std::string& str)
|
||||
void datasource_cache::register_datasources(std::string const& str)
|
||||
{
|
||||
#ifdef MAPNIK_THREADSAFE
|
||||
mutex::scoped_lock lock(mapnik::singleton<mapnik::datasource_cache,
|
||||
|
@ -162,13 +162,25 @@ void datasource_cache::register_datasources(const std::string& str)
|
|||
if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf()))
|
||||
#endif
|
||||
{
|
||||
#if (BOOST_FILESYSTEM_VERSION == 3)
|
||||
if (register_datasource(itr->path().string().c_str()))
|
||||
#else // v2
|
||||
if (register_datasource(itr->string().c_str()))
|
||||
#endif
|
||||
{
|
||||
registered_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool datasource_cache::register_datasource(std::string const& str)
|
||||
{
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
#if (BOOST_FILESYSTEM_VERSION == 3)
|
||||
lt_dlhandle module = lt_dlopen(itr->path().string().c_str());
|
||||
#else // v2
|
||||
lt_dlhandle module = lt_dlopen(itr->string().c_str());
|
||||
#endif
|
||||
lt_dlhandle module = lt_dlopen(str.c_str());
|
||||
if (module)
|
||||
{
|
||||
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
|
||||
|
@ -181,32 +193,27 @@ void datasource_cache::register_datasources(const std::string& str)
|
|||
{
|
||||
MAPNIK_LOG_DEBUG(datasource_cache) << "datasource_cache: Registered=" << ds_name();
|
||||
|
||||
registered_=true;
|
||||
success = true;
|
||||
}
|
||||
else if (!ds_name)
|
||||
{
|
||||
MAPNIK_LOG_ERROR(datasource_cache)
|
||||
<< "Problem loading plugin library '"
|
||||
<< itr->path().string() << "' (plugin is lacking compatible interface)";
|
||||
<< str << "' (plugin is lacking compatible interface)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (BOOST_FILESYSTEM_VERSION == 3)
|
||||
MAPNIK_LOG_ERROR(datasource_cache)
|
||||
<< "Problem loading plugin library: " << itr->path().string()
|
||||
<< "Problem loading plugin library: " << str
|
||||
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)";
|
||||
#else // v2
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
MAPNIK_LOG_ERROR(datasource_cache)
|
||||
<< "Problem loading plugin library: " << itr->string()
|
||||
<< " (dlopen failed - plugin likely has an unsatisfied dependency or incompatible ABI)";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
}
|
||||
<< "Exception caught while loading plugin library: " << str;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue