|
VR-Engage
2.2
|
This class creates and manages references to Lua objects in the Lua registry. It provides reference counting to ensure objects are properly cleaned up when they are no longer needed by any C++ code.
#include <luaReference.h>
Public Member Functions | |
| DtLuaReference (lua_State &s, int index) | |
| ~DtLuaReference () | |
| int | value () |
| void | inc () |
| void | dec () |
Private Member Functions | |
| DtLuaReference (const DtLuaReference &src) | |
| const DtLuaReference & | operator= (const DtLuaReference &src) |
Private Attributes | |
| lua_State & | myState |
| int | myRefCount |
| int | myRef |
| makVre::DtLuaReference::DtLuaReference | ( | lua_State & | s, |
| int | index ) |
Constructor that creates a reference to a Lua object.
| s | The Lua state containing the object |
| index | Index of the object on the Lua stack to reference |
Creates a new reference to the Lua object at the given stack index and stores it in the Lua registry.
Referenced by DtLuaReference(), and operator=().
| makVre::DtLuaReference::~DtLuaReference | ( | ) |
Destructor.
Removes the reference from the Lua registry if this is the last C++ object referring to it.
|
private |
Copy constructor (private, not implemented)
References should not be copied directly; instead, increment the reference count.
References DtLuaReference().
|
inline |
Gets the Lua registry reference value.
References myRef.
|
inline |
Increments the reference count.
Called when another C++ object starts using this reference.
References myRefCount.
| void makVre::DtLuaReference::dec | ( | ) |
Decrements the reference count.
Called when a C++ object stops using this reference. If the reference count reaches zero, the Lua reference is released.
|
private |
Assignment operator (private, not implemented)
References should not be assigned directly; instead, use reference counting.
References DtLuaReference().
|
private |
Reference to the Lua state.
|
private |
Number of C++ objects using this reference.
Referenced by inc().
|
private |
The actual reference value in the Lua registry.
Referenced by value().