ug4
lua_compiler.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3  * Author: Martin Rupp
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 __LUACompiler_H__
34 #define __LUACompiler_H__
35 
36 #include <stdio.h>
37 #include <string>
40 
41 namespace ug{
42 
43 class VMAdd;
44 
45 namespace bridge {
46 
47 
48 
50 {
51 
52 private:
53  typedef int (*LUA2C_Function)(double *, const double *) ;
54 
56  std::string m_pDyn;
58 
59 public:
60  std::string m_name;
62  int m_iIn, m_iOut;
64  bool bVM;
66  {
67  m_f= nullptr;
68  m_name = "uninitialized";
69  m_pDyn = "";
70  m_libHandle = nullptr;
71  bInitialized = false;
72  bVM = false;
73  vm = nullptr;
74  }
75 
76  int num_in() const
77  {
78  return m_iIn;
79  }
80 
81  int num_out() const
82  {
83  return m_iOut;
84  }
85 
86  const std::string &name() const
87  {
88  return m_name;
89  }
90 
91  bool is_valid() const
92  {
93  return bInitialized;
94  }
95 
96  bool create(const char *functionName, LuaFunctionHandle* pHandle = nullptr);
97  bool createVM(const char *functionName, LuaFunctionHandle* pHandle = nullptr);
98  bool createC(const char *functionName, LuaFunctionHandle* pHandle = nullptr);
99 
100  bool call(double *ret, const double *in) const;
101  virtual ~LUACompiler();
102 };
103 
104 
105 }
106 }
107 #endif /* __LUACompiler_H__ */
108 
Handle for a lua reference.
Definition: lua_function_handle.h:40
--> documentation in vm.doxygen <–///
Definition: vm.h:49
Definition: lua_compiler.h:50
int(* LUA2C_Function)(double *, const double *)
Definition: lua_compiler.h:53
std::string m_name
Definition: lua_compiler.h:60
virtual ~LUACompiler()
Definition: lua_compiler.cpp:247
DynLibHandle m_libHandle
Definition: lua_compiler.h:55
std::string m_pDyn
Definition: lua_compiler.h:56
LUACompiler()
Definition: lua_compiler.h:65
bool bVM
Definition: lua_compiler.h:64
const std::string & name() const
Definition: lua_compiler.h:86
int num_in() const
Definition: lua_compiler.h:76
bool create(const char *functionName, LuaFunctionHandle *pHandle=nullptr)
Definition: lua_compiler.cpp:59
VMAdd * vm
Definition: lua_compiler.h:57
LUA2C_Function m_f
Definition: lua_compiler.h:61
int num_out() const
Definition: lua_compiler.h:81
int m_iOut
Definition: lua_compiler.h:62
bool bInitialized
Definition: lua_compiler.h:63
bool call(double *ret, const double *in) const
Definition: lua_compiler.cpp:263
bool createVM(const char *functionName, LuaFunctionHandle *pHandle=nullptr)
Definition: lua_compiler.cpp:187
bool createC(const char *functionName, LuaFunctionHandle *pHandle=nullptr)
Definition: lua_compiler.cpp:67
bool is_valid() const
Definition: lua_compiler.h:91
int m_iIn
Definition: lua_compiler.h:62
void * DynLibHandle
Defines a reference to a dynamically loaded library.
Definition: dynamic_library_util.h:51
the ug namespace