Radium Engine  1.5.20
Loading...
Searching...
No Matches
Task.hpp
1#pragma once
2
3#include <Core/RaCore.hpp>
4#include <functional>
5#include <string>
6
7namespace Ra {
8namespace Core {
13class RA_CORE_API Task
14{
15 public:
17 virtual ~Task() {}
18
20 virtual std::string getName() const = 0;
21
23 virtual void process() = 0;
24};
25
29class RA_CORE_API FunctionTask : public Task
30{
31 public:
33 FunctionTask( const std::function<void( void )>& f, const std::string& name ) :
34 m_f( f ), m_name( name ) {}
35
37 virtual std::string getName() const override { return m_name; }
38
40 virtual void process() override { m_f(); }
41
42 protected:
43 std::function<void( void )> m_f;
45};
46
47} // namespace Core
48} // namespace Ra
std::string m_name
The function to call.
Definition Task.hpp:44
virtual void process() override
Call the function.
Definition Task.hpp:40
virtual std::string getName() const override
Return the provided task name.
Definition Task.hpp:37
FunctionTask(const std::function< void(void)> &f, const std::string &name)
Create a function task.
Definition Task.hpp:33
virtual std::string getName() const =0
Return the name of the task.
virtual void process()=0
Do the task job. Will be called from the task queue threads.
virtual ~Task()
Destructor.
Definition Task.hpp:17
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3