Radium Engine  1.5.0
Task.hpp
1 #pragma once
2 
3 #include <Core/RaCore.hpp>
4 #include <functional>
5 #include <string>
6 
7 namespace Ra {
8 namespace Core {
13 class 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 
29 class 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;
44  std::string m_name;
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
Definition: Cage.cpp:3