lbp_include.h
Go to the documentation of this file.
1 /** @file lbp_include.h Includes all luabindings plug-in headers */
2 
3 /*
4  ****************************************************
5  Convenience header file that includes all headers
6  relevant to the luabindings plug-in.
7 
8  (c) Thomas Moor 2008
9  ****************************************************
10  */
11 
12 
13 #ifndef FAUDES_LBP_INCLUDE_H
14 #define FAUDES_LBP_INCLUDE_H
15 
16 #endif
17 
18 
19 
20 /**
21 
22 @defgroup LuabindingsPlugin Lua Bindings PlugIn
23 
24 
25 @ingroup AllPlugins
26 
27 <p>
28 This plug-in generates libFAUDES bindings for the scripting language Lua;
29 see http://www.lua.org.
30 With this plug-in, a Lua interpreter may serve as
31 an interactive user interface to libFAUDES data types and functions.
32 The tutorial section includes a number of example scripts to demonstrate
33 libFAUDES access from Lua.
34 </p>
35 
36 <p>
37 The luabindings plug-in also includes the application luafaudes, a variation of
38 the std Lua interpreter that runs FAUDES extended lua scripts. If your target platform
39 is Linux, you really want to re-compile with LBP_LUAGOAL=linux in the Makefile.plug-in
40 in order to enable advanced readline support (tab key completion, command history etc).
41 </p>
42 
43 @section SecLuabindingsIntro1 Example Script
44 
45 The following script runs a simple synthesis procedure to
46 synthesise a supervisor - sic - for our two simple machines.
47 For examples, see "./plugins/luabindings/tutorial/_*_.lua" and the
48 introduction given on http://www.rt.eei.uni-erlangen.de/FGdes/faudes/luafaudes
49 
50 @code
51 
52 -- read original machine
53 machine = faudes.Generator("data/verysimplemachine.gen")
54 
55 -- prepare two copies
56 machine1 = faudes.Generator();
57 machine2 = faudes.Generator();
58 faudes.Version(machine,"1",machine1);
59 faudes.Version(machine,"2",machine2);
60 
61 -- compose overall plant
62 plant = faudes.Generator();
63 faudes.Parallel(machine1,machine2,plant);
64 
65 -- load specification
66 spec = faudes.Generator("data/buffer12.gen");
67 
68 -- run synthesis
69 super = faudes.Generator();
70 faudes.SupConNB(plant,spec,super);
71 
72 
73 -- report result
74 plant:Write();
75 spec:Write();
76 super:Write();
77 @endcode
78 
79 @section SecLuabindingsIntro2 Extending Luabindings
80 
81 
82 When you use the libFAUDES plug-in mechanism to implement your algorithms,
83 you may find it useful to include your extensions in the Lua based
84 interface. The wrapper code is automatically generated from so called interface
85 definition files using the tool SWIG; see http://www.swig.org.
86 
87 For data types with a tailored user interface, you will need to provide
88 interface definitions directly to define the way a user may interact with
89 variables of the respective type. For functions that are registered with
90 the faudes run-time interface, the interface definitions will be generated
91 by the build system. In both cases, the additional
92 code required to integrate your plug-in into luafaudes is minimal.
93 
94 The below is from the example plug-in and directly defines the interface for the
95 AlternativeAccessible function. For more detailed information,
96 see the <a href="../faudes_algorithm_example.html">Plug-In Example</a>
97 
98 
99 @code
100 // Set SWIG module name
101 // Note: must match libFAUDES plug-in name
102 %module example
103 #ifndef SwigModule
104 #define SwigModule "SwigExample"
105 #endif
106 
107 // Load std faudes interface
108 %include "faudesmodule.i"
109 
110 // Include rti generated functioninterface
111 #if SwigModule=="SwigExample"
112 %include "../../../include/rtiautoload.i"
113 #endif
114 
115 // Define interface to additional functions
116 void OtherFunction(Generator& rGen, rEventSet& rAlph);
117 bool IsGoodTest(Generator& rGen, rEventSet& rAlph);
118 ...
119 
120 @endcode
121 
122 
123 
124 @section SecLuabindingsIntro3 Build System
125 
126 Since not every libFAUDES based application requires luabindings,
127 the luabindings plug-in does not add code to libFAUDES itself but compiles
128 to a seperate archive named libluafaudes (.a,.so,.dll)
129 
130 The build system organises the compilation of the luabindings plug-in in two stages:
131 - At stage one, SWIG is used to generate the wrapper code. Since the plug-in ships
132  with appropriate wrapper code, this stage only needs to be processed if you want to
133  generate additional bindings for you plug-in. You will need SWIG version 1.3.36 installed on your system; see http://www.swig.org.
134  Use <tt>make luabindings-clean</tt> and <tt>make luabindings-prepare</tt> to re-build the wrapper code.
135  This stage is also processed by the configuration procedure, e.g. <tt>make dist-clean</tt> and <tt>make configure</tt>.
136 - At stage two, the wrapper code and Lua is compiled to the archive
137  <tt>libluafaudes.a</tt>. The plug-in includes the lua sources, no additional software requirements
138  are imposed. This stage is processed by the std build procedure, eg <tt>make clean</tt> and <tt>make</tt>.
139 
140 
141 @section SecLuabindingsIntro4 Advanced Topic: RTI extensions by Lua functions
142 
143 The Lua environment is designed to support both calling C code from a Lua script
144 as well as calling Lua code from a C application. The latter direction is used
145 by faudes::LuaFunction and faudes::LuaFunctionDefinition objects to extend libFAUDES
146 by Lua scripts that register with the libFAUDES run-time interface. Thus, libFAUDES applications
147 that interface to libFAUDES via the RTI can be transparently extended by Lua scripts.
148 
149 
150 @section License
151 
152 The luabindings plug-in is distributed with libFAUDES.
153 All code except Lua sources are provided under terms of the LGPL.
154 
155 
156 Copyright (c) 2008, 2023 Thomas Moor.
157 
158 
159 Lua sources are included for convenience and come under terms of the following MIT License:
160 
161 License for Lua 5.0 and later versions
162 Copyright (c) 1994-2008 Lua.org, PUC-Rio.
163 
164 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
165 
166 The above copyright notice and this permission notice shall be included in all copies or substantial portions ofthe Software.
167 
168 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
169 
170 
171 The luabindings plug-in also provides a variation of
172 the advanced readline support, which is Copyright (C) 2004-2006 Mike Pall,
173 with the same license as Lua. See also the file lbp_completion.cpp
174 
175 
176 
177 */
178 
179 
180 #ifndef FAUDES_LIBLUAFAUDES_H
181 #define FAUDES_LIBLUAFAUDES_H
182 
183 
184 // lua essentials
185 #define lua_c
186 
187 
188 // lua essentials
189 extern "C" {
190 #include "lua/lua.h"
191 #include "lua/lauxlib.h"
192 #include "lua/lualib.h"
193 }
194 
195 
196 // std streams
197 #include <iostream>
198 #include <fstream>
199 #include <sstream>
200 #include <string>
201 
202 // c libs since we dont use lua.h
203 #include <csignal>
204 #include <cstdio>
205 #include <cstdlib>
206 #include <cstring>
207 
208 // luafaudes: include faudes plus lua addons
209 #include "corefaudes.h"
210 #include "lbp_addons.h"
211 #include "lbp_function.h"
212 
213 // include declarations for SWIG generated module loaders
214 #include "lbp_load.h"
215 
216 
217 // SWIG interface std: programatic exception, see coreaddons.i
218 namespace faudes {
219 extern FAUDES_API void faudes_throw_exception(const std::string& msg);
220 extern FAUDES_API void faudes_dict_insert_topic(const std::string& topic, const std::string& text);
221 extern FAUDES_API void faudes_dict_insert_entry(const std::string& topic, const std::string& key, const std::string& entry);
222 extern FAUDES_API void faudes_mute(bool on);
223 extern FAUDES_API void faudes_console(const std::string& message);
224 extern FAUDES_API void faudes_debug(const std::string& message);
225 }
226 
227 // luafaudes debugging facilities
228 #ifdef FAUDES_DEBUG_LUABINDINGS
229 #define FD_DLB(message) FAUDES_WRITE_CONSOLE("FAUDES_LUA_ERROR: " << message);
230 #else
231 #define FD_DLB(message)
232 #endif
233 
234 
235 
236 #endif
#define FAUDES_API
Interface export/import symbols: windows.
Definition: cfl_platform.h:81
Includes all libFAUDES headers, no plugins.
luafaudes class to run scripts as rti functions
libFAUDES resides within the namespace faudes.
FAUDES_API void faudes_mute(bool on)
FAUDES_API void faudes_debug(const std::string &message)
FAUDES_API void faudes_dict_insert_topic(const std::string &topic, const std::string &text)
FAUDES_API void faudes_dict_insert_entry(const std::string &topic, const std::string &key, const std::string &entry)
FAUDES_API void faudes_console(const std::string &message)
FAUDES_API void faudes_throw_exception(const std::string &msg)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen