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 {