]> git.mxchange.org Git - flightgear.git/blob - src/Scripting/scriptmgr.hxx
Currently, when the sim pauses, all IO is also halted. To me it generally
[flightgear.git] / src / Scripting / scriptmgr.hxx
1 // scriptmgr.hxx - run user scripts
2 // Written by David Megginson, started 2002.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __SCRIPTMGR_HXX
7 #define __SCRIPTMGR_HXX
8
9 #ifndef __cplusplus
10 # error This library requires C++
11 #endif
12
13 #include <simgear/compiler.h>   // for SG_USING_STD
14 #include <simgear/structure/subsystem_mgr.hxx>
15
16 class pslExtension;
17
18
19 /**
20  * Manager for user scripts in PSL (PLIB's scripting language).
21  *
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
25  * tasks.
26  *
27  * Right now, there are three extension commands for
28  * FlightGear:
29  *
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
33  */
34 class FGScriptMgr : public SGSubsystem
35 {
36 public:
37
38     /**
39      * Constructor.
40      */
41     FGScriptMgr ();
42
43
44     /**
45      * Destructor.
46      */
47     virtual ~FGScriptMgr ();
48
49
50     /**
51      * Initialize PSL.
52      */
53     virtual void init ();
54
55
56     /**
57      * Update (no-op for now).
58      */
59     virtual void update (double delta_time_sec);
60
61
62     /**
63      * Run an in-memory user script.
64      *
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.
68      *
69      * @param script A string containing the script.
70      * @return true if the script compiled properly, false otherwise.
71      * @see #run_inline
72      */
73     virtual bool run (const char * script) const;
74
75
76     /**
77      * Run an inline in-memory user script.
78      *
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.
83      *
84      * @param script A string containing the inline script.
85      * @return true if the script compiled properly, false otherwise.
86      * @see #run
87      */
88     virtual bool run_inline (const char * script) const;
89     
90 };
91
92
93 #endif // __SCRIPTMGR_HXX