From d71325d83e7390836e7fb193fa7397f3942e108c Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Wed, 22 Jan 2025 20:16:51 +0100 Subject: [PATCH] App: Add GroupExtension::addObject(...) --- src/App/GroupExtension.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/App/GroupExtension.h b/src/App/GroupExtension.h index 4130023d23..8fa14f3eed 100644 --- a/src/App/GroupExtension.h +++ b/src/App/GroupExtension.h @@ -51,6 +51,11 @@ public: * append it to this group as well. */ virtual DocumentObject* addObject(const char* sType, const char* pObjectName); + /** Adds an object of \a T with \a pObjectName to the document this group belongs to and + * append it to this group as well. + */ + template + T* addObject(const char* pObjectName); /* Adds the object \a obj to this group. Returns all objects that have been added. */ virtual std::vector addObject(DocumentObject* obj); @@ -151,6 +156,13 @@ private: }; +template +T* GroupExtension::addObject(const char* pObjectName) +{ + static_assert(std::is_base_of::value, "T must be derived from DocumentObject"); + return static_cast(addObject(T::getClassName(), pObjectName)); +} + template class GroupExtensionPythonT: public ExtensionT {