diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/AugmentedLagrangianConstraint.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/AugmentedLagrangianConstraint.cpp index 0f2ac2fad2f..e3970402ce7 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/AugmentedLagrangianConstraint.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/AugmentedLagrangianConstraint.cpp @@ -31,11 +31,11 @@ namespace sofa::component::constraint::lagrangian::model using namespace sofa::defaulttype; using namespace sofa::helper; -int AugmentedLagrangianConstraintClass = core::RegisterObject("AugmentedLagrangianConstraint") - .add< AugmentedLagrangianConstraint >() - - ; - +void registerAugmentedLagrangianConstraint(sofa::core::ObjectFactory* factory) +{ + factory->registerObjects(core::ObjectRegistrationData("AugmentedLagrangianConstraint") + .add< AugmentedLagrangianConstraint >()); +} template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API BaseContactLagrangianConstraint; template class SOFA_COMPONENT_CONSTRAINT_LAGRANGIAN_MODEL_API AugmentedLagrangianConstraint; diff --git a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/init.cpp b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/init.cpp index de09f9f65d9..ba40a5df106 100644 --- a/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/init.cpp +++ b/Sofa/Component/Constraint/Lagrangian/Model/src/sofa/component/constraint/lagrangian/model/init.cpp @@ -26,6 +26,7 @@ namespace sofa::component::constraint::lagrangian::model { +extern void registerAugmentedLagrangianConstraint(sofa::core::ObjectFactory* factory); extern void registerBilateralLagrangianConstraint(sofa::core::ObjectFactory* factory); extern void registerFixedLagrangianConstraint(sofa::core::ObjectFactory* factory); extern void registerSlidingLagrangianConstraint(sofa::core::ObjectFactory* factory); @@ -57,6 +58,7 @@ const char* getModuleVersion() void registerObjects(sofa::core::ObjectFactory* factory) { + registerAugmentedLagrangianConstraint(factory); registerBilateralLagrangianConstraint(factory); registerFixedLagrangianConstraint(factory); registerSlidingLagrangianConstraint(factory); diff --git a/Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp b/Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp index 55b6be2b8b8..067f0bfef90 100644 --- a/Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp +++ b/Sofa/Component/IO/Mesh/tests/STLExporter_test.cpp @@ -69,6 +69,7 @@ class STLExporter_test : public BaseSimulationTest { { sofa::simpleapi::importPlugin("Sofa.Component.StateContainer"); sofa::simpleapi::importPlugin("Sofa.Component.Visual"); + sofa::simpleapi::importPlugin("Sofa.Component.IO.Mesh"); } void TearDown() override @@ -98,7 +99,6 @@ class STLExporter_test : public BaseSimulationTest { " \n" " \n" " \n" - " \n" " \n" " \n" " \n" diff --git a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp index 6f9d02cf2c8..20402e7c25f 100644 --- a/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp +++ b/Sofa/framework/Core/src/sofa/core/ObjectFactory.cpp @@ -775,7 +775,8 @@ bool ObjectFactory::registerObjectsFromPlugin(const std::string& pluginName) // do not register if it was already done before if(m_registeredPluginSet.count(pluginName) > 0) { - // msg_warning("ObjectFactory") << pluginName << " has already registered its components."; + // This warning should be generalized (i.e not only in dev mode) when runSofa will not auto-load modules/plugins by default anymore + dmsg_warning("ObjectFactory") << pluginName << " has already registered its components."; return false; } @@ -837,8 +838,8 @@ RegisterObject& RegisterObject::addCreator(std::string classname, std::string te RegisterObject::operator int() const { - //std::cout << "Implicit object registration is deprecrated since v24.06. Check #4429 for more information." << std::endl; - // msg_warning("RegisterObject") << "Implicit object registration is deprecrated since v24.06. Check #4429 for more information."; + dmsg_warning("RegisterObject") << m_objectRegistrationdata.entry.className + << ": Implicit object registration is deprecated since v24.12. Check #4429 for more information."; return commitTo(ObjectFactory::getInstance()); } diff --git a/Sofa/framework/Core/src/sofa/core/ObjectFactory.h b/Sofa/framework/Core/src/sofa/core/ObjectFactory.h index 302c70f3590..2126496ac8e 100644 --- a/Sofa/framework/Core/src/sofa/core/ObjectFactory.h +++ b/Sofa/framework/Core/src/sofa/core/ObjectFactory.h @@ -377,12 +377,14 @@ class SOFA_CORE_API ObjectRegistrationData /// This is the final operation that will actually commit the additions to the ObjectFactory. bool commitTo(sofa::core::ObjectFactory* objectFactory) const; + + friend class RegisterObject; }; // Legacy structure, to keep compatibility with olden code // using the singleton to get the instance of ObjectFactory -class /* SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT() */ SOFA_CORE_API RegisterObject +class SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT() SOFA_CORE_API RegisterObject { private: ObjectRegistrationData m_objectRegistrationdata; diff --git a/Sofa/framework/Helper/test/system/PluginManager_test.cpp b/Sofa/framework/Helper/test/system/PluginManager_test.cpp index ec780e35207..7673e8b6445 100644 --- a/Sofa/framework/Helper/test/system/PluginManager_test.cpp +++ b/Sofa/framework/Helper/test/system/PluginManager_test.cpp @@ -122,12 +122,22 @@ TEST_F(PluginManager_test, loadTestPluginAByPath) /// Check that existing plugins are correctly handled and returns no /// error/warning message. { - EXPECT_MSG_NOEMIT(Warning, Error); - + EXPECT_MSG_NOEMIT(Error, Warning); + std::cout << "PluginManager_test.loadTestPluginAByPath: " - << "pm.getPluginMap().size() = " << pm.getPluginMap().size() - << std::endl; + << "pm.getPluginMap().size() = " << pm.getPluginMap().size() + << std::endl; + } + { + EXPECT_MSG_NOEMIT(Error); + // Plugin A still uses the deprecated registration mechanism + // and is expected to throw a warning when loaded + EXPECT_MSG_EMIT(Warning); + ASSERT_EQ(pm.loadPluginByPath(pluginPath), PluginManager::PluginLoadStatus::SUCCESS); + } + { + EXPECT_MSG_NOEMIT(Error, Warning); ASSERT_GT(pm.findPlugin(pluginAName).size(), 0u); } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/RequiredPlugin.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/RequiredPlugin.cpp index 088e72f3251..32e49c43ebe 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/RequiredPlugin.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/RequiredPlugin.cpp @@ -136,17 +136,16 @@ bool RequiredPlugin::loadPlugin() objectFactory->registerObjectsFromPlugin(name); // fail-safe to check if potential components have been registered (implicitly or explicitly) - // SOFA_ATTRIBUTE_DEPRECATED__REGISTEROBJECT() std::vector entries; objectFactory->getEntriesFromTarget(entries, name); if (entries.empty()) { -// msg_warning() << "No component has been registered from " << name << ".\n" -// << "It could be because: \n" -// << " - the entrypoint registerObjects() has not been implemented;\n" -// << " - (deprecated) no sofa::core::RegisterObject() has been called;\n" -// << " - your plugin does not add any component (i.e BaseObject) into the factory. In that case, RequiredPlugin is not useful for this kind of plugin."; + msg_warning() << "No component has been registered from " << name << ".\n" + << "It could be because: \n" + << " - the entrypoint registerObjects() has not been implemented;\n" + << " - (deprecated since v24.12) no sofa::core::RegisterObject() has been called;\n" + << " - your plugin does not add any component (i.e BaseObject) into the factory. In that case, RequiredPlugin is not useful for this kind of plugin."; } if (d_stopAfterFirstSuffixFound.getValue()) break; diff --git a/Sofa/framework/Simulation/Core/test/RequiredPlugin_test.cpp b/Sofa/framework/Simulation/Core/test/RequiredPlugin_test.cpp index c9349748989..1013581b97a 100644 --- a/Sofa/framework/Simulation/Core/test/RequiredPlugin_test.cpp +++ b/Sofa/framework/Simulation/Core/test/RequiredPlugin_test.cpp @@ -85,7 +85,7 @@ struct RequiredPlugin_test : public BaseSimulationTest void testLoadPluginB() { - EXPECT_MSG_EMIT(Warning); // // TestPluginB does not register any component + EXPECT_MSG_EMIT(Warning); // TestPluginB does not register any component std::stringstream scene; scene << "" @@ -101,7 +101,7 @@ struct RequiredPlugin_test : public BaseSimulationTest void testLoadPluginC() { - EXPECT_MSG_NOEMIT(Warning); // // TestPluginC registers its component explicitly + EXPECT_MSG_NOEMIT(Warning); // TestPluginC registers its component explicitly std::stringstream scene; scene << "" @@ -118,8 +118,8 @@ struct RequiredPlugin_test : public BaseSimulationTest TEST_F(RequiredPlugin_test, testNotExistingPlugin ) { testNotExistingPlugin(); } TEST_F(RequiredPlugin_test, testNoParameter ) { testNoParameter(); } -TEST_F(RequiredPlugin_test, DISABLED_testLoadPluginA) { testLoadPluginA(); } // disabled because testLoadPluginA() should throw a warning (but this warning is commented for the moment) -TEST_F(RequiredPlugin_test, DISABLED_testLoadPluginB) { testLoadPluginB(); }// disabled because testLoadPluginB() should throw a warning (but this warning is commented for the moment) +TEST_F(RequiredPlugin_test, testLoadPluginA) { testLoadPluginA(); } +TEST_F(RequiredPlugin_test, testLoadPluginB) { testLoadPluginB(); } TEST_F(RequiredPlugin_test, testLoadPluginC) { testLoadPluginC(); } } diff --git a/Sofa/framework/Simulation/simutest/parallel_scenes_test.cpp b/Sofa/framework/Simulation/simutest/parallel_scenes_test.cpp index 8ed14089499..9e0385facb7 100644 --- a/Sofa/framework/Simulation/simutest/parallel_scenes_test.cpp +++ b/Sofa/framework/Simulation/simutest/parallel_scenes_test.cpp @@ -29,9 +29,6 @@ using sofa::simulation::Node ; #include using sofa::component::sceneutility::InfoComponent; -#include -using sofa::helper::system::PluginManager ; - #include using sofa::simulation::SceneLoaderXML ; @@ -47,10 +44,36 @@ class ParallelScenesTest : public virtual sofa::testing::BaseTest { } + void SetUp() override + { + EXPECT_MSG_NOEMIT(Error, Warning); + + sofa::simpleapi::importPlugin("Sofa.Component.AnimationLoop"); + sofa::simpleapi::importPlugin("Sofa.Component.Collision.Detection.Algorithm"); + sofa::simpleapi::importPlugin("Sofa.Component.Collision.Detection.Intersection"); + sofa::simpleapi::importPlugin("Sofa.Component.Collision.Geometry"); + sofa::simpleapi::importPlugin("Sofa.Component.Collision.Response.Contact"); + sofa::simpleapi::importPlugin("Sofa.Component.Constraint.Lagrangian.Correction"); + sofa::simpleapi::importPlugin("Sofa.Component.Constraint.Lagrangian.Solver"); + sofa::simpleapi::importPlugin("Sofa.Component.Constraint.Projective"); + sofa::simpleapi::importPlugin("Sofa.Component.IO.Mesh"); + sofa::simpleapi::importPlugin("Sofa.Component.LinearSolver.Iterative"); + sofa::simpleapi::importPlugin("Sofa.Component.Mapping.Linear"); + sofa::simpleapi::importPlugin("Sofa.Component.Mass"); + sofa::simpleapi::importPlugin("Sofa.Component.ODESolver.Backward"); + sofa::simpleapi::importPlugin("Sofa.Component.SolidMechanics.FEM.Elastic"); + sofa::simpleapi::importPlugin("Sofa.Component.StateContainer"); + sofa::simpleapi::importPlugin("Sofa.Component.Topology.Container.Constant"); + sofa::simpleapi::importPlugin("Sofa.Component.Topology.Container.Dynamic"); + sofa::simpleapi::importPlugin("Sofa.Component.Topology.Container.Grid"); + sofa::simpleapi::importPlugin("Sofa.Component.Visual"); + sofa::simpleapi::importPlugin("Sofa.GL.Component.Rendering3D"); + sofa::simpleapi::importPlugin("Sofa.Component.LinearSystem"); + } + void executeInParallel(const char* sceneStr, const std::size_t nbScenes, const std::size_t nbSteps) { - EXPECT_MSG_NOEMIT(Error); - EXPECT_MSG_NOEMIT(Warning); + EXPECT_MSG_NOEMIT(Error, Warning); std::vector groots; groots.resize(nbScenes); @@ -104,21 +127,6 @@ class ParallelScenesTest : public virtual sofa::testing::BaseTest const std::string sceneStr = R"( - - - - - - - - - - - - - - - @@ -160,29 +168,6 @@ class ParallelScenesTest : public virtual sofa::testing::BaseTest const std::string sceneStr = R"( - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applications/projects/SceneChecking/tests/SceneChecker_test.cpp b/applications/projects/SceneChecking/tests/SceneChecker_test.cpp index 9de8d0bbcf4..2ccaba88ecb 100644 --- a/applications/projects/SceneChecking/tests/SceneChecker_test.cpp +++ b/applications/projects/SceneChecking/tests/SceneChecker_test.cpp @@ -173,11 +173,12 @@ struct SceneChecker_test : public BaseSimulationTest EXPECT_MSG_NOEMIT(Warning); const std::string lvl = (shouldWarn)?"17.06":"17.12"; - + + sofa::simpleapi::importPlugin("Sofa.Component.SceneUtility"); + std::stringstream scene; scene << " \n" << " \n" - << " \n" << " \n" << " \n" << " \n";