GemaLuaCoreLib
The GeMA Lua Core library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmLuaStateDump Class Reference

A proxy class to export GmStateDump methods to the Lua environment. More...

#include <gmLuaStateDump.h>

Inheritance diagram for GmLuaStateDump:
Inheritance graph
[legend]
Collaboration diagram for GmLuaStateDump:
Collaboration graph
[legend]

Public Member Functions

 GmLuaStateDump (GmStateDump *state, const GmLogCategory &logger, bool ownership=false)
 Constructor. Receives the StateDump to be wrapped.
 
virtual ~GmLuaStateDump ()
 Destructor.
 
virtual const char * typeName () const
 Returns the object type as will be stored in the object metatable.
 
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.
 
virtual void * getClassMetatableID ()
 Returns an unique identifier to identify an user object as a GmValueInfo object.
 
GmStateDumpstateDump () const
 Returns a pointer to the internal state dump object.
 
bool ownership () const
 Returns true if the state dump object is owned by the proxy object.
 
void takeOwnership ()
 Takes the state dump ownership from the proxy object.
 
- 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.
 

Private Member Functions

int addStateItem (lua_State *L)
 Adds either an accessor, a matrix, a set of Lua global/local variables or a Lua file handle to the dump state. More...
 
int addGroupItem (lua_State *L)
 Adds a supported plugin (process) handle (like a fem process) or a mesh to the dump state. More...
 
int itemGroup (lua_State *L)
 Returns the group id for the given item id.
 
int numItems (lua_State *L)
 Returns the number of items added to the state.
 
int findItem (lua_State *L)
 Finds th item id of the named item. Can restrict the search by providing optional type masks, group id or start position. Returns nil if the item was not found. The search string CAN be a regular expression understood by QRegExp.
 
int setGroupActive (lua_State *L)
 Marks the items of the given group as active/inactive. A group id of -1 affects every group.
 
int init (lua_State *L)
 Initializes the state dump after all items have been added. Returns true on success.
 
int save (lua_State *L)
 Saves all the dump items. Returns true on success.
 
int load (lua_State *L)
 Loads all the dump items. Returns true on success.
 
int saveItem (lua_State *L)
 Saves data for a single dump item. Receives on the stack the item id + optional sizes and offset. Returns true on success.
 
int loadItem (lua_State *L)
 Loads data for a single dump item. Receives on the stack the item id + optional sizes and offset. Returns true on success.
 
int saveActiveGroups (lua_State *L)
 Saves the set of active dump items. Returns true on success.
 
int loadActiveGroups (lua_State *L)
 Loads the set of active dump items. Returns true on success.
 
int flush (lua_State *L)
 Flushes data to the dump file. Usefull only after calls to saveItem()
 
int clear (lua_State *L)
 Releases dump memory when dumping to memory.
 

Private Attributes

GmStateDump_state
 The wrapped state dump object.
 
bool _ownsState
 Are we the owner of _state?
 

Additional Inherited Members

- Protected Member Functions inherited from GmLuaObject
 GmLuaObject (const GmLogCategory &logger)
 Construtor protegido. Somente classes derivadas devem ser instanciadas.
 
- 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.
 

Detailed Description

A proxy class to export GmStateDump methods to the Lua environment.

Member Function Documentation

◆ addGroupItem()

int GmLuaStateDump::addGroupItem ( lua_State *  L)
private

Adds a supported plugin (process) handle (like a fem process) or a mesh to the dump state.

Accepts as parameters the object plus an optional groupId parameter. Returns the added items group id or nil on error.

◆ addStateItem()

int GmLuaStateDump::addStateItem ( lua_State *  L)
private

Adds either an accessor, a matrix, a set of Lua global/local variables or a Lua file handle to the dump state.

For the accessor option, accepts as parameters the object plus the associated mesh plus an optional fixed hint. For the matrix option, accepts the object plus an optional fixed hint. For the Lua object option, the parameters should be a Lua table with the name of the global variables, followed by another optional table with the name of local variables (all of them should be in scope when save() is called) followed by an optional string with the name of the global table that will be used as temporary storage on saving and as the place for loading local variable values on loading. For the Lua file handle option, parameters should be an io file handle, the base file name and an optional temp file name.

For all the options, an additional groupId parameter can be given (in that case, other optional parameters must be given).

Returns the added item id. On error adding the item, returns nil.


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