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
15 #include <Main/fgfs.hxx>
21 * Manager for user scripts in PSL (PLIB's scripting language).
23 * The initial draft of this subsystem does nothing on update, and
24 * simply executes scripts on demand from various input bindings, but
25 * I plan to merge in code from Erik Hofman for events and scheduled
28 * Right now, there are three extension commands for
31 * print(...) - prints all of its arguments to standard output.
32 * get_property(name) - get a property value
33 * set_property(name, value) - set a property value
35 class FGScriptMgr : public FGSubsystem
48 virtual ~FGScriptMgr ();
58 * Update (no-op for now).
60 virtual void update (double delta_time_sec);
64 * Run an in-memory user script.
66 * Any included files are referenced relative to $FG_ROOT. This
67 * is not very efficient right now, since it recompiles the script
68 * every time it runs. The script must have a main() function.
70 * @param script A string containing the script.
71 * @return true if the script compiled properly, false otherwise.
74 virtual bool run (const char * script) const;
78 * Run an inline in-memory user script.
80 * The script is executed as if it were surrounded by a main()
81 * function, so it cannot contain any top-level constructions like
82 * #include statements or function declarations. This is useful
83 * for quick one-liners.
85 * @param script A string containing the inline script.
86 * @return true if the script compiled properly, false otherwise.
89 virtual bool run_inline (const char * script) const;
94 #endif // __SCRIPTMGR_HXX