2021-11-05 17:34:23 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Tasks.hpp
|
|
|
|
Date: 2021-11-1
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::Async
|
|
|
|
{
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
2021-11-07 20:16:20 +00:00
|
|
|
struct ITask
|
|
|
|
{
|
|
|
|
virtual Result_t OnFrame(const Info_t &in) const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
|
|
|
struct FTask final : ITask<Info_t, Result_t>
|
2021-11-05 17:34:23 +00:00
|
|
|
{
|
|
|
|
using InfoType_t = Info_t;
|
|
|
|
using ResultType_t = Result_t;
|
|
|
|
|
|
|
|
AuFunction<Result_t(const Info_t &)> onFrame;
|
2021-11-07 20:16:20 +00:00
|
|
|
|
|
|
|
virtual inline Result_t OnFrame(const Info_t &in) const override final
|
|
|
|
{
|
|
|
|
return onFrame(in);
|
|
|
|
}
|
2021-11-05 17:34:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
2021-11-07 20:16:20 +00:00
|
|
|
struct CTask final : ITask<Info_t, Result_t>
|
2021-11-05 17:34:23 +00:00
|
|
|
{
|
|
|
|
using InfoType_t = Info_t;
|
|
|
|
using ResultType_t = Result_t;
|
|
|
|
|
|
|
|
Result_t(* onFrame)(const Info_t &) = 0;
|
2021-11-07 20:16:20 +00:00
|
|
|
|
|
|
|
virtual inline Result_t OnFrame(const Info_t &in) const override final
|
|
|
|
{
|
|
|
|
return onFrame(in);
|
|
|
|
}
|
2021-11-05 17:34:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
using FVoidTask = FTask<AVoid, AVoid>;
|
|
|
|
}
|