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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Sofa/framework/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compat>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}_compat>
)

target_link_libraries(${PROJECT_NAME} PRIVATE nlohmann_json::nlohmann_json)

if(SOFA_BUILD_WITH_PCH_ENABLED)
Expand Down
27 changes: 27 additions & 0 deletions Sofa/framework/Core/compat/sofa/core/objectmodel/BaseObject.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once

#include <sofa/config.h>
#include <sofa/core/objectmodel/BaseComponent.h>

SOFA_HEADER_DEPRECATED("v26.06", "v29.06", "sofa/core/objectmodel/BaseComponent.h")
7 changes: 7 additions & 0 deletions Sofa/framework/Core/src/sofa/core/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions Sofa/framework/Core/src/sofa/core/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ SOFA_CORE_API SReal dt(const sofa::core::MechanicalParams*);
namespace sofa::core::objectmodel
{
class Base;
class BaseObject;
class BaseComponent;
using BaseObject = BaseComponent;
class BaseNode;
class BaseContext;
class BaseData;
Expand Down Expand Up @@ -263,7 +264,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);

Expand Down
7 changes: 5 additions & 2 deletions Sofa/framework/Core/src/sofa/core/objectmodel/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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(); }

/// @}
};

Expand Down
3 changes: 2 additions & 1 deletion Sofa/framework/Core/src/sofa/core/objectmodel/BaseClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ class SOFA_CORE_API DeprecatedBaseClass : public BaseClass
{ \
return ::sofa::core::objectmodel::BaseLink::InitLink<MyType> \
(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 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#include <sofa/core/objectmodel/BaseObject.h>
#include <sofa/core/objectmodel/BaseComponent.h>
#include <sofa/core/objectmodel/BaseContext.h>
#include <sofa/core/objectmodel/BaseNode.h>
#include <sofa/core/objectmodel/Event.h>
Expand All @@ -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)"))
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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"))
{
Expand Down Expand Up @@ -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<BaseObject>(objectName);
const BaseComponent* loader = getContext()->get<BaseComponent>(objectName);
if (!loader)
{
msg_error() << "Source object \"" << valueString << "\" NOT FOUND.";
Expand All @@ -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)
{
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -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);
Expand All @@ -232,15 +232,15 @@ 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))
{
this->getContext()->notifyRemoveSlave(this, s.get());
}
}

void BaseObject::init()
void BaseComponent::init()
{
for(const auto data: this->m_vecData)
{
Expand All @@ -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 )
Expand All @@ -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();
Expand All @@ -314,40 +314,40 @@ 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())
{
removeSlave(l_slaves.getValue().front());
}
}

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())
{
handleTopologyChange();
}
}

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<const BaseNode*>(getContext());
if(!node)
Expand Down
Loading
Loading