Skip to content
Snippets Groups Projects
Commit 66e5f52a authored by Christoph Pohl's avatar Christoph Pohl
Browse files

Merge branch '140-fix-usage-of-custom-skill-blueprints' into 'master'

Resolve "Fix usage of custom skill blueprints"

Closes #140

See merge request sw/armarx/robot-api!416
parents a02294b8 cc62338a
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,8 @@ armarx_add_library( ...@@ -46,6 +46,8 @@ armarx_add_library(
detail/SkillImplementationWrapper.h detail/SkillImplementationWrapper.h
SkillContext.h SkillContext.h
blueprints/SkillWithContextBlueprint.h
mixins/All.h mixins/All.h
mixins/ArvizSkillMixin.h mixins/ArvizSkillMixin.h
......
...@@ -72,7 +72,7 @@ namespace armarx::plugins ...@@ -72,7 +72,7 @@ namespace armarx::plugins
{ {
auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...); auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...);
auto* facPtr = fac.get(); auto* facPtr = fac.get();
addCustomSkillFactory(std::move(fac)); addSkillFactory(std::move(fac));
return static_cast<FactoryT*>(facPtr); return static_cast<FactoryT*>(facPtr);
} }
...@@ -189,7 +189,7 @@ namespace armarx ...@@ -189,7 +189,7 @@ namespace armarx
requires skills::isSkillBlueprint<FacT> FacT* requires skills::isSkillBlueprint<FacT> FacT*
addCustomSkillFactory(Args&&... args) addCustomSkillFactory(Args&&... args)
{ {
return plugin->addSkillFactory<FacT>(std::forward<Args>(args)...); return plugin->addCustomSkillFactory<FacT>(std::forward<Args>(args)...);
} }
private: private:
......
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI
* @author Christoph Pohl ( christoph dot pohl at kit dot edu )
* @date 05.12.23
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <RobotAPI/libraries/skills/provider/SkillFactory.h>
namespace armarx
{
namespace skills
{
// template <typename T>
// concept takesContext = requires(typename T::Context cntxt) {
// { T::connectTo(cntxt) } -> void;
// };
template <typename SkillT>
class SkillWithContextBlueprint : public SkillBlueprint
{
public:
using ContextT = typename SkillT::Context;
template <typename... Args>
SkillWithContextBlueprint(Args&&... args) :
SkillBlueprint(*SkillBlueprint::ForSkill<SkillT>(std::forward<Args>(args)...))
{
}
virtual std::unique_ptr<Skill>
createSkill(const ProviderID& pid) const override
{
auto s = _createSkill();
s->setProviderId(pid);
static_cast<SkillT*>(s.get())->connectTo(context_);
return s;
}
void
connectTo(const ContextT& services)
{
context_ = services;
}
private:
ContextT context_;
};
} // namespace skills
} // namespace armarx
\ No newline at end of file
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