From 3feeb8c06f449eeeb3638ad8f59828fe020b2bbb Mon Sep 17 00:00:00 2001 From: Bruno Marques Date: Thu, 20 Aug 2020 16:48:29 +0200 Subject: [PATCH] :children_crossing: Add virtual getPathName function in Base Both BaseObject and BaseNode have a getPathName function, but those can't be called from a Base ptr without dereferencing with toBaseNode / toBaseObject --- SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Base.h | 3 +++ .../modules/SofaCore/src/sofa/core/objectmodel/BaseData.h | 2 +- .../modules/SofaCore/src/sofa/core/objectmodel/BaseNode.h | 2 +- .../modules/SofaCore/src/sofa/core/objectmodel/BaseObject.h | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Base.h b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Base.h index ea226ea11f9..c3e88b21a3c 100644 --- a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Base.h +++ b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/Base.h @@ -180,6 +180,9 @@ class SOFA_CORE_API Base std::initializer_list outputs); void addOutputsToCallback(const std::string& name, std::initializer_list outputs); + + virtual std::string getPathName() const { return ""; } + /// Accessor to the object name const std::string& getName() const { diff --git a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseData.h b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseData.h index 449da4d0a65..d920db524ea 100644 --- a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseData.h +++ b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseData.h @@ -224,7 +224,7 @@ class SOFA_CORE_API BaseData : public DDGNode /// @} /// If we use the Data as a link and not as value directly - std::string getLinkPath() const { return parentBaseData.getPath(); } + virtual std::string getLinkPath() const { return parentBaseData.getPath(); } /// Return whether this %Data can be used as a linkPath. /// /// True by default. diff --git a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseNode.h b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseNode.h index 48425e013d1..576a78f3ff2 100644 --- a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseNode.h +++ b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseNode.h @@ -131,7 +131,7 @@ class SOFA_CORE_API BaseNode : public virtual Base virtual const BaseContext* getContext() const = 0; /// Return the full path name of this node - virtual std::string getPathName() const; + virtual std::string getPathName() const override; /// Return the path from this node to the root node virtual std::string getRootPath() const; diff --git a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseObject.h b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseObject.h index b4d3a298b72..1c03d48e8c5 100644 --- a/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseObject.h +++ b/SofaKernel/modules/SofaCore/src/sofa/core/objectmodel/BaseObject.h @@ -439,7 +439,7 @@ class SOFA_CORE_API BaseObject : public virtual Base /// Return the full path name of this object - virtual std::string getPathName() const; + virtual std::string getPathName() const override; /// @name internalupdate /// Methods related to tracking of data and the internal update