supertux
squirrel_virtual_machine.hpp
1 // SuperTux
2 // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_SQUIRREL_SQUIRREL_VIRTUAL_MACHINE_HPP
18 #define HEADER_SUPERTUX_SQUIRREL_SQUIRREL_VIRTUAL_MACHINE_HPP
19 
20 #include <memory>
21 
22 #include <squirrel.h>
23 
24 #include "squirrel/squirrel_vm.hpp"
25 #include "util/currenton.hpp"
26 
28 class SquirrelScheduler;
29 
30 class SquirrelVirtualMachine final : public Currenton<SquirrelVirtualMachine>
31 {
32 public:
33  SquirrelVirtualMachine(bool enable_debugger);
35 
36  SquirrelVM& get_vm() { return m_vm; }
37 
38  void wait_for_seconds(HSQUIRRELVM vm, float seconds);
39  void update(float dt_sec);
40 
42  void wait_for_screenswitch(HSQUIRRELVM vm);
43 
45  void wakeup_screenswitch();
46 
47 private:
48  void update_debugger();
49 
50 private:
51  SquirrelVM m_vm;
52 
53  std::unique_ptr<SquirrelThreadQueue> m_screenswitch_queue;
54  std::unique_ptr<SquirrelScheduler> m_scheduler;
55 
56 private:
58  SquirrelVirtualMachine& operator=(const SquirrelVirtualMachine&) = delete;
59 };
60 
61 #endif
62 
63 /* EOF */
Definition: squirrel_virtual_machine.hpp:30
void wakeup_screenswitch()
wakes up threads waiting for a screen switch event
Definition: squirrel_virtual_machine.cpp:163
This class keeps a list of squirrel threads that are scheduled for a certain time.
Definition: squirrel_scheduler.hpp:28
A &#39;Currenton&#39; allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
Basic wrapper around HSQUIRRELVM with some utility functions, not to be confused with SquirrelVirtual...
Definition: squirrel_vm.hpp:29
void wait_for_screenswitch(HSQUIRRELVM vm)
adds thread waiting for a screen switch event
Definition: squirrel_virtual_machine.cpp:157
Keeps a list of SquirrelThreads that wait for a wakeup event.
Definition: squirrel_thread_queue.hpp:26