]> git.mxchange.org Git - flightgear.git/blob - src/Scripting/scriptmgr.hxx
Moved random ground cover object management code (userdata.[ch]xx) over
[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
15 #include <Main/fgfs.hxx>
16
17 class pslExtension;
18
19
20 /**
21  * Manager for user scripts in PSL (PLIB's scripting language).
22  *
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
26  * tasks.
27  *
28  * Right now, there are three extension commands for
29  * FlightGear:
30  *
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
34  */
35 class FGScriptMgr : public FGSubsystem
36 {
37 public:
38
39     /**
40      * Constructor.
41      */
42     FGScriptMgr ();
43
44
45     /**
46      * Destructor.
47      */
48     virtual ~FGScriptMgr ();
49
50
51     /**
52      * Initialize PSL.
53      */
54     virtual void init ();
55
56
57     /**
58      * Update (no-op for now).
59      */
60     virtual void update (double delta_time_sec);
61
62
63     /**
64      * Run an in-memory user script.
65      *
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.
69      *
70      * @param script A string containing the script.
71      * @return true if the script compiled properly, false otherwise.
72      * @see #run_inline
73      */
74     virtual bool run (const char * script) const;
75
76
77     /**
78      * Run an inline in-memory user script.
79      *
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.
84      *
85      * @param script A string containing the inline script.
86      * @return true if the script compiled properly, false otherwise.
87      * @see #run
88      */
89     virtual bool run_inline (const char * script) const;
90     
91 };
92
93
94 #endif // __SCRIPTMGR_HXX