JNGL
job.hpp
Go to the documentation of this file.
1 // Copyright 2012-2020 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include <memory>
8 
9 namespace jngl {
10 
15 class Job {
16 public:
21  virtual void step() = 0;
22 
27  virtual void draw() const = 0;
28 
30  Job() = default;
31 
33  Job(const Job&) = default;
34 
36  Job& operator=(const Job&) = default;
37 
39  Job(Job&&) = default;
40 
42  Job& operator=(Job&&) = default;
43 
45  virtual ~Job();
46 };
47 
50 
52 template <class T, class... Args>
53 void addJob(Args&&... args) {
54  addJob(std::make_shared<T>(std::forward<Args>(args)...));
55 }
56 
57 } // namespace jngl
Background job which stays part of the main loop independent of the active jngl::Work.
Definition: job.hpp:15
virtual void draw() const =0
Draw the game state.
Job & operator=(Job &&)=default
Move assignment.
virtual void step()=0
Advance the game logic.
virtual ~Job()
Does nothing.
Job & operator=(const Job &)=default
Copy assignment.
Job()=default
Does nothing.
Job(const Job &)=default
Copy constructor.
Job(Job &&)=default
Move constructor.
JNGL's main namespace.
Definition: App.hpp:10
void addJob(std::shared_ptr< Job > job)
Add a new Job which will be always be stepped and drawn by App::mainLoop()