33 #ifndef __H__UG_BRIDGE__GLOBAL_FUNCTION__
34 #define __H__UG_BRIDGE__GLOBAL_FUNCTION__
47 #error "You need to define UG_PROFILER to use PROFILE_BRIDGE"
69 const std::string& retValInfos,
const std::string& paramInfos,
70 const std::string& tooltip,
const std::string& help);
73 const std::string&
name()
const {
return m_name;}
76 const std::string&
options()
const {
return m_methodOptions;}
79 const std::string&
return_name()
const {
return return_info(0);}
82 const std::string&
return_info(
size_t i)
const {
return m_vRetValInfo.at(i);}
91 size_t num_infos(
size_t i)
const {
return m_vvParamInfo.at(i).size();}
97 const std::string&
parameter_name(
size_t i)
const {
return parameter_info(i, 0);}
100 const std::string&
parameter_info(
size_t i,
size_t j)
const {
return m_vvParamInfo.at(i).at(j);}
109 const std::string&
tooltip()
const {
return m_tooltip;}
112 const std::string&
help()
const {
return m_help;}
125 bool check_consistency(std::string classname =
"")
const;
128 template <
typename TFunc>
139 const size_t MinNumInfos = 3;
142 m_vvParamInfo.resize(m_paramsIn.size());
144 for(
int i = 0; i < (int)m_vvParamInfo.size(); ++i)
145 for(
size_t j = m_vvParamInfo.at(i).size(); j < MinNumInfos; ++j)
146 m_vvParamInfo.at(i).push_back(std::string(
""));
155 for(
size_t j = m_vRetValInfo.size(); j < MinNumInfos; ++j)
156 m_vRetValInfo.push_back(std::string(
""));
160 void tokenize(
const std::string& str, std::vector<std::string>& tokens,
161 const char delimiter);
191 template <
typename TFunc>
193 const std::string&
name,
const std::string& funcOptions,
194 const std::string& group,
195 const std::string& retValInfos,
const std::string& paramInfos,
196 const std::string& tooltip,
const std::string& help)
198 paramInfos, tooltip, help),
199 m_group(group), m_func((void*)f), m_proxy_func(pf)
200 #ifdef PROFILE_BRIDGE
204 create_parameter_stack<TFunc>();
210 #ifdef PROFILE_BRIDGE
213 m_proxy_func(m_func, paramsIn, paramsOut);
215 #ifdef PROFILE_BRIDGE
222 const std::string&
group()
const {
return m_group;}
234 #ifdef PROFILE_BRIDGE
235 mutable RuntimeProfileInfo m_dpi;
251 for(
size_t i = 0; i < m_overloads.size(); ++i)
252 delete m_overloads[i].m_func;
256 const std::string&
name()
const {
return m_name;}
259 template <
class TFunc>
262 const std::string& funcOptions,
const std::string& group,
263 const std::string& retValInfos,
const std::string& paramInfos,
264 const std::string& tooltip,
const std::string& help)
266 size_t typeID = GetUniqueTypeID<TFunc>();
269 if(get_overload_by_type_id(typeID))
return NULL;
273 funcOptions, group, retValInfos,
274 paramInfos, tooltip, help);
283 {
return m_overloads.at(index).
m_func;}
286 {
return m_overloads.at(index).
m_func;}
288 template <
class TType>
291 size_t typeID = GetUniqueTypeID<TType>();
292 return get_overload_by_type_id(typeID);
295 template <
class TType>
298 size_t typeID = GetUniqueTypeID<TType>();
299 return get_overload_by_type_id(typeID);
304 for(
size_t i = 0; i < m_overloads.size(); ++i){
305 if(m_overloads[i].m_typeID == typeID)
306 return m_overloads[i].
m_func;
313 for(
size_t i = 0; i < m_overloads.size(); ++i){
314 if(m_overloads[i].m_typeID == typeID)
315 return m_overloads[i].
m_func;
321 {
return m_overloads.at(index).m_typeID;}
327 m_func(
func), m_typeID(typeID) {}
339 template <typename TFunc, typename TRet = typename func_traits<TFunc>::return_type>
345 TFunc fp = (TFunc)
func;
359 template <
typename TFunc>
365 TFunc fp = (TFunc)
func;
location name
Definition: checkpoint_util.lua:128
Base class for function/method export.
Definition: global_function.h:66
const ParameterInfo & params_out() const
parameter list for input values
Definition: global_function.h:118
const std::string & options() const
name of function
Definition: global_function.h:76
std::vector< std::string > m_vRetValInfo
Definition: global_function.h:168
ParameterInfo m_paramsIn
Definition: global_function.h:179
std::string m_tooltip
Definition: global_function.h:176
std::string m_methodOptions
Definition: global_function.h:165
ParameterInfo m_paramsOut
Definition: global_function.h:180
std::string m_name
Definition: global_function.h:164
std::string m_help
Definition: global_function.h:177
size_t num_parameter() const
number of parameters.
Definition: global_function.h:88
void create_parameter_stack()
Definition: global_function.h:129
std::string m_retValInfos
Definition: global_function.h:167
const std::string & help() const
help informations
Definition: global_function.h:112
const std::string & parameter_name(size_t i) const
name of parameter i
Definition: global_function.h:97
const std::string & name() const
name of function
Definition: global_function.h:73
std::vector< std::vector< std::string > > m_vvParamInfo
Definition: global_function.h:174
const std::string & return_name() const
name of return value
Definition: global_function.h:79
size_t num_infos(size_t i) const
number of info strings for one parameter
Definition: global_function.h:91
const std::vector< std::string > & return_info_vec() const
type info of return value
Definition: global_function.h:85
const std::string & parameter_info_string() const
whole string of all type infos for of all parameters
Definition: global_function.h:106
const std::string & return_info(size_t i) const
type info of return type
Definition: global_function.h:82
const std::string & parameter_info(size_t i, size_t j) const
type info of all parameters
Definition: global_function.h:100
const char * parameter_class_name(size_t i) const
class name of parameter i
Definition: global_function.h:94
ParameterInfo & params_in()
non-const export of param list
Definition: global_function.h:122
const std::string & tooltip() const
gives some information to the exported functions
Definition: global_function.h:109
const ParameterInfo & params_in() const
parameter list for input values
Definition: global_function.h:115
std::string m_paramInfos
Definition: global_function.h:171
const std::vector< std::string > & parameter_info_vec(size_t i) const
type info of i th parameters
Definition: global_function.h:103
Groups of Functions - useful to realize overloaded functions.
Definition: global_function.h:243
std::string m_name
Definition: global_function.h:332
size_t get_overload_type_id(size_t index) const
Definition: global_function.h:320
ExportedFunction * get_overload_by_type_id(size_t typeID)
Definition: global_function.h:302
std::vector< Overload > m_overloads
Definition: global_function.h:333
ExportedFunction * add_overload(TFunc f, ExportedFunction::ProxyFunc pf, const std::string &funcOptions, const std::string &group, const std::string &retValInfos, const std::string ¶mInfos, const std::string &tooltip, const std::string &help)
adds an overload. Returns false if the overload already existed.
Definition: global_function.h:261
const ExportedFunction * get_overload_by_type_id(size_t typeID) const
Definition: global_function.h:311
ExportedFunction * get_overload_by_type()
Definition: global_function.h:289
ExportedFunction * get_overload(size_t index)
Definition: global_function.h:282
const ExportedFunction * get_overload_by_type() const
Definition: global_function.h:296
ExportedFunctionGroup(const std::string &name)
constructor
Definition: global_function.h:246
~ExportedFunctionGroup()
destructor
Definition: global_function.h:249
size_t num_overloads() const
Definition: global_function.h:280
const ExportedFunction * get_overload(size_t index) const
Definition: global_function.h:285
const std::string & name() const
name of function group
Definition: global_function.h:256
This class describes a wrapper for a c++ - function, that is exported by ug.
Definition: global_function.h:186
ExportedFunction(TFunc f, ProxyFunc pf, const std::string &name, const std::string &funcOptions, const std::string &group, const std::string &retValInfos, const std::string ¶mInfos, const std::string &tooltip, const std::string &help)
Definition: global_function.h:192
std::string m_group
save groups
Definition: global_function.h:226
void(* ProxyFunc)(void *func, const ParameterStack &in, ParameterStack &out)
Definition: global_function.h:189
void execute(const ParameterStack ¶msIn, ParameterStack ¶msOut) const
executes the function
Definition: global_function.h:208
ProxyFunc m_proxy_func
proxy function
Definition: global_function.h:232
const std::string & group() const
return groups
Definition: global_function.h:222
void * m_func
pointer to to function
Definition: global_function.h:229
a stack holding parameter infos about a parameter stack
Definition: parameter_stack.h:73
A stack that can hold values together with their type-id.
Definition: parameter_stack.h:270
void push(void *ptr, const ClassNameNode *classNameNode)
Definition: parameter_stack.h:367
#define UG_API
Definition: ug_config.h:65
function func(x, y, z, t, si)
static void create(ParameterInfo &in)
Definition: param_to_type_value_list.h:92
static void create(ParameterInfo &stack)
Definition: param_to_type_value_list.h:115
Definition: global_function.h:324
size_t m_typeID
Definition: global_function.h:329
Overload()
Definition: global_function.h:325
ExportedFunction * m_func
Definition: global_function.h:328
Overload(ExportedFunction *func, size_t typeID)
Definition: global_function.h:326
static void apply(void *func, const ParameterStack &in, ParameterStack &out)
Definition: global_function.h:362
Definition: global_function.h:341
static void apply(void *func, const ParameterStack &in, ParameterStack &out)
Definition: global_function.h:342
Definition: param_to_type_value_list.h:71
Exception throw, if method name has not been given.
Definition: global_function.h:62
Definition: function_traits.h:59