From 2c47b340bbb415dc88e774c47f85d35bb0753e81 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Tue, 1 Dec 2020 18:17:25 +0100 Subject: [PATCH] Part: Geometry - Add non-const getters for extensions --- src/Mod/Part/App/Geometry.cpp | 15 +++++++++++++-- src/Mod/Part/App/Geometry.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index ed4604b29f..c9ce273258 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -288,7 +288,7 @@ bool Geometry::hasExtension(std::string name) const return false; } -std::weak_ptr Geometry::getExtension(Base::Type type) const +std::weak_ptr Geometry::getExtension(Base::Type type) { for( auto ext : extensions) { if(ext->getTypeId() == type) @@ -298,7 +298,7 @@ std::weak_ptr Geometry::getExtension(Base::Type type) c throw Base::ValueError("No geometry extension of the requested type."); } -std::weak_ptr Geometry::getExtension(std::string name) const +std::weak_ptr Geometry::getExtension(std::string name) { for( auto ext : extensions) { if(ext->getName() == name) @@ -308,6 +308,17 @@ std::weak_ptr Geometry::getExtension(std::string name) throw Base::ValueError("No geometry extension with the requested name."); } +std::weak_ptr Geometry::getExtension(Base::Type type) const +{ + return const_cast(this)->getExtension(type).lock(); +} + +std::weak_ptr Geometry::getExtension(std::string name) const +{ + return const_cast(this)->getExtension(name).lock(); +} + + void Geometry::setExtension(std::unique_ptr && geo) { bool hasext=false; diff --git a/src/Mod/Part/App/Geometry.h b/src/Mod/Part/App/Geometry.h index 9ed35a73a2..f05f554cf9 100644 --- a/src/Mod/Part/App/Geometry.h +++ b/src/Mod/Part/App/Geometry.h @@ -107,6 +107,8 @@ public: bool hasExtension(std::string name) const; std::weak_ptr getExtension(Base::Type type) const; std::weak_ptr getExtension(std::string name) const; + std::weak_ptr getExtension(Base::Type type); + std::weak_ptr getExtension(std::string name); void setExtension(std::unique_ptr &&geo); void deleteExtension(Base::Type type); void deleteExtension(std::string name);