29#include <range/v3/algorithm/all_of.hpp>
30#include <range/v3/range/conversion.hpp>
31#include <range/v3/view/filter.hpp>
32#include <range/v3/view/indirect.hpp>
33#include <range/v3/view/map.hpp>
34#include <range/v3/view/transform.hpp>
35#include <range/v3/view/zip.hpp>
54 << proxy_->getSkillId().toString();
63 <<
" on handle destruction.";
83 std::optional<TerminatedSkillStatusUpdate>
88 std::optional<TerminatedSkillStatusUpdate> result = proxy_->join(executionId_);
99 return proxy_->abortSkillAsync(executionId_);
102 std::optional<SkillStatusUpdate>
108 return proxy_->getExecutionStatus(executionId_);
115 operator bool()
const
117 return ranges::all_of(
118 ranges::views::values(
updates),
119 [](
const std::optional<armarx::skills::TerminatedSkillStatusUpdate>& update)
123 std::vector<armarx::skills::SkillExecutionID>
129 return ranges::views::keys(
updates) | ranges::views::filter(failed) | ranges::to_vector;
132 std::vector<armarx::skills::SkillID>
139 {
return executionId.skillId; };
141 return ranges::views::keys(
updates) | ranges::views::filter(failed) |
142 ranges::views::transform(getSkillID) | ranges::to_vector;
146 joinAll(
const std::vector<armarx::skills::SkillExecutionHandle*>& handles)
149 {
return handle.join(); };
152 {
return handle.executionId(); };
154 const auto executionIDs = handles | ranges::views::indirect |
155 ranges::views::transform(getExecutionID) | ranges::to_vector;
156 const auto updates = handles | ranges::views::indirect |
157 ranges::views::transform(join) | ranges::to_vector;
159 return JoinAllResult{ranges::views::zip(executionIDs, updates) |
160 ranges::to<JoinAllResult::UpdatesMap>()};
164 joinAll(
const std::vector<std::unique_ptr<armarx::skills::SkillExecutionHandle>>& handles)
166 const std::vector<armarx::skills::SkillExecutionHandle*> rawHandles =
167 handles | ranges::views::transform([](
auto& p) {
return p.get(); }) |
170 return static_cast<JoinAllResult (*)(
const std::vector<SkillExecutionHandle*>&)
>(
175 joinAll(
const std::vector<std::shared_ptr<armarx::skills::SkillExecutionHandle>>& handles)
177 const std::vector<armarx::skills::SkillExecutionHandle*> rawHandles =
178 handles | ranges::views::transform([](
auto& p) {
return p.get(); }) |
181 return static_cast<JoinAllResult (*)(
const std::vector<SkillExecutionHandle*>&)
>(
RAII handle for a running subskill.
bool abortAsync()
Request an asynchronous abort of the subskill.
std::optional< TerminatedSkillStatusUpdate > join()
Block until the subskill terminates and return its status.
~SkillExecutionHandle()
Destructor requests cleanup of the subskill.
SkillExecutionHandle(SkillProxyPtr proxy, skills::SkillExecutionID executionId)
Construct a handle for an executing subskill.
const skills::SkillExecutionID & executionId() const
std::optional< SkillStatusUpdate > getExecutionStatus()
Get the current execution status of the subskill.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_ERROR
The logging level for unexpected behaviour, that must be fixed.
#define ARMARX_VERBOSE
The logging level for verbose information.
JoinAllResult joinAll(const std::vector< armarx::skills::SkillExecutionHandle * > &handles)
This file is part of ArmarX.
bool skillExecutionSucceeded(const std::optional< armarx::skills::TerminatedSkillStatusUpdate > &update)
std::unique_ptr< class SkillProxy > SkillProxyPtr
bool skillExecutionFailed(const std::optional< armarx::skills::TerminatedSkillStatusUpdate > &update)
std::vector< armarx::skills::SkillID > failedSkillIDs() const
std::vector< armarx::skills::SkillExecutionID > failedSkillExecutionIDs() const