You've already forked pico-launcher
mirror of
https://github.com/LNH-team/pico-launcher.git
synced 2026-01-09 16:28:48 -08:00
28 lines
869 B
C++
28 lines
869 B
C++
#pragma once
|
|
#include "Task.h"
|
|
|
|
class TaskFactory
|
|
{
|
|
template <typename T>
|
|
static T TaskResultToResultType(TaskResult<T> arg);
|
|
|
|
public:
|
|
template <typename FuncType>
|
|
static auto Create(const FuncType& function)
|
|
{
|
|
return FuncTask<decltype(TaskResultToResultType(function())), FuncType>(function);
|
|
}
|
|
|
|
template <typename FuncType>
|
|
static auto CreateOnHeap(const FuncType& function) -> Task<decltype(TaskResultToResultType(function()))>*
|
|
{
|
|
return new FuncTask<decltype(TaskResultToResultType(function())), FuncType>(function);
|
|
}
|
|
|
|
template <typename FuncType>
|
|
static auto CreateOnHeapUnique(const FuncType& function) -> std::unique_ptr<Task<decltype(TaskResultToResultType(function()))>>
|
|
{
|
|
return std::make_unique<FuncTask<decltype(TaskResultToResultType(function())), FuncType>>(function);
|
|
}
|
|
};
|