GemaLuaCoreLib
The GeMA Lua Core library
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
GmLuaAccessorBase< T > Class Template Reference

A helper class for implementing the common behaviour between GmLuaValueAccessor, GmLuaCellAccessor, GmLuaGaussAccessor, GmLuaBoudaryConditionAccessor and GmLuaDiscontinuityAccessor. More...

#include <gmLuaValueAccessor.h>

Inheritance diagram for GmLuaAccessorBase< T >:
Inheritance graph
[legend]
Collaboration diagram for GmLuaAccessorBase< T >:
Collaboration graph
[legend]

Classes

struct  Options
 Options for valueStr() More...
 

Public Member Functions

virtual ~GmLuaAccessorBase ()
 Destructor.
 
virtual QString toString () const
 Default method used by the __tostring metamethod to capture the result of tostring() over an object.
 
virtual void fillMetatable (lua_State *L, int index)
 Prepares the object metatable for calling methods.
 
T * accessor () const
 Returns the wrapped accessor.
 
- Public Member Functions inherited from GmLuaObject
virtual ~GmLuaObject ()
 Destrutor.
 
virtual void populateMetatable (lua_State *L, int index)
 Fills the object metatable to allow for the proxy to export its methods.
 
QVariant ptrToVariant ()
 Constructs a QVariant storing a POINTER to the current object.
 
void ref ()
 Increments the object reference count. Use with care.
 
- Public Member Functions inherited from LuaProxy::Base
virtual void * getClassMetatableID ()=0
 

Protected Member Functions

 GmLuaAccessorBase (T *ac, const GmLogCategory &logger, bool ownership)
 Constructor. Receives the ValueAccessor to be wrapped. More...
 
void parseCoord (lua_State *L, int stackPos, QString fname, GmVector &coord)
 An auxiliary function used to parse a coordinate table / object from the lua stack. More...
 
void parseOptions (lua_State *L, int stackPos, Options &opt)
 Aux function to parse print options for the valueStr() call if the object at stackPos is a table.
 
void pushResult (lua_State *L, const double *val)
 Pushes an accessor result on the stack. Value can be pushed as a number (scalar) or as a matrix.
 
- Protected Member Functions inherited from GmLuaObject
 GmLuaObject (const GmLogCategory &logger)
 Construtor protegido. Somente classes derivadas devem ser instanciadas.
 
virtual const char * typeName () const =0
 Returns the object type as will be stored in the object metatable.
 

Protected Attributes

T * _ac
 The wrapped value accessor object.
 
bool _owner
 Do we own the accessor?
 
- Protected Attributes inherited from GmLuaObject
const GmLogCategory_logger
 A logger used by the proxy when needed.
 
QAtomicInteger< int > _refCount
 Lua objects are reference counted to enable sharing them among different states. This is needed to allow for passing objects as parameters in a parallel call. The garbage collection method releases memory only for the last reference.
 

Private Member Functions

int size (lua_State *L)
 Returns the number of value 'lines' in this accessor.
 
int info (lua_State *L)
 Returns the info object for this accessor.
 
int isScalar (lua_State *L)
 Is this a scalar accessor? Returns true or false.
 
int unit (lua_State *L)
 Returns a string with the unit in which data is returned for this accessor.
 
int valueSize (lua_State *L)
 Returns the size of the value returned by the accessor.
 
int defValue (lua_State *L)
 Returns the default value converted to the accessor unit.
 

Detailed Description

template<class T>
class GmLuaAccessorBase< T >

A helper class for implementing the common behaviour between GmLuaValueAccessor, GmLuaCellAccessor, GmLuaGaussAccessor, GmLuaBoudaryConditionAccessor and GmLuaDiscontinuityAccessor.

Should not be instanced by user code. Although a template, its implementation is on the cpp file since all the needed specializations are known.

Constructor & Destructor Documentation

◆ GmLuaAccessorBase()

template<class T>
GmLuaAccessorBase< T >::GmLuaAccessorBase ( T *  ac,
const GmLogCategory logger,
bool  ownership 
)
protected

Constructor. Receives the ValueAccessor to be wrapped.

Due to its nature, by default, wrapped accessors WILL be DELETED together with the proxy. THIS IS A DIFFERENT BEHAVIOUR from other kinds of proxy Lua objects. That behaviour can be turned off by setting the ownership flag to false.

Member Function Documentation

◆ parseCoord()

template<class T >
void GmLuaAccessorBase< T >::parseCoord ( lua_State *  L,
int  stackPos,
QString  fname,
GmVector coord 
)
protected

An auxiliary function used to parse a coordinate table / object from the lua stack.

Parameter stackPos defines where on the Lua stack the values should be queried and fname is the name of the called function, used in error messages.

Results are retuned in the parameter coord. It should be passed as an EMPTY vector. If no coordinate was given, coord is left unchanged. On errors, this function calls luaL_error and does not return.


The documentation for this class was generated from the following files: