Skip to content
Snippets Groups Projects
Commit d11c236f authored by Fabian Reister's avatar Fabian Reister
Browse files

SkillProviderComponentPlugin: addSkill with template param

parent faf4451e
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
#include <queue>
#include <thread>
#include <functional>
#include <type_traits>
#include <ArmarXCore/core/ComponentPlugin.h>
#include <ArmarXCore/core/ManagedIceObject.h>
......@@ -66,6 +67,18 @@ namespace armarx
void addSkill(const skills::LambdaSkill::FunT&, const skills::SkillDescription&);
void addSkill(std::unique_ptr<skills::Skill>&&);
template<typename T>
T* addSkill()
{
static_assert(std::is_base_of<skills::Skill, T>::value, "T must be derived from skills::Skill!");
static_assert(std::is_default_constructible<T>::value, "T must be default constructible!");
auto skill = std::make_unique<T>();
auto* skillPtr = skill.get();
addSkill(std::move(skill));
return static_cast<T*>(skillPtr);
}
private:
armarx::plugins::SkillProviderComponentPlugin* plugin = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment