1 // $Id: main.cpp 3275 2006-04-09 00:32:34Z sommer $
4 // Copyright (C) 2005 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 #ifndef __SCRIPT_MANAGER_H__
21 #define __SCRIPT_MANAGER_H__
32 * This class is responsible for managing all running squirrel threads
33 * (they are cooperative threads or coroutines)
34 * It keeps a list of suspended scripts and receives wakeup events for them
45 * Creates a new thread and registers it with the script manager
46 * (so it can suspend and register for wakeup events)
48 HSQUIRRELVM create_thread();
50 HSQUIRRELVM get_global_vm() const
63 explicit WakeupData() : type(NO_EVENT) {}
64 explicit WakeupData(WakeupEvent type_) : type(type_) {}
70 GameObject* game_object;
74 void set_wakeup_event(HSQUIRRELVM vm, WakeupEvent event, float timeout = -1);
75 void set_wakeup_event(HSQUIRRELVM vm, WakeupData event, float timeout = -1);
76 void fire_wakeup_event(WakeupEvent event);
77 void fire_wakeup_event(WakeupData event);
83 SquirrelVM(HSQUIRRELVM arg_vm, HSQOBJECT arg_obj);
88 WakeupData waiting_for_events;
91 typedef std::list<SquirrelVM> SquirrelVMs;
92 SquirrelVMs squirrel_vms;
97 extern ScriptManager* script_manager;