Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace sofa::component::odesolver::backward
{

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
Expand All @@ -52,13 +52,27 @@ const char* getModuleVersion()

void registerObjects(sofa::core::ObjectFactory* factory)
{
const auto isLoaded = sofa::helper::system::PluginManager::getInstance().isPluginLoaded(Sofa.Component.IntegrationScheme.Backward);
bool objLoaded = false;

if (isLoaded.second)
{
objLoaded = factory->registerObjectsFromPlugin(Sofa.Component.IntegrationScheme.Backward);

if (!objLoaded)
msg_error_once("Sofa.Component.ODESolver.Backward")<<"Registering objects from Sofa.Component.IntegrationScheme.Backward failed.";
}
}

void init()
{
msg_deprecated_once(MODULE_NAME)<<"This plugin is empty since v26.12 and will be removed in v27.12, load Sofa.Component.IntegrationScheme.Backward instead.";
auto status = sofa::helper::system::PluginManager::getInstance().loadPluginByName(Sofa.Component.IntegrationScheme.Backward) ;

if (status <= sofa::helper::system::PluginManager::PluginLoadStatus::ALREADY_LOADED)
msg_info_once("Sofa.Component.ODESolver.Backward")<<"Sofa.Component.IntegrationScheme.Backward has been loaded automatically.";
else
msg_error_once("Sofa.Component.ODESolver.Backward")<<"Tried to load Sofa.Component.IntegrationScheme.Backward automatically but failed.";
}

} // namespace sofa::component::odesolver::backward
4 changes: 3 additions & 1 deletion Sofa/Component/ODESolver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ set(SOURCE_FILES
${SOFACOMPONENTODESOLVER_SOURCE_DIR}/init.cpp
)

sofa_find_package(Sofa.Component.IntegrationScheme REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC ${SOFACOMPONENTODESOLVER_TARGETS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${SOFACOMPONENTODESOLVER_TARGETS} Sofa.Component.IntegrationScheme)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <sofa/component/odesolver/forward/init.h>

#include <sofa/Modules.h>
#include <sofa/component/odesolver/forward/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>
#include <sofa/Modules.h>

namespace sofa::component::odesolver::forward
{

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
Expand All @@ -52,12 +52,27 @@ const char* getModuleVersion()

void registerObjects(sofa::core::ObjectFactory* factory)
{
const auto isLoaded = sofa::helper::system::PluginManager::getInstance().isPluginLoaded(Sofa.Component.IntegrationScheme.Forward);
bool objLoaded = false;

if (isLoaded.second)
{
objLoaded = factory->registerObjectsFromPlugin(Sofa.Component.IntegrationScheme.Forward);

if (!objLoaded)
msg_error_once("Sofa.Component.ODESolver.Forward")<<"Registering objects from Sofa.Component.IntegrationScheme.Forward failed.";
}
}

void init()
{
msg_deprecated_once(MODULE_NAME)<<"This plugin is empty since v26.12 and will be removed in v27.12, load Sofa.Component.IntegrationScheme.Forward instead.";
auto status = sofa::helper::system::PluginManager::getInstance().loadPluginByName(Sofa.Component.IntegrationScheme.Forward) ;

if (status <= sofa::helper::system::PluginManager::PluginLoadStatus::ALREADY_LOADED)
msg_info_once("Sofa.Component.ODESolver.Forward")<<"Sofa.Component.IntegrationScheme.Forward has been loaded automatically.";
else
msg_error_once("Sofa.Component.ODESolver.Forward")<<"Tried to load Sofa.Component.IntegrationScheme.Forward automatically but failed.";
}

} // namespace sofa::component::odesolver::forward
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ foreach(target ${SOFACOMPONENTODESOLVER_SOURCE_DIR})
endforeach()

sofa_find_package(Sofa.Simulation.Core QUIET REQUIRED)
sofa_find_package(Sofa.Component.IntegrationScheme QUIET REQUIRED)

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
Expand Down
21 changes: 19 additions & 2 deletions Sofa/Component/ODESolver/compat/sofa/component/odesolver/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

namespace sofa::component::odesolver
{

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
Expand All @@ -52,12 +52,29 @@ const char* getModuleVersion()

void registerObjects(sofa::core::ObjectFactory* factory)
{
const auto isLoaded = sofa::helper::system::PluginManager::getInstance().isPluginLoaded(Sofa.Component.IntegrationScheme);
bool objLoaded = true;

if (isLoaded.second)
{

objLoaded &= factory->registerObjectsFromPlugin(Sofa.Component.IntegrationScheme.Backward);
objLoaded &= factory->registerObjectsFromPlugin(Sofa.Component.IntegrationScheme.Forward);

if (!objLoaded)
msg_error_once("Sofa.Component.ODESolver")<<"Registering objects from Sofa.Component.IntegrationScheme failed.";
}
}

void init()
{
msg_deprecated_once(MODULE_NAME)<<"This plugin and its sub-plugins are empty since v26.12 and will be removed in v27.12, load Sofa.Component.IntegrationScheme instead.";
msg_deprecated_once(MODULE_NAME)<<"This plugin is empty since v26.12 and will be removed in v27.12, load Sofa.Component.IntegrationScheme instead.";
auto status = sofa::helper::system::PluginManager::getInstance().loadPluginByName(Sofa.Component.IntegrationScheme) ;

if (status <= sofa::helper::system::PluginManager::PluginLoadStatus::ALREADY_LOADED)
msg_info_once("Sofa.Component.ODESolver")<<"Sofa.Component.IntegrationScheme has been loaded automatically.";
else
msg_error_once("Sofa.Component.ODESolver")<<"Tried to load Sofa.Component.IntegrationScheme automatically but failed.";
}

} // namespace sofa::component::integrationscheme
Loading