From 421a8d36d06efcd541d709f6eb55f5ff8768485b Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Tue, 3 Feb 2026 16:21:47 +0100 Subject: [PATCH 1/7] [Core] Rename BaseObject files to BaseComponent with compatibility --- Sofa/framework/Core/CMakeLists.txt | 15 +++++++++-- .../compat/sofa/core/objectmodel/BaseObject.h | 27 +++++++++++++++++++ .../{BaseObject.cpp => BaseComponent.cpp} | 0 .../{BaseObject.h => BaseComponent.h} | 0 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 Sofa/framework/Core/compat/sofa/core/objectmodel/BaseObject.h rename Sofa/framework/Core/src/sofa/core/objectmodel/{BaseObject.cpp => BaseComponent.cpp} (100%) rename Sofa/framework/Core/src/sofa/core/objectmodel/{BaseObject.h => BaseComponent.h} (100%) diff --git a/Sofa/framework/Core/CMakeLists.txt b/Sofa/framework/Core/CMakeLists.txt index 0c1c246598f..ea8d668d26b 100644 --- a/Sofa/framework/Core/CMakeLists.txt +++ b/Sofa/framework/Core/CMakeLists.txt @@ -153,11 +153,11 @@ set(HEADER_FILES ${SRC_ROOT}/objectmodel/Base.h ${SRC_ROOT}/objectmodel/BaseClass.h ${SRC_ROOT}/objectmodel/BaseClassNameHelper.h + ${SRC_ROOT}/objectmodel/BaseComponent.h ${SRC_ROOT}/objectmodel/BaseContext.h ${SRC_ROOT}/objectmodel/BaseData.h ${SRC_ROOT}/objectmodel/BaseLink.h ${SRC_ROOT}/objectmodel/BaseNode.h - ${SRC_ROOT}/objectmodel/BaseObject.h ${SRC_ROOT}/objectmodel/BaseObjectDescription.h ${SRC_ROOT}/objectmodel/ClassInfo.h ${SRC_ROOT}/objectmodel/ComponentState.h @@ -303,11 +303,11 @@ set(SOURCE_FILES ${SRC_ROOT}/objectmodel/AspectPool.cpp ${SRC_ROOT}/objectmodel/Base.cpp ${SRC_ROOT}/objectmodel/BaseClass.cpp + ${SRC_ROOT}/objectmodel/BaseComponent.cpp ${SRC_ROOT}/objectmodel/BaseContext.cpp ${SRC_ROOT}/objectmodel/BaseData.cpp ${SRC_ROOT}/objectmodel/BaseLink.cpp ${SRC_ROOT}/objectmodel/BaseNode.cpp - ${SRC_ROOT}/objectmodel/BaseObject.cpp ${SRC_ROOT}/objectmodel/BaseObjectDescription.cpp ${SRC_ROOT}/objectmodel/ClassInfo.cpp ${SRC_ROOT}/objectmodel/ComponentState.cpp @@ -355,6 +355,11 @@ set(SOURCE_FILES ${SRC_ROOT}/visual/VisualState.cpp ) +set(DEPRECATED_DIR "compat/sofa/core") +set(DEPRECATED_HEADER_FILES + ${DEPRECATED_DIR}/objectmodel/BaseObject.h +) + sofa_find_package(Sofa.Topology REQUIRED) sofa_find_package(Sofa.Helper REQUIRED) sofa_find_package(Sofa.DefaultType REQUIRED) @@ -371,6 +376,12 @@ add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Helper Sofa.Topology Sofa.DefaultType) +# For compatibility with renamed files. To remove if all files have been removed in this folder +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) + target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json) if(SOFA_BUILD_WITH_PCH_ENABLED) diff --git a/Sofa/framework/Core/compat/sofa/core/objectmodel/BaseObject.h b/Sofa/framework/Core/compat/sofa/core/objectmodel/BaseObject.h new file mode 100644 index 00000000000..0355a52ce80 --- /dev/null +++ b/Sofa/framework/Core/compat/sofa/core/objectmodel/BaseObject.h @@ -0,0 +1,27 @@ +/****************************************************************************** +* 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 + +SOFA_HEADER_DEPRECATED("v26.06", "v29.06", "sofa/core/objectmodel/BaseComponent.h") diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp similarity index 100% rename from Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.cpp rename to Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h similarity index 100% rename from Sofa/framework/Core/src/sofa/core/objectmodel/BaseObject.h rename to Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h From 3b88a178944e421d0785dc897356e4a7e88e9b86 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Feb 2026 10:49:00 +0100 Subject: [PATCH 2/7] rename BaseObject to BaseComponent with alias for deprecated usage --- Sofa/framework/Core/src/sofa/core/config.h.in | 7 ++ Sofa/framework/Core/src/sofa/core/fwd.h | 4 +- .../Core/src/sofa/core/objectmodel/Base.h | 7 +- .../src/sofa/core/objectmodel/BaseClass.h | 3 +- .../sofa/core/objectmodel/BaseComponent.cpp | 70 +++++++++---------- .../src/sofa/core/objectmodel/BaseComponent.h | 32 +++++---- .../src/sofa/core/objectmodel/BaseContext.h | 18 ++--- .../SimpleApi/src/sofa/simpleapi/SimpleApi.h | 6 +- .../sofa/simulation/PropagateEventVisitor.h | 2 +- .../Core/src/sofa/simulation/ResetVisitor.cpp | 4 +- .../Core/src/sofa/simulation/ResetVisitor.h | 4 +- .../sofa/simulation/TopologyChangeVisitor.h | 2 +- .../simulation/UpdateInternalDataVisitor.h | 2 +- .../src/sofa/simulation/UpdateLinksVisitor.h | 2 +- .../Core/src/sofa/simulation/Visitor.h | 14 ++-- .../src/sofa/simulation/XMLPrintVisitor.h | 2 +- 16 files changed, 96 insertions(+), 83 deletions(-) diff --git a/Sofa/framework/Core/src/sofa/core/config.h.in b/Sofa/framework/Core/src/sofa/core/config.h.in index 3ddb668a2a2..315be9692db 100644 --- a/Sofa/framework/Core/src/sofa/core/config.h.in +++ b/Sofa/framework/Core/src/sofa/core/config.h.in @@ -140,6 +140,13 @@ SOFA_ATTRIBUTE_DEPRECATED("v25.12", "v26.06", "Use getContactDistance or setCont SOFA_ATTRIBUTE_DEPRECATED("v25.12", "v26.12", "Use toBaseLagrangianConstraint instead.") #endif +#ifdef SOFA_BUILD_SOFA_CORE +#define SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() +#else +#define SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() \ +SOFA_ATTRIBUTE_DEPRECATED("v26.06", "v29.06", "Use toBaseComponent instead.") +#endif + #ifdef SOFA_BUILD_SOFA_CORE #define SOFA_ATTRIBUTE_DEPRECATED__REBUILDSYSTEM() #else diff --git a/Sofa/framework/Core/src/sofa/core/fwd.h b/Sofa/framework/Core/src/sofa/core/fwd.h index a9ab6b73c8d..1363e64495c 100644 --- a/Sofa/framework/Core/src/sofa/core/fwd.h +++ b/Sofa/framework/Core/src/sofa/core/fwd.h @@ -72,7 +72,7 @@ SOFA_CORE_API SReal dt(const sofa::core::MechanicalParams*); namespace sofa::core::objectmodel { class Base; -class BaseObject; +class BaseComponent; class BaseNode; class BaseContext; class BaseData; @@ -263,7 +263,7 @@ SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::BaseMapping); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::BehaviorModel); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::CollisionModel); -SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::objectmodel::BaseObject); +SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::objectmodel::BaseComponent); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::objectmodel::ContextObject); SOFA_DECLARE_OPAQUE_FUNCTION_BETWEEN_BASE_AND(sofa::core::objectmodel::ConfigurationSetting); diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h index 597c97148ac..adcc0bdeefa 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/Base.h @@ -410,7 +410,7 @@ class SOFA_CORE_API Base : public IntrusiveObject SOFA_BASE_CAST_DEFINITION( core, CollisionModel ) SOFA_BASE_CAST_DEFINITION( core, DataEngine ) SOFA_BASE_CAST_DEFINITION( objectmodel, BaseContext ) - SOFA_BASE_CAST_DEFINITION( objectmodel, BaseObject ) + SOFA_BASE_CAST_DEFINITION( objectmodel, BaseComponent ) SOFA_BASE_CAST_DEFINITION( objectmodel, BaseNode ) SOFA_BASE_CAST_DEFINITION( objectmodel, ContextObject ) SOFA_BASE_CAST_DEFINITION( objectmodel, ConfigurationSetting ) @@ -444,9 +444,12 @@ class SOFA_CORE_API Base : public IntrusiveObject #undef SOFA_BASE_CAST_DEFINITION - SOFA_ATTRIBUTE_DEPRECATED__TOBASECONSTRAINT() virtual const behavior::BaseLagrangianConstraint* toBaseConstraint() const { return toBaseLagrangianConstraint(); } \ + SOFA_ATTRIBUTE_DEPRECATED__TOBASECONSTRAINT() virtual const behavior::BaseLagrangianConstraint* toBaseConstraint() const { return toBaseLagrangianConstraint(); } SOFA_ATTRIBUTE_DEPRECATED__TOBASECONSTRAINT() virtual behavior::BaseLagrangianConstraint* toBaseConstraint() { return toBaseLagrangianConstraint(); } + SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() virtual const objectmodel::BaseComponent* toBaseObject() const { return toBaseComponent(); } + SOFA_ATTRIBUTE_DEPRECATED__TOBASEOBJECT() virtual objectmodel::BaseComponent* toBaseObject() { return toBaseComponent(); } + /// @} }; diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.h index b81f839b1a5..453e03e3044 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.h @@ -247,7 +247,8 @@ class SOFA_CORE_API DeprecatedBaseClass : public BaseClass { \ return ::sofa::core::objectmodel::BaseLink::InitLink \ (this, n, help); \ -} +}\ + using BaseObject SOFA_ATTRIBUTE_DEPRECATED("v26.06", "v29.06", "BaseObject has been renamed to BaseComponent") = sofa::core::objectmodel::BaseComponent; // this alias allows the transition from BaseObject to BaseComponent. // Do not use this macro directly, use SOFA_CLASS instead #define SOFA_CLASS_DECL \ diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp index 38f0555076e..827aa9659bb 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.cpp @@ -19,7 +19,7 @@ * * * Contact information: contact@sofa-framework.org * ******************************************************************************/ -#include +#include #include #include #include @@ -32,7 +32,7 @@ namespace sofa::core::objectmodel { -BaseObject::BaseObject() +BaseComponent::BaseComponent() : Base() , f_listening(initData( &f_listening, false, "listening", "if true, handle the events, otherwise ignore the events")) , l_context(initLink("context","Graph Node containing this object (or BaseContext::getDefault() if no graph is used)")) @@ -48,7 +48,7 @@ BaseObject::BaseObject() f_listening.setAutoLink(false); } -BaseObject::~BaseObject() +BaseComponent::~BaseComponent() { assert(l_master.get() == nullptr); // an object that is still a slave should not be able to be deleted, as at least one smart pointer points to it for(auto& slave : l_slaves) @@ -62,7 +62,7 @@ BaseObject::~BaseObject() // This method insures that context is never nullptr (using BaseContext::getDefault() instead) // and that all slaves of an object share its context -void BaseObject::changeContextLink(BaseContext* before, BaseContext*& after) +void BaseComponent::changeContextLink(BaseContext* before, BaseContext*& after) { if (!after) after = BaseContext::getDefault(); if (before == after) return; @@ -81,14 +81,14 @@ void BaseObject::changeContextLink(BaseContext* before, BaseContext*& after) } /// This method insures that slaves objects have master and context links set correctly -void BaseObject::changeSlavesLink(BaseObject::SPtr ptr, std::size_t /*index*/, bool add) +void BaseComponent::changeSlavesLink(BaseComponent::SPtr ptr, std::size_t /*index*/, bool add) { if (!ptr) return; if (add) { ptr->l_master.set(this); ptr->l_context.set(getContext()); } else { ptr->l_master.reset(); ptr->l_context.reset(); } } -void BaseObject::parse( BaseObjectDescription* arg ) +void BaseComponent::parse( BaseObjectDescription* arg ) { if (arg->getAttribute("src")) { @@ -117,13 +117,13 @@ void BaseObject::parse( BaseObjectDescription* arg ) Base::parse(arg); } -void BaseObject::setSrc(const std::string &valueString, std::vector< std::string > *attributeList) +void BaseComponent::setSrc(const std::string &valueString, std::vector< std::string > *attributeList) { std::size_t posAt = valueString.rfind('@'); if (posAt == std::string::npos) posAt = 0; const std::string objectName = valueString.substr(posAt + 1); - const BaseObject* loader = getContext()->get(objectName); + const BaseComponent* loader = getContext()->get(objectName); if (!loader) { msg_error() << "Source object \"" << valueString << "\" NOT FOUND."; @@ -132,9 +132,9 @@ void BaseObject::setSrc(const std::string &valueString, std::vector< std::string setSrc(valueString, loader, attributeList); } -void BaseObject::setSrc(const std::string &valueString, const BaseObject *loader, std::vector< std::string > *attributeList) +void BaseComponent::setSrc(const std::string &valueString, const BaseComponent *loader, std::vector< std::string > *attributeList) { - BaseObject::MapData dataLoaderMap = loader->m_aliasData; + BaseComponent::MapData dataLoaderMap = loader->m_aliasData; if (attributeList != nullptr) { @@ -175,7 +175,7 @@ void BaseObject::setSrc(const std::string &valueString, const BaseObject *loader } } -Base* BaseObject::findLinkDestClass(const BaseClass* destType, const std::string& path, const BaseLink* link) +Base* BaseComponent::findLinkDestClass(const BaseClass* destType, const std::string& path, const BaseLink* link) { if (this->getContext() == BaseContext::getDefault()) return nullptr; @@ -184,32 +184,32 @@ Base* BaseObject::findLinkDestClass(const BaseClass* destType, const std::string } -const BaseContext* BaseObject::getContext() const +const BaseContext* BaseComponent::getContext() const { return l_context.get(); } -BaseContext* BaseObject::getContext() +BaseContext* BaseComponent::getContext() { return l_context.get(); } -const BaseObject* BaseObject::getMaster() const +const BaseComponent* BaseComponent::getMaster() const { return l_master.get(); } -BaseObject* BaseObject::getMaster() +BaseComponent* BaseComponent::getMaster() { return l_master.get(); } -const BaseObject::VecSlaves& BaseObject::getSlaves() const +const BaseComponent::VecSlaves& BaseComponent::getSlaves() const { return l_slaves.getValue(); } -BaseObject* BaseObject::getSlave(const std::string& name) const +BaseComponent* BaseComponent::getSlave(const std::string& name) const { for (auto slave : l_slaves) { @@ -219,9 +219,9 @@ BaseObject* BaseObject::getSlave(const std::string& name) const return nullptr; } -void BaseObject::addSlave(BaseObject::SPtr s) +void BaseComponent::addSlave(BaseComponent::SPtr s) { - const BaseObject::SPtr previous = s->getMaster(); + const BaseComponent::SPtr previous = s->getMaster(); if (previous == this) return; if (previous) previous->l_slaves.remove(s); @@ -232,7 +232,7 @@ void BaseObject::addSlave(BaseObject::SPtr s) this->getContext()->notifyAddSlave(this, s.get()); } -void BaseObject::removeSlave(BaseObject::SPtr s) +void BaseComponent::removeSlave(BaseComponent::SPtr s) { if (l_slaves.remove(s)) { @@ -240,7 +240,7 @@ void BaseObject::removeSlave(BaseObject::SPtr s) } } -void BaseObject::init() +void BaseComponent::init() { for(const auto data: this->m_vecData) { @@ -258,15 +258,15 @@ void BaseObject::init() } } -void BaseObject::bwdInit() +void BaseComponent::bwdInit() { } -void BaseObject::reinit() +void BaseComponent::reinit() { } -void BaseObject::updateInternal() +void BaseComponent::updateInternal() { const auto& mapTrackedData = m_internalDataTracker.getMapTrackedData(); for( auto const& it : mapTrackedData ) @@ -281,17 +281,17 @@ void BaseObject::updateInternal() } } -void BaseObject::trackInternalData(const objectmodel::BaseData& data) +void BaseComponent::trackInternalData(const objectmodel::BaseData& data) { m_internalDataTracker.trackData(data); } -void BaseObject::cleanTracker() +void BaseComponent::cleanTracker() { m_internalDataTracker.clean(); } -bool BaseObject::hasDataChanged(const objectmodel::BaseData& data) +bool BaseComponent::hasDataChanged(const objectmodel::BaseData& data) { bool dataFoundinTracker = false; const auto& mapTrackedData = m_internalDataTracker.getMapTrackedData(); @@ -314,16 +314,16 @@ bool BaseObject::hasDataChanged(const objectmodel::BaseData& data) return m_internalDataTracker.hasChanged(data); } -void BaseObject::doUpdateInternal() +void BaseComponent::doUpdateInternal() { } -void BaseObject::storeResetState() +void BaseComponent::storeResetState() { } -void BaseObject::reset() +void BaseComponent::reset() { } -void BaseObject::cleanup() +void BaseComponent::cleanup() { while (!l_slaves.empty()) { @@ -331,10 +331,10 @@ void BaseObject::cleanup() } } -void BaseObject::handleEvent( Event* /*e*/ ) +void BaseComponent::handleEvent( Event* /*e*/ ) { } -void BaseObject::handleTopologyChange(core::topology::Topology* t) +void BaseComponent::handleTopologyChange(core::topology::Topology* t) { if (t == this->getContext()->getTopology()) { @@ -342,12 +342,12 @@ void BaseObject::handleTopologyChange(core::topology::Topology* t) } } -SReal BaseObject::getTime() const +SReal BaseComponent::getTime() const { return getContext()->getTime(); } -std::string BaseObject::getPathName() const +std::string BaseComponent::getPathName() const { auto node = dynamic_cast(getContext()); if(!node) diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h index 8b149518b14..cf12eb0ae67 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h @@ -37,16 +37,16 @@ namespace sofa::core::objectmodel * It is able to process events, if listening enabled (default is false). * */ -class SOFA_CORE_API BaseObject : public virtual Base +class SOFA_CORE_API BaseComponent : public virtual Base { public: - SOFA_CLASS(BaseObject, Base); - SOFA_BASE_CAST_IMPLEMENTATION(BaseObject) + SOFA_CLASS(BaseComponent, Base); + SOFA_BASE_CAST_IMPLEMENTATION(BaseComponent) protected: - BaseObject(); + BaseComponent(); - ~BaseObject() override; + ~BaseComponent() override; public: @@ -126,21 +126,21 @@ class SOFA_CORE_API BaseObject : public virtual Base BaseContext* getContext(); - const BaseObject* getMaster() const; + const BaseComponent* getMaster() const; - BaseObject* getMaster(); + BaseComponent* getMaster(); - typedef sofa::core::objectmodel::MultiLink LinkSlaves; + typedef sofa::core::objectmodel::MultiLink LinkSlaves; typedef LinkSlaves::Container VecSlaves; const VecSlaves& getSlaves() const; - BaseObject* getSlave(const std::string& name) const; + BaseComponent* getSlave(const std::string& name) const; - virtual void addSlave(BaseObject::SPtr s); + virtual void addSlave(BaseComponent::SPtr s); - virtual void removeSlave(BaseObject::SPtr s); + virtual void removeSlave(BaseComponent::SPtr s); /// @} /// @name data access @@ -180,7 +180,7 @@ class SOFA_CORE_API BaseObject : public virtual Base /// Sets a source Object and parses it to collect dependent Data /// Use it before scene graph insertion - void setSrc(const std::string &v, const BaseObject *loader, std::vector< std::string > *attributeList=nullptr); + void setSrc(const std::string &v, const BaseComponent *loader, std::vector< std::string > *attributeList=nullptr); Base* findLinkDestClass(const BaseClass* destType, const std::string& path, const BaseLink* link) override; @@ -205,9 +205,9 @@ class SOFA_CORE_API BaseObject : public virtual Base ///@} /// - SingleLink l_context; + SingleLink l_context; LinkSlaves l_slaves; - SingleLink l_master; + SingleLink l_master; /// Implementation of the internal update virtual void doUpdateInternal(); @@ -217,7 +217,7 @@ class SOFA_CORE_API BaseObject : public virtual Base void changeContextLink(BaseContext* before, BaseContext*& after); /// This method insures that slaves objects have master and context links set correctly - void changeSlavesLink(BaseObject::SPtr ptr, std::size_t /*index*/, bool add); + void changeSlavesLink(BaseComponent::SPtr ptr, std::size_t /*index*/, bool add); /// BaseNode can set the context of its own objects friend class BaseNode; @@ -236,5 +236,7 @@ class SOFA_CORE_API BaseObject : public virtual Base virtual bool removeInNode( BaseNode* /*node*/ ) { return false; } }; +using BaseObject = BaseComponent; + } // namespace sofa::core::objectmodel diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h index e0ae2ddc670..e1125f5a4e1 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h @@ -188,9 +188,9 @@ class SOFA_CORE_API BaseContext : public virtual Base /// Returns a list of object of type passed as a parameter. There should be no /// Copy constructor because of Return Value Optimization. /// eg: - /// for(BaseObject* o : context->getObjects() ){ ... } + /// for(BaseComponent* o : context->getObjects() ){ ... } /// for(VisualModel* o : context->getObjects() ){ ... } - template + template std::vector getObjects(SearchDirection dir = SearchUp){ std::vector o; getObjects(o, dir) ; @@ -338,11 +338,11 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @{ /// Mechanical Degrees-of-Freedom - virtual void setMechanicalState( BaseObject* ) + virtual void setMechanicalState( BaseComponent* ) { } /// Topology - virtual void setTopology( BaseObject* ) + virtual void setTopology( BaseComponent* ) { } /// @} @@ -362,13 +362,13 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @{ /// Add an object, or return false if not supported - virtual bool addObject( sptr /*obj*/, TypeOfInsertion = TypeOfInsertion::AtEnd) + virtual bool addObject( sptr /*obj*/, TypeOfInsertion = TypeOfInsertion::AtEnd) { return false; } /// Remove an object, or return false if not supported - virtual bool removeObject( sptr /*obj*/ ) + virtual bool removeObject( sptr /*obj*/ ) { return false; } @@ -393,9 +393,9 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @name Notifications for graph change listeners /// @{ - virtual void notifyAddSlave(core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); - virtual void notifyRemoveSlave(core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); - virtual void notifyMoveSlave(core::objectmodel::BaseObject* previousMaster, core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); + virtual void notifyAddSlave(core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); + virtual void notifyRemoveSlave(core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); + virtual void notifyMoveSlave(core::objectmodel::BaseComponent* previousMaster, core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); /// @} diff --git a/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h b/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h index f5cc9c1d3e5..184d16253e8 100644 --- a/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h +++ b/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h @@ -33,7 +33,7 @@ namespace sofa::simpleapi { -using BaseObject [[deprecated("Use sofa::core::objectmodel::BaseObject instead.")]] = sofa::core::objectmodel::BaseObject; +using BaseObject [[deprecated("Use sofa::core::objectmodel::BaseComponent instead.")]] = sofa::core::objectmodel::BaseComponent; using sofa::core::objectmodel::BaseObjectDescription; using sofa::simulation::Simulation ; @@ -53,11 +53,11 @@ NodeSPtr SOFA_SIMPLEAPI_API createRootNode( Simulation* s, const std::string& na ///@brief Create a sofa object in the provided node. ///The parameter "params" is for passing specific data argument to the created object including the ///object's type. -sofa::core::sptr SOFA_SIMPLEAPI_API createObject(NodeSPtr node, BaseObjectDescription& params); +sofa::core::sptr SOFA_SIMPLEAPI_API createObject(NodeSPtr node, BaseObjectDescription& params); ///@brief create a sofa object in the provided node of the given type. ///The parameter "params" is for passing specific data argument to the created object. -sofa::core::sptr SOFA_SIMPLEAPI_API createObject( NodeSPtr node, const std::string& type, +sofa::core::sptr SOFA_SIMPLEAPI_API createObject( NodeSPtr node, const std::string& type, const std::map& params = std::map{} ); ///@brief create a child to the provided nodeof given name. diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h index 7ae5a9752a2..1dd246499c0 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h @@ -43,7 +43,7 @@ class SOFA_SIMULATION_CORE_API PropagateEventVisitor : public sofa::simulation:: ~PropagateEventVisitor() override; Visitor::Result processNodeTopDown(simulation::Node* node) override; - void processObject(simulation::Node*, core::objectmodel::BaseObject* obj); + void processObject(simulation::Node*, core::objectmodel::BaseComponent* obj); const char* getClassName() const override { return "PropagateEventVisitor"; } virtual std::string getInfos() const override { return std::string(m_event->getClassName()); } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp index 3fa466d3a18..c2fc1e10f80 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp @@ -27,7 +27,7 @@ namespace sofa::simulation { -void ResetVisitor::processObject(core::objectmodel::BaseObject* obj) +void ResetVisitor::processObject(core::objectmodel::BaseComponent* obj) { obj->reset(); } @@ -46,7 +46,7 @@ void ResetVisitor::processNodeBottomUp(simulation::Node* /*node*/) { } -void StoreResetStateVisitor::processObject(core::objectmodel::BaseObject* obj) +void StoreResetStateVisitor::processObject(core::objectmodel::BaseComponent* obj) { obj->storeResetState(); } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h index 05389a2df9a..71d603453ea 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h @@ -33,7 +33,7 @@ class SOFA_SIMULATION_CORE_API ResetVisitor : public Visitor public: ResetVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseObject* obj); + void processObject(core::objectmodel::BaseComponent* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; @@ -48,7 +48,7 @@ class SOFA_SIMULATION_CORE_API StoreResetStateVisitor : public Visitor public: StoreResetStateVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseObject* obj); + void processObject(core::objectmodel::BaseComponent* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h index 9be70787b0f..1164943ca10 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h @@ -36,7 +36,7 @@ class SOFA_SIMULATION_CORE_API TopologyChangeVisitor : public Visitor ~TopologyChangeVisitor() override {} - virtual void processTopologyChange(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); + virtual void processTopologyChange(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h index a4cec8d167c..6f61afb087f 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h @@ -39,7 +39,7 @@ class SOFA_SIMULATION_CORE_API UpdateInternalDataVisitor : public Visitor public: UpdateInternalDataVisitor(const core::ExecParams* eparams): Visitor(eparams) {} - void processUpdateInternalData(simulation::Node* node, sofa::core::objectmodel::BaseObject* baseObj); + void processUpdateInternalData(simulation::Node* node, sofa::core::objectmodel::BaseComponent* baseObj); Result processNodeTopDown(simulation::Node* node) override; /// Specify whether this action can be parallelized. diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h index cdd9a3d1e71..03a4573a9d1 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h @@ -33,7 +33,7 @@ class SOFA_SIMULATION_CORE_API UpdateLinksVisitor : public Visitor public: UpdateLinksVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseObject* obj); + void processObject(core::objectmodel::BaseComponent* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h index f24d6173b09..b78c2169986 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h @@ -91,8 +91,8 @@ class SOFA_SIMULATION_CORE_API Visitor virtual std::string getInfos() const { return ""; } protected: - void debug_write_state_before( sofa::core::objectmodel::BaseObject* obj ) ; - void debug_write_state_after( sofa::core::objectmodel::BaseObject* obj ) ; + void debug_write_state_before( sofa::core::objectmodel::BaseComponent* obj ) ; + void debug_write_state_after( sofa::core::objectmodel::BaseComponent* obj ) ; /// Function to be called when a visitor executes a main task /// It surrounds the task function with debug information @@ -131,28 +131,28 @@ class SOFA_SIMULATION_CORE_API Visitor //method to compare the tags of the object with the ones of the visitor // return true if the object has all the tags of the visitor // or if no tag is set to the visitor - bool testTags(sofa::core::objectmodel::BaseObject* obj); + bool testTags(sofa::core::objectmodel::BaseComponent* obj); /// Alias for context->executeVisitor(this) virtual void execute(sofa::core::objectmodel::BaseContext* node, bool precomputedOrder=false); /// Optional helper method to call before handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual ctime_t begin(simulation::Node *node, sofa::core::objectmodel::BaseObject *obj, + virtual ctime_t begin(simulation::Node *node, sofa::core::objectmodel::BaseComponent *obj, const std::string &typeInfo = std::string("type")); /// Optional helper method to call after handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual void end(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0); + virtual void end(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0); /// Optional helper method to call before handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual ctime_t begin(simulation::Visitor::VisitorContext *node, sofa::core::objectmodel::BaseObject *obj, + virtual ctime_t begin(simulation::Visitor::VisitorContext *node, sofa::core::objectmodel::BaseComponent *obj, const std::string &typeInfo = std::string("type")); /// Optional helper method to call after handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual void end(simulation::Visitor::VisitorContext* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0); + virtual void end(simulation::Visitor::VisitorContext* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0); /// Specify whether this visitor can be parallelized. virtual bool isThreadSafe() const { return false; } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h index 2e13904f9e4..24097fbb38e 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h @@ -45,7 +45,7 @@ class SOFA_SIMULATION_CORE_API XMLPrintVisitor : public Visitor template void processObjects(Seq& list); - void processBaseObject(sofa::core::objectmodel::BaseObject* obj); + void processBaseObject(sofa::core::objectmodel::BaseComponent* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; From 84120cc4dcfd9eb4fbd24227aaa3d131f95a6ced Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Feb 2026 14:14:11 +0100 Subject: [PATCH 3/7] rename symbol depending on SOFA_DUMP_VISITOR_INFO --- .../Core/src/sofa/simulation/BaseMechanicalVisitor.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h index ee1fc92a26f..d743edb6dbe 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h @@ -204,17 +204,17 @@ class SOFA_SIMULATION_CORE_API BaseMechanicalVisitor : public Visitor virtual bool stopAtMechanicalMapping(simulation::Node* /*node*/, sofa::core::BaseMapping* map); #ifdef SOFA_DUMP_VISITOR_INFO - ctime_t begin(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, const std::string &info=std::string("type")) override; - void end(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0) override; + ctime_t begin(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, const std::string &info=std::string("type")) override; + void end(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0) override; virtual void setReadWriteVectors() {} virtual void addReadVector(core::ConstMultiVecId id) { readVector.push_back(id); } virtual void addWriteVector(core::MultiVecId id) { writeVector.push_back(id); } virtual void addReadWriteVector(core::MultiVecId id) { readVector.push_back(core::ConstMultiVecId(id)); writeVector.push_back(id); } void printReadVectors(core::behavior::BaseMechanicalState* mm); - void printReadVectors(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); + void printReadVectors(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); void printWriteVectors(core::behavior::BaseMechanicalState* mm); - void printWriteVectors(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); + void printWriteVectors(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); protected: sofa::type::vector< sofa::core::ConstMultiVecId > readVector; sofa::type::vector< sofa::core::MultiVecId > writeVector; From 184d67cfce03ba22f6e3d2b20f344af1c7e132cd Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Feb 2026 16:18:28 +0100 Subject: [PATCH 4/7] revert renaming in visitors and SimpleApi --- .../SimpleApi/src/sofa/simpleapi/SimpleApi.h | 6 +++--- .../src/sofa/simulation/BaseMechanicalVisitor.h | 8 ++++---- .../src/sofa/simulation/PropagateEventVisitor.h | 2 +- .../Core/src/sofa/simulation/ResetVisitor.cpp | 4 ++-- .../Core/src/sofa/simulation/ResetVisitor.h | 4 ++-- .../src/sofa/simulation/TopologyChangeVisitor.h | 2 +- .../sofa/simulation/UpdateInternalDataVisitor.h | 2 +- .../Core/src/sofa/simulation/UpdateLinksVisitor.h | 2 +- .../Simulation/Core/src/sofa/simulation/Visitor.h | 14 +++++++------- .../Core/src/sofa/simulation/XMLPrintVisitor.h | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h b/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h index 184d16253e8..f5cc9c1d3e5 100644 --- a/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h +++ b/Sofa/framework/SimpleApi/src/sofa/simpleapi/SimpleApi.h @@ -33,7 +33,7 @@ namespace sofa::simpleapi { -using BaseObject [[deprecated("Use sofa::core::objectmodel::BaseComponent instead.")]] = sofa::core::objectmodel::BaseComponent; +using BaseObject [[deprecated("Use sofa::core::objectmodel::BaseObject instead.")]] = sofa::core::objectmodel::BaseObject; using sofa::core::objectmodel::BaseObjectDescription; using sofa::simulation::Simulation ; @@ -53,11 +53,11 @@ NodeSPtr SOFA_SIMPLEAPI_API createRootNode( Simulation* s, const std::string& na ///@brief Create a sofa object in the provided node. ///The parameter "params" is for passing specific data argument to the created object including the ///object's type. -sofa::core::sptr SOFA_SIMPLEAPI_API createObject(NodeSPtr node, BaseObjectDescription& params); +sofa::core::sptr SOFA_SIMPLEAPI_API createObject(NodeSPtr node, BaseObjectDescription& params); ///@brief create a sofa object in the provided node of the given type. ///The parameter "params" is for passing specific data argument to the created object. -sofa::core::sptr SOFA_SIMPLEAPI_API createObject( NodeSPtr node, const std::string& type, +sofa::core::sptr SOFA_SIMPLEAPI_API createObject( NodeSPtr node, const std::string& type, const std::map& params = std::map{} ); ///@brief create a child to the provided nodeof given name. diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h index d743edb6dbe..ee1fc92a26f 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/BaseMechanicalVisitor.h @@ -204,17 +204,17 @@ class SOFA_SIMULATION_CORE_API BaseMechanicalVisitor : public Visitor virtual bool stopAtMechanicalMapping(simulation::Node* /*node*/, sofa::core::BaseMapping* map); #ifdef SOFA_DUMP_VISITOR_INFO - ctime_t begin(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, const std::string &info=std::string("type")) override; - void end(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0) override; + ctime_t begin(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, const std::string &info=std::string("type")) override; + void end(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0) override; virtual void setReadWriteVectors() {} virtual void addReadVector(core::ConstMultiVecId id) { readVector.push_back(id); } virtual void addWriteVector(core::MultiVecId id) { writeVector.push_back(id); } virtual void addReadWriteVector(core::MultiVecId id) { readVector.push_back(core::ConstMultiVecId(id)); writeVector.push_back(id); } void printReadVectors(core::behavior::BaseMechanicalState* mm); - void printReadVectors(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); + void printReadVectors(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); void printWriteVectors(core::behavior::BaseMechanicalState* mm); - void printWriteVectors(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); + void printWriteVectors(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); protected: sofa::type::vector< sofa::core::ConstMultiVecId > readVector; sofa::type::vector< sofa::core::MultiVecId > writeVector; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h index 1dd246499c0..7ae5a9752a2 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/PropagateEventVisitor.h @@ -43,7 +43,7 @@ class SOFA_SIMULATION_CORE_API PropagateEventVisitor : public sofa::simulation:: ~PropagateEventVisitor() override; Visitor::Result processNodeTopDown(simulation::Node* node) override; - void processObject(simulation::Node*, core::objectmodel::BaseComponent* obj); + void processObject(simulation::Node*, core::objectmodel::BaseObject* obj); const char* getClassName() const override { return "PropagateEventVisitor"; } virtual std::string getInfos() const override { return std::string(m_event->getClassName()); } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp index c2fc1e10f80..3fa466d3a18 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.cpp @@ -27,7 +27,7 @@ namespace sofa::simulation { -void ResetVisitor::processObject(core::objectmodel::BaseComponent* obj) +void ResetVisitor::processObject(core::objectmodel::BaseObject* obj) { obj->reset(); } @@ -46,7 +46,7 @@ void ResetVisitor::processNodeBottomUp(simulation::Node* /*node*/) { } -void StoreResetStateVisitor::processObject(core::objectmodel::BaseComponent* obj) +void StoreResetStateVisitor::processObject(core::objectmodel::BaseObject* obj) { obj->storeResetState(); } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h index 71d603453ea..05389a2df9a 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/ResetVisitor.h @@ -33,7 +33,7 @@ class SOFA_SIMULATION_CORE_API ResetVisitor : public Visitor public: ResetVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseComponent* obj); + void processObject(core::objectmodel::BaseObject* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; @@ -48,7 +48,7 @@ class SOFA_SIMULATION_CORE_API StoreResetStateVisitor : public Visitor public: StoreResetStateVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseComponent* obj); + void processObject(core::objectmodel::BaseObject* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h index 1164943ca10..9be70787b0f 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/TopologyChangeVisitor.h @@ -36,7 +36,7 @@ class SOFA_SIMULATION_CORE_API TopologyChangeVisitor : public Visitor ~TopologyChangeVisitor() override {} - virtual void processTopologyChange(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj); + virtual void processTopologyChange(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h index 6f61afb087f..a4cec8d167c 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateInternalDataVisitor.h @@ -39,7 +39,7 @@ class SOFA_SIMULATION_CORE_API UpdateInternalDataVisitor : public Visitor public: UpdateInternalDataVisitor(const core::ExecParams* eparams): Visitor(eparams) {} - void processUpdateInternalData(simulation::Node* node, sofa::core::objectmodel::BaseComponent* baseObj); + void processUpdateInternalData(simulation::Node* node, sofa::core::objectmodel::BaseObject* baseObj); Result processNodeTopDown(simulation::Node* node) override; /// Specify whether this action can be parallelized. diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h index 03a4573a9d1..cdd9a3d1e71 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/UpdateLinksVisitor.h @@ -33,7 +33,7 @@ class SOFA_SIMULATION_CORE_API UpdateLinksVisitor : public Visitor public: UpdateLinksVisitor(const core::ExecParams* eparams) : Visitor(eparams) {} - void processObject(core::objectmodel::BaseComponent* obj); + void processObject(core::objectmodel::BaseObject* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h index b78c2169986..f24d6173b09 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/Visitor.h @@ -91,8 +91,8 @@ class SOFA_SIMULATION_CORE_API Visitor virtual std::string getInfos() const { return ""; } protected: - void debug_write_state_before( sofa::core::objectmodel::BaseComponent* obj ) ; - void debug_write_state_after( sofa::core::objectmodel::BaseComponent* obj ) ; + void debug_write_state_before( sofa::core::objectmodel::BaseObject* obj ) ; + void debug_write_state_after( sofa::core::objectmodel::BaseObject* obj ) ; /// Function to be called when a visitor executes a main task /// It surrounds the task function with debug information @@ -131,28 +131,28 @@ class SOFA_SIMULATION_CORE_API Visitor //method to compare the tags of the object with the ones of the visitor // return true if the object has all the tags of the visitor // or if no tag is set to the visitor - bool testTags(sofa::core::objectmodel::BaseComponent* obj); + bool testTags(sofa::core::objectmodel::BaseObject* obj); /// Alias for context->executeVisitor(this) virtual void execute(sofa::core::objectmodel::BaseContext* node, bool precomputedOrder=false); /// Optional helper method to call before handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual ctime_t begin(simulation::Node *node, sofa::core::objectmodel::BaseComponent *obj, + virtual ctime_t begin(simulation::Node *node, sofa::core::objectmodel::BaseObject *obj, const std::string &typeInfo = std::string("type")); /// Optional helper method to call after handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual void end(simulation::Node* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0); + virtual void end(simulation::Node* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0); /// Optional helper method to call before handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual ctime_t begin(simulation::Visitor::VisitorContext *node, sofa::core::objectmodel::BaseComponent *obj, + virtual ctime_t begin(simulation::Visitor::VisitorContext *node, sofa::core::objectmodel::BaseObject *obj, const std::string &typeInfo = std::string("type")); /// Optional helper method to call after handling an object if not using the for_each method. /// It currently takes care of time logging, but could be extended (step-by-step execution for instance) - virtual void end(simulation::Visitor::VisitorContext* node, sofa::core::objectmodel::BaseComponent* obj, ctime_t t0); + virtual void end(simulation::Visitor::VisitorContext* node, sofa::core::objectmodel::BaseObject* obj, ctime_t t0); /// Specify whether this visitor can be parallelized. virtual bool isThreadSafe() const { return false; } diff --git a/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h b/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h index 24097fbb38e..2e13904f9e4 100644 --- a/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h +++ b/Sofa/framework/Simulation/Core/src/sofa/simulation/XMLPrintVisitor.h @@ -45,7 +45,7 @@ class SOFA_SIMULATION_CORE_API XMLPrintVisitor : public Visitor template void processObjects(Seq& list); - void processBaseObject(sofa::core::objectmodel::BaseComponent* obj); + void processBaseObject(sofa::core::objectmodel::BaseObject* obj); Result processNodeTopDown(simulation::Node* node) override; void processNodeBottomUp(simulation::Node* node) override; From 8cd8e1e577aa35eb346d41c7a79f41b3d56efe11 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Feb 2026 16:28:20 +0100 Subject: [PATCH 5/7] the alias is now declared in fwd.h --- Sofa/framework/Core/src/sofa/core/fwd.h | 1 + Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Sofa/framework/Core/src/sofa/core/fwd.h b/Sofa/framework/Core/src/sofa/core/fwd.h index 1363e64495c..07ce7568506 100644 --- a/Sofa/framework/Core/src/sofa/core/fwd.h +++ b/Sofa/framework/Core/src/sofa/core/fwd.h @@ -73,6 +73,7 @@ namespace sofa::core::objectmodel { class Base; class BaseComponent; +using BaseObject = BaseComponent; class BaseNode; class BaseContext; class BaseData; diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h index cf12eb0ae67..667f91a6e39 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseComponent.h @@ -236,7 +236,5 @@ class SOFA_CORE_API BaseComponent : public virtual Base virtual bool removeInNode( BaseNode* /*node*/ ) { return false; } }; -using BaseObject = BaseComponent; - } // namespace sofa::core::objectmodel From 7fa1b37fb404eea38297398cbf1cb8e96326cfa6 Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Wed, 4 Feb 2026 16:33:40 +0100 Subject: [PATCH 6/7] revert changes on BaseContext --- .../src/sofa/core/objectmodel/BaseContext.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h index e1125f5a4e1..e0ae2ddc670 100644 --- a/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h +++ b/Sofa/framework/Core/src/sofa/core/objectmodel/BaseContext.h @@ -188,9 +188,9 @@ class SOFA_CORE_API BaseContext : public virtual Base /// Returns a list of object of type passed as a parameter. There should be no /// Copy constructor because of Return Value Optimization. /// eg: - /// for(BaseComponent* o : context->getObjects() ){ ... } + /// for(BaseObject* o : context->getObjects() ){ ... } /// for(VisualModel* o : context->getObjects() ){ ... } - template + template std::vector getObjects(SearchDirection dir = SearchUp){ std::vector o; getObjects(o, dir) ; @@ -338,11 +338,11 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @{ /// Mechanical Degrees-of-Freedom - virtual void setMechanicalState( BaseComponent* ) + virtual void setMechanicalState( BaseObject* ) { } /// Topology - virtual void setTopology( BaseComponent* ) + virtual void setTopology( BaseObject* ) { } /// @} @@ -362,13 +362,13 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @{ /// Add an object, or return false if not supported - virtual bool addObject( sptr /*obj*/, TypeOfInsertion = TypeOfInsertion::AtEnd) + virtual bool addObject( sptr /*obj*/, TypeOfInsertion = TypeOfInsertion::AtEnd) { return false; } /// Remove an object, or return false if not supported - virtual bool removeObject( sptr /*obj*/ ) + virtual bool removeObject( sptr /*obj*/ ) { return false; } @@ -393,9 +393,9 @@ class SOFA_CORE_API BaseContext : public virtual Base /// @name Notifications for graph change listeners /// @{ - virtual void notifyAddSlave(core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); - virtual void notifyRemoveSlave(core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); - virtual void notifyMoveSlave(core::objectmodel::BaseComponent* previousMaster, core::objectmodel::BaseComponent* master, core::objectmodel::BaseComponent* slave); + virtual void notifyAddSlave(core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); + virtual void notifyRemoveSlave(core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); + virtual void notifyMoveSlave(core::objectmodel::BaseObject* previousMaster, core::objectmodel::BaseObject* master, core::objectmodel::BaseObject* slave); /// @} From 7f8d636de76f46ebb31fab56e7cf6faa1bef666e Mon Sep 17 00:00:00 2001 From: Alex Bilger Date: Thu, 5 Feb 2026 10:00:59 +0100 Subject: [PATCH 7/7] adapt tests --- Sofa/framework/Core/test/ObjectFactoryJson_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sofa/framework/Core/test/ObjectFactoryJson_test.cpp b/Sofa/framework/Core/test/ObjectFactoryJson_test.cpp index ce051811eb5..6b9aef3afd9 100644 --- a/Sofa/framework/Core/test/ObjectFactoryJson_test.cpp +++ b/Sofa/framework/Core/test/ObjectFactoryJson_test.cpp @@ -45,7 +45,7 @@ TEST(ObjectFactoryJson, oneObject) .add< simulation::DefaultAnimationLoop >().commitTo(&o), 1); const auto dump = core::ObjectFactoryJson::dump(&o); - const std::string expectedDump = R"x([{"className":"DefaultAnimationLoop","creator":{"":{"class":{"categories":["AnimationLoop"],"className":"DefaultAnimationLoop","namespaceName":"sofa::simulation","parents":["BaseAnimationLoop"],"shortName":"defaultAnimationLoop","templateName":"","typeName":"DefaultAnimationLoop"},"object":{"data":[{"defaultValue":"unnamed","group":"","help":"object name","name":"name","type":"string"},{"defaultValue":"0","group":"","help":"if true, emits extra messages at runtime.","name":"printLog","type":"bool"},{"defaultValue":"","group":"","help":"list of the subsets the object belongs to","name":"tags","type":"TagSet"},{"defaultValue":"","group":"","help":"this object bounding box","name":"bbox","type":"BoundingBox"},{"defaultValue":"Undefined","group":"","help":"The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).","name":"componentState","type":"ComponentState"},{"defaultValue":"0","group":"","help":"if true, handle the events, otherwise ignore the events","name":"listening","type":"bool"},{"defaultValue":"1","group":"","help":"If true, compute the global bounding box of the scene at each time step. Used mostly for rendering.","name":"computeBoundingBox","type":"bool"},{"defaultValue":"0","group":"","help":"If true, solves all the ODEs in parallel","name":"parallelODESolving","type":"bool"}],"link":[{"destinationTypeName":"BaseContext","help":"Graph Node containing this object (or BaseContext::getDefault() if no graph is used)","name":"context"},{"destinationTypeName":"BaseObject","help":"Sub-objects used internally by this object","name":"slaves"},{"destinationTypeName":"BaseObject","help":"nullptr for regular objects, or master object for which this object is one sub-objects","name":"master"},{"destinationTypeName":"BaseNode","help":"Link to the scene's node that will be processed by the loop","name":"targetNode"}]},"target":""}},"description":"foo\n"}])x"; + const std::string expectedDump = R"x([{"className":"DefaultAnimationLoop","creator":{"":{"class":{"categories":["AnimationLoop"],"className":"DefaultAnimationLoop","namespaceName":"sofa::simulation","parents":["BaseAnimationLoop"],"shortName":"defaultAnimationLoop","templateName":"","typeName":"DefaultAnimationLoop"},"object":{"data":[{"defaultValue":"unnamed","group":"","help":"object name","name":"name","type":"string"},{"defaultValue":"0","group":"","help":"if true, emits extra messages at runtime.","name":"printLog","type":"bool"},{"defaultValue":"","group":"","help":"list of the subsets the object belongs to","name":"tags","type":"TagSet"},{"defaultValue":"","group":"","help":"this object bounding box","name":"bbox","type":"BoundingBox"},{"defaultValue":"Undefined","group":"","help":"The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).","name":"componentState","type":"ComponentState"},{"defaultValue":"0","group":"","help":"if true, handle the events, otherwise ignore the events","name":"listening","type":"bool"},{"defaultValue":"1","group":"","help":"If true, compute the global bounding box of the scene at each time step. Used mostly for rendering.","name":"computeBoundingBox","type":"bool"},{"defaultValue":"0","group":"","help":"If true, solves all the ODEs in parallel","name":"parallelODESolving","type":"bool"}],"link":[{"destinationTypeName":"BaseContext","help":"Graph Node containing this object (or BaseContext::getDefault() if no graph is used)","name":"context"},{"destinationTypeName":"BaseComponent","help":"Sub-objects used internally by this object","name":"slaves"},{"destinationTypeName":"BaseComponent","help":"nullptr for regular objects, or master object for which this object is one sub-objects","name":"master"},{"destinationTypeName":"BaseNode","help":"Link to the scene's node that will be processed by the loop","name":"targetNode"}]},"target":""}},"description":"foo\n"}])x"; EXPECT_EQ(dump, expectedDump); } @@ -65,7 +65,7 @@ TEST(ObjectFactoryJson, oneTemplatedObject) const auto dump = core::ObjectFactoryJson::dump(&o); const auto vec3name = core::objectmodel::BaseClassNameHelper::getTypeName(); - const std::string expectedDump = R"x([{"className":"DummyComponent","creator":{"Vec3f":{"class":{"categories":["_Miscellaneous"],"className":"DummyComponent","namespaceName":"sofa","parents":["BaseObject"],"shortName":"dummyComponent","templateName":"Vec3f","typeName":"DummyComponent<)x" + std::string{vec3name} + R"x(>"},"object":{"data":[{"defaultValue":"unnamed","group":"","help":"object name","name":"name","type":"string"},{"defaultValue":"0","group":"","help":"if true, emits extra messages at runtime.","name":"printLog","type":"bool"},{"defaultValue":"","group":"","help":"list of the subsets the object belongs to","name":"tags","type":"TagSet"},{"defaultValue":"","group":"","help":"this object bounding box","name":"bbox","type":"BoundingBox"},{"defaultValue":"Undefined","group":"","help":"The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).","name":"componentState","type":"ComponentState"},{"defaultValue":"0","group":"","help":"if true, handle the events, otherwise ignore the events","name":"listening","type":"bool"}],"link":[{"destinationTypeName":"BaseContext","help":"Graph Node containing this object (or BaseContext::getDefault() if no graph is used)","name":"context"},{"destinationTypeName":"BaseObject","help":"Sub-objects used internally by this object","name":"slaves"},{"destinationTypeName":"BaseObject","help":"nullptr for regular objects, or master object for which this object is one sub-objects","name":"master"}]},"target":""}},"description":"foo\n"}])x"; + const std::string expectedDump = R"x([{"className":"DummyComponent","creator":{"Vec3f":{"class":{"categories":["_Miscellaneous"],"className":"DummyComponent","namespaceName":"sofa","parents":["BaseComponent"],"shortName":"dummyComponent","templateName":"Vec3f","typeName":"DummyComponent<)x" + std::string{vec3name} + R"x(>"},"object":{"data":[{"defaultValue":"unnamed","group":"","help":"object name","name":"name","type":"string"},{"defaultValue":"0","group":"","help":"if true, emits extra messages at runtime.","name":"printLog","type":"bool"},{"defaultValue":"","group":"","help":"list of the subsets the object belongs to","name":"tags","type":"TagSet"},{"defaultValue":"","group":"","help":"this object bounding box","name":"bbox","type":"BoundingBox"},{"defaultValue":"Undefined","group":"","help":"The state of the component among (Dirty, Valid, Undefined, Loading, Invalid).","name":"componentState","type":"ComponentState"},{"defaultValue":"0","group":"","help":"if true, handle the events, otherwise ignore the events","name":"listening","type":"bool"}],"link":[{"destinationTypeName":"BaseContext","help":"Graph Node containing this object (or BaseContext::getDefault() if no graph is used)","name":"context"},{"destinationTypeName":"BaseComponent","help":"Sub-objects used internally by this object","name":"slaves"},{"destinationTypeName":"BaseComponent","help":"nullptr for regular objects, or master object for which this object is one sub-objects","name":"master"}]},"target":""}},"description":"foo\n"}])x"; EXPECT_EQ(dump, expectedDump); }