Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lua_util.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2014: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG__UG_SCRIPT__
34#define __H__UG__UG_SCRIPT__
35#include <vector>
36#include <string>
37
38#ifndef USE_LUAJIT
39// default lua
40extern "C" {
41#include "externals/lua/lua.h"
42#include "externals/lua/lauxlib.h"
43#include "externals/lua/lualib.h"
44}
45#else
46// luajit
47#include <lua.hpp>
48#endif
49
50#include "common/common.h"
52#include "registry/registry.h"
53
54
55
56
57namespace ug
58{
59
60namespace script
61{
62
64class LuaError : public UGError
65{
66 public:
67 LuaError(const char* msg) : UGError(msg), bShowMsg(true) {}
68 LuaError() : UGError(""), bShowMsg(false) {}
69
70 bool show_msg() const {return bShowMsg;}
71
72 protected:
74};
75
76
77
79
94UG_API bool LoadUGScript(const char* filename, bool bDistributed);
96UG_API bool LoadUGScript_Parallel(const char* filename);
98UG_API bool LoadUGScript_Single(const char* filename);
99
101UG_API void RegisterDefaultLuaBridge(ug::bridge::Registry* reg, std::string grp = "/ug4");
102
104
110
112
114
122UG_API bool ParseAndExecuteBuffer(const char* buffer, const char *bufferName="buffer");
123
126
129
132
135
138
141
144
147
150
159UG_API void SetLuaUGArgs(lua_State* L, int argc, char* argv[]);
160
163
174UG_API bool GetAbsoluteUGScriptFilename(const std::string &filename, std::string &absoluteFilename);
175
176}// end of namespace
177}// end of namespace
178
179
180#endif
Instances of this class or of derived classes are thrown if errors arise.
Definition error.h:104
Registry for functions and classes that are exported to scripts and visualizations.
Definition registry.h:138
Error class thrown if an error occurs during parsing.
Definition lua_util.h:65
LuaError()
Definition lua_util.h:68
bool bShowMsg
Definition lua_util.h:73
bool show_msg() const
Definition lua_util.h:70
LuaError(const char *msg)
Definition lua_util.h:67
#define UG_API
Definition ug_config.h:65
struct lua_State lua_State
Definition lua_table_handle.h:40
int UGLuaPrintAllProcs(lua_State *L)
UGLuaPrint. Redirects LUA prints to UG_LOG.
Definition lua_util.cpp:369
bool LoadUGScript_Parallel(const char *filename)
calls LoadUGScript with bDistributed=true
Definition lua_util.cpp:192
int UGGetMetatable(lua_State *L)
Returns the metatable for the given class.
Definition lua_util.cpp:433
int UGAlgebraCompiled(lua_State *L)
Returns if dimension is compiled into binary.
Definition lua_util.cpp:564
void RegisterStdLUAFunctions(lua_State *L)
register functions like print and write directly to LUA (not using the ug registry)
Definition lua_util.cpp:423
void ReleaseDefaultLuaState()
calls lua_close, which calls delete for all lua objects
Definition lua_util.cpp:287
int UGIsBaseClass(lua_State *L)
Returns if a class contains a base class.
Definition lua_util.cpp:489
bool GetAbsoluteUGScriptFilename(const string &filename, string &absoluteFilename)
Definition lua_util.cpp:111
lua_State * GetDefaultLuaState()
returns the default lua state
Definition lua_util.cpp:242
bool LoadUGScript(const char *_filename, bool bDistributedLoad, bool bThrowOnError)
Definition lua_util.cpp:139
void RegisterDefaultLuaBridge(ug::bridge::Registry *reg, std::string grp)
registers lua only functionality at the registry
Definition lua_util.cpp:214
void SetLuaUGArgs(lua_State *L, int argc, char *argv[])
Definition lua_util.cpp:528
bool LoadUGScript_Single(const char *filename)
calls LoadUGScript with bDistributed=false . Avoid. (
Definition lua_util.cpp:196
int UGGetClassName(lua_State *L)
Returns type of a userdata as string.
Definition lua_util.cpp:444
int UGGetClassGroup(lua_State *L)
Returns classgroup of a userdata as string.
Definition lua_util.cpp:465
int UGLuaWrite(lua_State *L)
UGLuaWrite. Redirects LUA prints to UG_LOG without adding newline at the end.
Definition lua_util.cpp:380
bool ParseAndExecuteBuffer(const char *buffer, const char *bufferName)
Definition lua_util.cpp:308
int UGLuaPrint(lua_State *L)
UGLuaPrint. Redirects LUA prints to UG_LOG.
Definition lua_util.cpp:359
int UGDimCompiled(lua_State *L)
Returns if dimension is compiled into binary.
Definition lua_util.cpp:549
the ug namespace