47 lines
1.2 KiB
C
47 lines
1.2 KiB
C
|
#ifndef ALSK_ALSK_IMPL_BONE_WHILE_H
|
||
|
#define ALSK_ALSK_IMPL_BONE_WHILE_H
|
||
|
|
||
|
#include <cmath>
|
||
|
#include <vector>
|
||
|
|
||
|
#include "../boneimplbase.h"
|
||
|
#include "../../skeleton/bone/while.h"
|
||
|
|
||
|
namespace alsk {
|
||
|
|
||
|
/**
|
||
|
* @brief While implementation for any execution
|
||
|
*/
|
||
|
template<typename R, typename... Args, typename... Tasks, typename Tag, typename Executor, typename State>
|
||
|
struct Impl<While<R(Args...), Tasks...>, Tag, Executor, State>:
|
||
|
BoneImplBase<While<R(Args...), Tasks...>, Tag, Executor, State>
|
||
|
{
|
||
|
using This = Impl;
|
||
|
using Test = Execute<typename This::Skeleton::TestLinks>;
|
||
|
using Task = Execute<typename This::Skeleton::TaskLinks>;
|
||
|
|
||
|
typename This::Skeleton skeleton;
|
||
|
typename This::Executor executor;
|
||
|
typename This::StateRef state;
|
||
|
|
||
|
constexpr Impl() = default;
|
||
|
template<typename S, typename O>
|
||
|
constexpr Impl(S&& skeleton, O&& executor, State& state):
|
||
|
skeleton{std::forward<S>(skeleton)},
|
||
|
executor{std::forward<O>(executor)},
|
||
|
state{state}
|
||
|
{}
|
||
|
|
||
|
template<typename T>
|
||
|
constexpr typename This::Return operator()(T& a, T const& b) {
|
||
|
auto tupleP = std::forward_as_tuple(a, b);
|
||
|
|
||
|
while(executor.template execute<Test>(*this, skeleton.test, tupleP, std::tuple<>{}))
|
||
|
executor.template execute<Task>(*this, skeleton.task, tupleP, std::tuple<>{});
|
||
|
}
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|
||
|
#endif
|