Skip to content

Commit 7297ec2

Browse files
committed
exodus plugin: deprecate in libf3d and warn
1 parent 05d12db commit 7297ec2

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

library/src/engine.cxx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -265,32 +265,40 @@ std::map<std::string, bool> engine::getRenderingBackendList()
265265
//----------------------------------------------------------------------------
266266
void engine::loadPlugin(const std::string& pathOrName, const std::vector<fs::path>& searchPaths)
267267
{
268-
if (pathOrName.empty())
268+
std::string localPathOrName = pathOrName;
269+
270+
if (localPathOrName.empty())
269271
{
270272
return;
271273
}
272274

275+
// For easier removal when removing deprecation: F3D_DEPRECATED
276+
if (localPathOrName == "exodus") {
277+
f3d::log::warn("The 'exodus' plugin is deprecated, loading 'hdf' instead");
278+
localPathOrName = "hdf";
279+
}
280+
273281
std::string pluginOrigin = "static";
274282
factory* factory = factory::instance();
275283

276284
// check if the plugin is already loaded
277285
auto plugs = factory->getPlugins();
278-
if (std::any_of(plugs.cbegin(), plugs.cend(), [pathOrName](const plugin* plug)
279-
{ return (plug->getName() == pathOrName || plug->getOrigin() == pathOrName); }))
286+
if (std::any_of(plugs.cbegin(), plugs.cend(), [localPathOrName](const plugin* plug)
287+
{ return (plug->getName() == localPathOrName || plug->getOrigin() == localPathOrName); }))
280288
{
281-
log::debug("Plugin \"", pathOrName, "\" already loaded");
289+
log::debug("Plugin \"", localPathOrName, "\" already loaded");
282290
return;
283291
}
284292

285293
// check if the plugin is a known static plugin
286-
factory::plugin_initializer_t init_plugin = factory->getStaticInitializer(pathOrName);
294+
factory::plugin_initializer_t init_plugin = factory->getStaticInitializer(localPathOrName);
287295

288296
if (init_plugin == nullptr)
289297
{
290298
vtksys::DynamicLoader::LibraryHandle handle = nullptr;
291299
try
292300
{
293-
fs::path fullPath = utils::collapsePath(pathOrName);
301+
fs::path fullPath = utils::collapsePath(localPathOrName);
294302
if (fs::exists(fullPath))
295303
{
296304
// plugin provided as full path
@@ -313,7 +321,7 @@ void engine::loadPlugin(const std::string& pathOrName, const std::vector<fs::pat
313321
// Construct the library file name from the plugin name
314322
std::string libName = vtksys::DynamicLoader::LibPrefix();
315323
libName += "f3d-plugin-";
316-
libName += pathOrName;
324+
libName += localPathOrName;
317325
libName += vtksys::DynamicLoader::LibExtension();
318326

319327
// try search paths
@@ -323,7 +331,7 @@ void engine::loadPlugin(const std::string& pathOrName, const std::vector<fs::pat
323331
if (fs::exists(tryPath))
324332
{
325333
log::debug(
326-
"Trying to load \"", pathOrName, "\" plugin from: \"", tryPath.string(), "\"");
334+
"Trying to load \"", localPathOrName, "\" plugin from: \"", tryPath.string(), "\"");
327335
handle = vtksys::DynamicLoader::OpenLibrary(tryPath.string());
328336

329337
if (handle)
@@ -346,7 +354,7 @@ void engine::loadPlugin(const std::string& pathOrName, const std::vector<fs::pat
346354
handle = vtksys::DynamicLoader::OpenLibrary(libName);
347355
if (!handle)
348356
{
349-
throw engine::plugin_exception("Cannot open the library \"" + pathOrName +
357+
throw engine::plugin_exception("Cannot open the library \"" + localPathOrName +
350358
"\": " + vtksys::DynamicLoader::LastError());
351359
}
352360
else
@@ -365,7 +373,7 @@ void engine::loadPlugin(const std::string& pathOrName, const std::vector<fs::pat
365373
vtksys::DynamicLoader::GetSymbolAddress(handle, "init_plugin"));
366374
if (init_plugin == nullptr)
367375
{
368-
throw engine::plugin_exception("Cannot find init_plugin symbol in library \"" + pathOrName +
376+
throw engine::plugin_exception("Cannot find init_plugin symbol in library \"" + localPathOrName +
369377
"\": " + vtksys::DynamicLoader::LastError());
370378
}
371379
}

library/testing/TestSDKEngine.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ int TestSDKEngine(int argc, char* argv[])
1717
try { f3d::engine::loadPlugin("alembic", {argv[3]}); } catch (...) {}
1818
try { f3d::engine::loadPlugin("assimp", {argv[3]}); } catch (...) {}
1919
try { f3d::engine::loadPlugin("draco", {argv[3]}); } catch (...) {}
20+
try { f3d::engine::loadPlugin("exodus", {argv[3]}); } catch (...) {} // F3D_DEPRECATED
2021
try { f3d::engine::loadPlugin("hdf", {argv[3]}); } catch (...) {}
2122
try { f3d::engine::loadPlugin("occt", {argv[3]}); } catch (...) {}
2223
try { f3d::engine::loadPlugin("usd", {argv[3]}); } catch (...) {}

0 commit comments

Comments
 (0)