From 8c8ed2531de01fd3d66333424c4fc46e1e199edf Mon Sep 17 00:00:00 2001 From: hugtalbot Date: Thu, 23 Jan 2025 07:49:32 +0100 Subject: [PATCH] [SceneUtility] Remove *AliasComponent --- Sofa/Component/SceneUtility/CMakeLists.txt | 4 - .../sceneutility/MakeAliasComponent.cpp | 90 ------- .../sceneutility/MakeAliasComponent.h | 73 ------ .../sceneutility/MakeDataAliasComponent.cpp | 120 ---------- .../sceneutility/MakeDataAliasComponent.h | 76 ------ .../src/sofa/component/sceneutility/init.cpp | 6 +- .../SceneUtility/tests/CMakeLists.txt | 2 - .../tests/MakeAliasComponent_test.cpp | 203 ---------------- .../tests/MakeDataAliasComponent_test.cpp | 226 ------------------ .../src/sofa/helper/ComponentChange.cpp | 2 - 10 files changed, 1 insertion(+), 801 deletions(-) delete mode 100644 Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.cpp delete mode 100644 Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.h delete mode 100644 Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.cpp delete mode 100644 Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.h delete mode 100644 Sofa/Component/SceneUtility/tests/MakeAliasComponent_test.cpp delete mode 100644 Sofa/Component/SceneUtility/tests/MakeDataAliasComponent_test.cpp diff --git a/Sofa/Component/SceneUtility/CMakeLists.txt b/Sofa/Component/SceneUtility/CMakeLists.txt index eb3562d6a15..dfebecb2701 100644 --- a/Sofa/Component/SceneUtility/CMakeLists.txt +++ b/Sofa/Component/SceneUtility/CMakeLists.txt @@ -9,8 +9,6 @@ set(HEADER_FILES ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/AddResourceRepository.h ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/APIVersion.h ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/InfoComponent.h - ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MakeAliasComponent.h - ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MakeDataAliasComponent.h ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MessageHandlerComponent.h ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/PauseAnimation.h ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/PauseAnimationOnEvent.h @@ -21,8 +19,6 @@ set(SOURCE_FILES ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/AddResourceRepository.cpp ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/APIVersion.cpp ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/InfoComponent.cpp - ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MakeAliasComponent.cpp - ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MakeDataAliasComponent.cpp ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/MessageHandlerComponent.cpp ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/PauseAnimation.cpp ${SOFACOMPONENTSCENEUTILITY_SOURCE_DIR}/PauseAnimationOnEvent.cpp diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.cpp b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.cpp deleted file mode 100644 index 0698496c34b..00000000000 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#include -#include -using sofa::core::ObjectFactory ; - -using sofa::core::objectmodel::ComponentState ; - -#include - -using std::string; - -namespace sofa::component::sceneutility -{ - -namespace makealiascomponent -{ - -MakeAliasComponent::MakeAliasComponent() : - d_targetcomponent(initData(&d_targetcomponent, "targetcomponent", "The component class for which to create an alias.")) - ,d_alias(initData(&d_alias, "alias", "The new alias of the component.")) -{ - d_componentState.setValue(ComponentState::Invalid) ; -} - -void MakeAliasComponent::parse ( core::objectmodel::BaseObjectDescription* arg ) -{ - BaseObject::parse(arg) ; - - const char* target=arg->getAttribute("targetcomponent") ; - if(target==nullptr) - { - msg_error(this) << "The mandatory 'targetcomponent' attribute is missing. " - "The component is disabled. " - "To remove this error message you need to add a targetcomponent attribute pointing to a valid component's ClassName."; - return ; - } - const string starget(target) ; - - const char* alias=arg->getAttribute("alias") ; - if(alias==nullptr) - { - msg_error(this) << "The mandatory 'alias' attribute is missing. " - "The component is disabled. " - "To remove this error message you need to add an alias attribute with a valid string component's ClassName."; - return ; - } - const string salias(alias); - - if(!ObjectFactory::getInstance()->hasCreator(starget)) - { - msg_error(this) << "The provided attribute 'targetcomponent= "<< starget << "' does not correspond to a valid component ClassName " - "The component is disabled. " - "To remove this error message you need to fix your scene and provide a valid component ClassName in the 'targetcomponent' attribute. "; - return ; - } - - ObjectFactory::getInstance()->addAlias(salias, starget); - - d_componentState.setValue(ComponentState::Valid) ; -} - -} // namespace makealiascomponent - -void registerMakeAliasComponent(sofa::core::ObjectFactory* factory) -{ - factory->registerObjects(core::ObjectRegistrationData("This object creates an alias to a component name to make the scene more readable.") - .add< MakeAliasComponent >()); -} - -} // namespace sofa::component::sceneutility diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.h b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.h deleted file mode 100644 index 96ccab239de..00000000000 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeAliasComponent.h +++ /dev/null @@ -1,73 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#pragma once - -#include - -#include -#include -#include - -#include - -namespace sofa::component::sceneutility::makealiascomponent -{ - -/// I use a per-file namespace so that I can employ the 'using' keywords without -/// fearing it will leak names into the global namespace. When closing this namespace -/// selected object from this per-file namespace are then imported into their parent namespace. -/// for ease of use -/// -/// A component to add alias to other components. -class SOFA_COMPONENT_SCENEUTILITY_API MakeAliasComponent : public core::objectmodel::BaseObject -{ -public: - SOFA_CLASS(MakeAliasComponent, core::objectmodel::BaseObject); - - MakeAliasComponent() ; - ~MakeAliasComponent() override{} - - /// Inherited from BaseObject. - /// Parse the given description to assign values to this object's fields and - /// potentially other parameters. - void parse ( core::objectmodel::BaseObjectDescription* arg ) override; - - Data d_targetcomponent ; ///< The component class for which to create an alias. - Data d_alias ; ///< The new alias of the component. - - /// Returns the sofa class name. By default the name of the c++ class is exposed... but - /// Here we want it to be MakeAlias so we need to customize it. - /// More details on the name customization infrastructure is in NameDecoder.h - static std::string GetCustomClassName() - { - return "MakeAlias" ; - } -}; - -} // namespace sofa::component::sceneutility::makealiascomponent - -namespace sofa::component::sceneutility -{ -/// Import the component from the per-file namespace. -using makealiascomponent::MakeAliasComponent ; - -} // namespace sofa::component::sceneutility diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.cpp b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.cpp deleted file mode 100644 index 3f6ee73c225..00000000000 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#include -#include -using sofa::core::ObjectFactory ; - -using sofa::core::objectmodel::ComponentState ; - -#include - -using std::string; - -namespace sofa::component::sceneutility -{ - -namespace makedataaliascomponent -{ - -MakeDataAliasComponent::MakeDataAliasComponent() - : d_componentname(initData(&d_componentname, "componentname", "The component class for which to create an alias.")) - , d_dataname(initData(&d_dataname, "dataname", "The data field for which to create an alias.")) - , d_alias(initData(&d_alias, "alias", "The alias of the data field.")) -{ - d_componentState.setValue(ComponentState::Invalid) ; -} - -MakeDataAliasComponent::~MakeDataAliasComponent() -{ - if (m_hasAddedAlias) - { - ObjectFactory::ClassEntry& creatorentry = ObjectFactory::getInstance()->getEntry(d_componentname.getValue()); - auto& aliases = creatorentry.m_dataAlias[d_dataname.getValue()]; - const auto it = std::find(aliases.begin(), aliases.end(), d_alias.getValue()); - if (it != aliases.end()) - { - aliases.erase(std::remove(aliases.begin(), aliases.end(), d_alias.getValue()), aliases.end()); - } - } -} - -void MakeDataAliasComponent::parse ( core::objectmodel::BaseObjectDescription* arg ) -{ - BaseObject::parse(arg) ; - - const char* component=arg->getAttribute("componentname") ; - if(component==nullptr) - { - msg_error(this) << "The mandatory 'componentname' attribute is missing. " - "The component is disabled. " - "To remove this error message you need to add a targetcomponent attribute pointing to a valid component's ClassName."; - return ; - } - const string scomponent(component) ; - - - const char* dataname=arg->getAttribute("dataname") ; - if(dataname==nullptr) - { - msg_error(this) << "The mandatory 'dataname' attribute is missing. " - "The component is disabled. " - "To remove this error message you need to add a targetcomponent attribute pointing to a valid component's ClassName."; - return ; - } - - const char* alias=arg->getAttribute("alias") ; - if(alias==nullptr) - { - msg_error(this) << "The mandatory 'alias' attribute is missing. " - "The component is disabled. " - "To remove this error message you need to add an alias attribute with a valid string component's ClassName."; - return ; - } - const string salias(alias); - - if(!ObjectFactory::getInstance()->hasCreator(scomponent)){ - msg_error(this) << "The value '"<< scomponent << "' for 'componentname' does not correspond to a valid name. " - "The component is disabled. " - "To remove this error message you need to add a targetcomponent attribute pointing to a valid component's ClassName."; - return ; - } - - ObjectFactory::ClassEntry& creatorentry = ObjectFactory::getInstance()->getEntry(scomponent); - auto& aliases = creatorentry.m_dataAlias[dataname]; - const auto it = std::find(aliases.begin(), aliases.end(), salias); - if (it != aliases.end()) - { - aliases.push_back(salias); - m_hasAddedAlias = true; - } - - d_componentState.setValue(ComponentState::Valid); -} -} // namespace makedataaliascomponent - -void registerMakeDataAliasComponent(sofa::core::ObjectFactory* factory) -{ - factory->registerObjects(core::ObjectRegistrationData("This object creates an alias to a data field.") - .add< MakeDataAliasComponent >()); -} - -} // namespace sofa::component::sceneutility diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.h b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.h deleted file mode 100644 index eee41a045da..00000000000 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/MakeDataAliasComponent.h +++ /dev/null @@ -1,76 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#pragma once - -#include - -#include -#include -#include - -#include - -namespace sofa::component::sceneutility::makedataaliascomponent -{ -/// I use a per-file namespace so that I can employ the 'using' keywords without -/// fearing it will leak names into the global namespace. When closing this namespace -/// selected object from this per-file namespace are then imported into their parent namespace. -/// for ease of use - -/// A component to add alias to other components. -class SOFA_COMPONENT_SCENEUTILITY_API MakeDataAliasComponent : public core::objectmodel::BaseObject -{ -public: - SOFA_CLASS(MakeDataAliasComponent, core::objectmodel::BaseObject); - - MakeDataAliasComponent() ; - ~MakeDataAliasComponent() override; - - /// Inherited from BaseObject. - /// Parse the given description to assign values to this object's fields and - /// potentially other parameters. - void parse ( core::objectmodel::BaseObjectDescription* arg ) override; - - Data d_componentname ; ///< The component class for which to create an alias. - Data d_dataname ; ///< The data field for which to create an alias. - Data d_alias ; ///< The alias of the data field. - - /// Returns the sofa class name. By default the name of the c++ class is exposed... but - /// Here we want it to be MakeAlias so we need to customize it. - /// More details on the name customization infrastructure is in NameDecoder.h - static std::string GetCustomClassName() - { - return "MakeDataAlias" ; - } -private: - - bool m_hasAddedAlias { false }; -}; - -} // namespace sofa::component::sceneutility::makedataaliascomponent - -namespace sofa::component::sceneutility -{ -/// Import the component from the per-file namespace. -using makedataaliascomponent::MakeDataAliasComponent ; - -} // namespace sofa::component::sceneutility diff --git a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/init.cpp b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/init.cpp index 1f1dead21ae..ed5d28c77b9 100644 --- a/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/init.cpp +++ b/Sofa/Component/SceneUtility/src/sofa/component/sceneutility/init.cpp @@ -31,8 +31,6 @@ extern void registerAddPluginRepository(sofa::core::ObjectFactory* factory); extern void registerAPIVersion(sofa::core::ObjectFactory* factory); extern void registerFileMessageHandlerComponent(sofa::core::ObjectFactory* factory); extern void registerInfoComponent(sofa::core::ObjectFactory* factory); -extern void registerMakeAliasComponent(sofa::core::ObjectFactory* factory); -extern void registerMakeDataAliasComponent(sofa::core::ObjectFactory* factory); extern void registerMessageHandlerComponent(sofa::core::ObjectFactory* factory); extern void registerPauseAnimationOnEvent(sofa::core::ObjectFactory* factory); @@ -64,9 +62,7 @@ void registerObjects(sofa::core::ObjectFactory* factory) registerAddPluginRepository(factory); registerAPIVersion(factory); registerFileMessageHandlerComponent(factory); - registerInfoComponent(factory);; - registerMakeAliasComponent(factory); - registerMakeDataAliasComponent(factory); + registerInfoComponent(factory); registerMessageHandlerComponent(factory); registerPauseAnimationOnEvent(factory); } diff --git a/Sofa/Component/SceneUtility/tests/CMakeLists.txt b/Sofa/Component/SceneUtility/tests/CMakeLists.txt index 00292aa674e..ac128afddb6 100644 --- a/Sofa/Component/SceneUtility/tests/CMakeLists.txt +++ b/Sofa/Component/SceneUtility/tests/CMakeLists.txt @@ -4,8 +4,6 @@ project(Sofa.Component.SceneUtility_test) set(SOURCE_FILES AddResourceRepository_test.cpp - MakeAliasComponent_test.cpp - MakeDataAliasComponent_test.cpp MessageHandlerComponent_test.cpp ) diff --git a/Sofa/Component/SceneUtility/tests/MakeAliasComponent_test.cpp b/Sofa/Component/SceneUtility/tests/MakeAliasComponent_test.cpp deleted file mode 100644 index 552ad09b95a..00000000000 --- a/Sofa/Component/SceneUtility/tests/MakeAliasComponent_test.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#include - -#include -using std::string ; - -#include -#include - -#include -using sofa::simulation::graph::DAGSimulation ; - -#include -using sofa::simulation::Simulation ; - -#include -using sofa::simulation::Node ; - -#include -using sofa::simulation::SceneLoaderXML ; - -#include -using sofa::component::sceneutility::MakeAliasComponent ; - -//TODO(dmarchal): all these lines are ugly...this is too much for simple initialization stuff. -#include -using sofa::helper::logging::MessageDispatcher; -using sofa::helper::logging::MessageHandler; -using sofa::helper::logging::ConsoleMessageHandler; -using sofa::helper::logging::Message ; - -#include -using sofa::helper::logging::RichConsoleStyleMessageFormatter ; - -using sofa::core::objectmodel::ComponentState ; - -#include - -//TODO(dmarchal): handle properly the memory cycle of the simulation objects. -// now it is soo ugly... - -namespace makealiascomponent_test -{ - -MessageHandler* defaultHandler=nullptr; -Simulation* theSimulation = nullptr ; - -bool doInit(){ - return true; -} -bool inited = doInit(); - -void perTestInit() -{ - sofa::simpleapi::importPlugin(Sofa.Component.SceneUtility); - - theSimulation = sofa::simulation::getSimulation(); - - if(defaultHandler==nullptr) - defaultHandler=new ConsoleMessageHandler(&RichConsoleStyleMessageFormatter::getInstance()) ; - - /// THE TESTS HERE ARE NOT INHERITING FROM SOFA TEST SO WE NEED TO MANUALLY INSTALL THE HANDLER - /// DO NO REMOVE - MessageDispatcher::addHandler( sofa::testing::MainGtestMessageHandler::getInstance() ); -} - - -TEST(MakeAliasComponent, checkGracefullHandlingOfMissingAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - sofa::simulation::node::unload(root); -} - -TEST(MakeAliasComponent, checkGracefullHandlingOfMissingTargetAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - sofa::simulation::node::unload(root); -} - -TEST(MakeAliasComponent, checkGracefullHandlingOfMissingAliasAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - sofa::simulation::node::unload(root); -} - -TEST(MakeAliasComponent, checkGracefullHandlingOfInvalidTargetName) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - - const string scene = - " \n" - " \n" - " \n" - " \n" ; - - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - sofa::simulation::node::unload(root); -} - -TEST(MakeAliasComponent, checkValidBehavior) -{ - EXPECT_MSG_NOEMIT(Error) ; - - const string scene = - " \n" - " \n" - " \n" - " \n" - " \n" ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeAliasComponent* component = nullptr; - root->getTreeObject(component) ; - - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Valid) ; - sofa::simulation::node::unload(root); -} - -} diff --git a/Sofa/Component/SceneUtility/tests/MakeDataAliasComponent_test.cpp b/Sofa/Component/SceneUtility/tests/MakeDataAliasComponent_test.cpp deleted file mode 100644 index 7a36ee55625..00000000000 --- a/Sofa/Component/SceneUtility/tests/MakeDataAliasComponent_test.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/****************************************************************************** -* SOFA, Simulation Open-Framework Architecture * -* (c) 2006 INRIA, USTL, UJF, CNRS, MGH * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU Lesser General Public License as published by * -* the Free Software Foundation; either version 2.1 of the License, or (at * -* your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but WITHOUT * -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * -* for more details. * -* * -* You should have received a copy of the GNU Lesser General Public License * -* along with this program. If not, see . * -******************************************************************************* -* Authors: The SOFA Team and external contributors (see Authors.txt) * -* * -* Contact information: contact@sofa-framework.org * -******************************************************************************/ -#include - -#include -using std::string ; - -#include -#include - -#include -using sofa::simulation::graph::DAGSimulation ; - -#include -using sofa::simulation::Simulation ; - -#include -using sofa::simulation::Node ; - -#include -using sofa::simulation::SceneLoaderXML ; - -#include -using sofa::component::sceneutility::MakeDataAliasComponent ; - -#include -using sofa::helper::logging::MessageDispatcher; -using sofa::helper::logging::MessageHandler; -using sofa::helper::logging::ConsoleMessageHandler; -using sofa::helper::logging::Message ; - - -using sofa::helper::logging::LogMessage ; - -#include -using sofa::helper::logging::RichConsoleStyleMessageFormatter ; - -using sofa::core::objectmodel::ComponentState ; - -#include - -namespace makedataaliascomponent_test -{ - -MessageHandler* defaultHandler=nullptr ; -Simulation* theSimulation = nullptr ; - -bool doInit(){ - return true; -} - -bool inited = doInit(); - -void perTestInit() -{ - sofa::simpleapi::importPlugin(Sofa.Component.SceneUtility); - sofa::simpleapi::importPlugin(Sofa.Component.StateContainer); - - if(defaultHandler==nullptr) - defaultHandler=new ConsoleMessageHandler(&RichConsoleStyleMessageFormatter::getInstance()) ; - - /// THE TESTS HERE ARE NOT INHERITING FROM SOFA TEST SO WE NEED TO MANUALLY INSTALL THE HANDLER - /// DO NO REMOVE - MessageDispatcher::addHandler( sofa::testing::MainGtestMessageHandler::getInstance() ); -} - -TEST(MakeDataAliasComponent, checkGracefullHandlingOfMissingAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeDataAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - - sofa::simulation::node::unload(root); -} - -TEST(MakeDataAliasComponent, checkGracefullHandlingOfMissingTargetAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeDataAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - - sofa::simulation::node::unload(root); -} - -TEST(MakeDataAliasComponent, checkGracefullHandlingOfMissingAliasAttributes) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - - const string scene = - " " - " " - " " - " " ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeDataAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - - sofa::simulation::node::unload(root); -} - -TEST(MakeDataAliasComponent, checkGracefullHandlingOfInvalidTargetName) -{ - perTestInit(); - EXPECT_MSG_EMIT(Error) ; - - const string scene = - " \n" - " \n" - " \n" - " \n" ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeDataAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Invalid) ; - - sofa::simulation::node::unload(root); -} - -TEST(MakeDataAliasComponent, checkGracefullHandlingOfInvalidDataName) -{ - perTestInit(); - EXPECT_MSG_EMIT(Warning) ; - - const string scene = - " \n" - " \n" - " \n" - " \n" - " \n" ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test1", scene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - MakeDataAliasComponent* component = nullptr; - - root->getTreeObject(component) ; - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Valid) ; - - sofa::simulation::node::unload(root); -} - -TEST(MakeDataAliasComponent, checkValidBehavior) -{ - EXPECT_MSG_NOEMIT(Error) ; - - const string ascene = - " \n" - " \n" - " \n" - " \n" - " \n" ; - - const Node::SPtr root = SceneLoaderXML::loadFromMemory("test", ascene.c_str()); - EXPECT_TRUE(root!=nullptr) ; - - MakeDataAliasComponent* component = nullptr; - root->getTreeObject(component) ; - - EXPECT_TRUE(component!=nullptr) ; - EXPECT_EQ(component->getComponentState(), ComponentState::Valid) ; - - sofa::simulation::node::unload(root); -} - -} diff --git a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp index 29d9abf57d8..12e4e6077bb 100644 --- a/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/ComponentChange.cpp @@ -127,8 +127,6 @@ const std::map > movedComponents = { // SofaBaseUtils was deprecated in #2605 { "AddResourceRepository", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) }, - { "MakeAliasComponent", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) }, - { "MakeDataAliasComponent", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) }, { "MessageHandlerComponent", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) }, { "FileMessageHandlerComponent", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) }, { "InfoComponent", Moved("v22.06", "SofaBaseUtils", Sofa.Component.SceneUtility) },