|
libFAUDES
Sections
Index
|
lbp_1_extension.cpp File ReferenceRegistering a lua script with the libFAUDES run-time interface. More... #include "libfaudes.h" #include "libluafaudes.h" #include "lua/lua.h" #include "lua/lauxlib.h" #include "lua/lualib.h" #include <iostream> #include <fstream> #include <sstream> #include <string> #include <csignal> #include <cstdio> #include <cstdlib> #include <cstring> #include "corefaudes.h" #include "lbp_load.h" Go to the source code of this file.
Detailed DescriptionRegistering a lua script with the libFAUDES run-time interface. This tutorial loads a luascript from file an registers it with the libFAUDES run-time interface. Thus, the script can be invoked by an application in the same way as built in functions. /** @file lbp_1_extension.cpp Registering a lua script with the libFAUDES run-time interface This tutorial loads a luascript from file an registers it with the libFAUDES run-time interface. Thus, the script can be invoked by an application in the same way as built in functions. @ingroup Tutorials @include lbp_1_extension.cpp */ // libfaudes include #include "libfaudes.h" // luafaudes plugin #include "libluafaudes.h" // we make the faudes namespace available to our program using namespace faudes; ///////////////// // main program ///////////////// int main (int argc, char **argv) { // load std registry for data types LoadRegistry("../../../include/libfaudes.rti"); // initialize a lua function definition from file LuaFunctionDefinition lfdef1; lfdef1.Read("data/largegen.rti"); // report to console std::cout << "################################\n"; std::cout << "# lua extension from rti file\n"; lfdef1.Write(); std::cout << "################################\n"; // run syntax check on script std::string err=lfdef1.SyntaxCheck(); if(err=="") std::cout << "script seems ok\n"; else { std::cout << err << "\n"; return 1; } // test faudes type interface (assignment/equality) LuaFunctionDefinition lfdef2; lfdef2 = lfdef1; if(lfdef2!=lfdef1) { std::cout << "# ERR: the two definitions should be equal\n"; exit(1); } // report to console std::cout << "################################\n"; std::cout << "# copy of lua extension\n"; lfdef2.Write(); std::cout << "################################\n"; // instantiate a function object faudes::Function* fnct = lfdef2.NewFunction(); // prepare arguments Integer cntq=10; Integer cnts=5; Generator gres; // set argumants fnct->Variant(0); fnct->ParamValue(0,&cntq); fnct->ParamValue(1,&cnts); fnct->ParamValue(2,&gres); // execute lua script fnct->Execute(); // report statistics on result std::cout << "################################\n"; std::cout << "# statistics \n"; gres.SWrite(); std::cout << "################################\n"; } Definition in file lbp_1_extension.cpp. Function Documentation
Definition at line 32 of file lbp_1_extension.cpp. |
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3