1 // scriptmgr.hxx - run user scripts
2 // Written by David Megginson, started 2002.
4 // This file is in the Public Domain, and comes with no warranty.
6 #ifndef __SCRIPTMGR_HXX
7 #define __SCRIPTMGR_HXX
10 # error This library requires C++
13 #include <simgear/compiler.h> // for SG_USING_STD
14 #include <simgear/structure/subsystem_mgr.hxx>
20 * Manager for user scripts in PSL (PLIB's scripting language).
22 * The initial draft of this subsystem does nothing on update, and
23 * simply executes scripts on demand from various input bindings, but
24 * I plan to merge in code from Erik Hofman for events and scheduled
27 * Right now, there are three extension commands for
30 * print(...) - prints all of its arguments to standard output.
31 * get_property(name) - get a property value
32 * set_property(name, value) - set a property value
34 class FGScriptMgr : public SGSubsystem
47 virtual ~FGScriptMgr ();
57 * Update (no-op for now).
59 virtual void update (double delta_time_sec);
63 * Run an in-memory user script.
65 * Any included files are referenced relative to $FG_ROOT. This
66 * is not very efficient right now, since it recompiles the script
67 * every time it runs. The script must have a main() function.
69 * @param script A string containing the script.
70 * @return true if the script compiled properly, false otherwise.
73 virtual bool run (const char * script) const;
77 * Run an inline in-memory user script.
79 * The script is executed as if it were surrounded by a main()
80 * function, so it cannot contain any top-level constructions like
81 * #include statements or function declarations. This is useful
82 * for quick one-liners.
84 * @param script A string containing the inline script.
85 * @return true if the script compiled properly, false otherwise.
88 virtual bool run_inline (const char * script) const;
93 #endif // __SCRIPTMGR_HXX