GemaLuaCoreLib
The GeMA Lua Core library
Functions
GmLuaTaskUtils Namespace Reference

Aux functions used by several of the task classes. More...

Functions

bool pushParameter (LuaEnv *env, const QVariant &v)
 Pushes v on the stack. More...
 
bool setInTable (LuaTable &t, const QVariant &index, const QVariant &v)
 Aux function used by pushParameter() to set a field in a table (integer or string) to the value v, following the same rules as in pushParameter(). Can not use LuaTable::fromVariantMap() due to the differences in treatment for user data values.
 
GmThreadTaskResult callLuaTaskFunction (void *dataSet, const GmThread *thread, const QString &luaName, const QVariantList &extraPars, const GmLogCategory &logger, bool loggerIsUpvalue, int(*iteratorClosure)(lua_State *), const char *fname)
 Aux function used by the GmLuaXxxTask classes to call a Lua function sending as parameters an iterator over the given data set + any additional extra parameters.
 
template<class T >
void parseExecOptions (LuaEnv *env, int stackPos, T(*str2Strat)(QString), T defStrategy, const char *fname, int *ntasks, int *nworkers, T *strategy, QVector< int > &taskAffinity)
 Parses the contents of the options Lua table at stackPos, using the function str2Strat() function to transform strings to a strategy enum value. On errors, this function calls luaL_error() and doesn't returns. More...
 

Detailed Description

Aux functions used by several of the task classes.

Function Documentation

◆ parseExecOptions()

template<class T >
void GmLuaTaskUtils::parseExecOptions ( LuaEnv env,
int  stackPos,
T(*)(QString str2Strat,
defStrategy,
const char *  fname,
int *  ntasks,
int *  nworkers,
T *  strategy,
QVector< int > &  taskAffinity 
)

Parses the contents of the options Lua table at stackPos, using the function str2Strat() function to transform strings to a strategy enum value. On errors, this function calls luaL_error() and doesn't returns.

Parameters
envThe Lua environment
stackPosThe position of the Lua table on the stack
str2StratPointer to the string to enumerate translation function. Expects that the function returns defStrategy on errors.
defStrategyThe default strategy enum value
fnameThe name of the called Lua function. Used on error messages.
ntasksFilled with the configured number of tasks. Default = 0.
nworkersFilled with the configured number of workers. Default = -1.
strategyFilled with the configured strategy enum value. Default = defStrategy.
taskAffinityVector filled with the contents of the 'affinity' table. Default = empty.

◆ pushParameter()

bool GmLuaTaskUtils::pushParameter ( LuaEnv env,
const QVariant v 
)

Pushes v on the stack.

Expects values to be:

  • Basic types: numbers, strings, boolean and nil
  • Tables with number and string keys whose values are accepted. Can not have cycles. IMPORTANT: Tables are NOT shared among environments. Each one has its own table copy.
  • User data objects inheriting from GmLuaObject. Those objects are reference counted and released when garbage collected from the last Lua env. This objects ARE shared between environments! Other types of user data objects / light user data objects are NOT supported.