VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtLuaReference Class Reference

Detailed Description

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 DtLuaReferenceoperator= (const DtLuaReference &src)
 

Private Attributes

lua_State & myState
 
int myRefCount
 
int myRef
 

Constructor & Destructor Documentation

◆ DtLuaReference() [1/2]

makVre::DtLuaReference::DtLuaReference ( lua_State & s,
int index )

Constructor that creates a reference to a Lua object.

Parameters
sThe Lua state containing the object
indexIndex 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=().

◆ ~DtLuaReference()

makVre::DtLuaReference::~DtLuaReference ( )

Destructor.

Removes the reference from the Lua registry if this is the last C++ object referring to it.

◆ DtLuaReference() [2/2]

makVre::DtLuaReference::DtLuaReference ( const DtLuaReference & src)
private

Copy constructor (private, not implemented)

References should not be copied directly; instead, increment the reference count.

References DtLuaReference().

Member Function Documentation

◆ value()

int makVre::DtLuaReference::value ( )
inline

Gets the Lua registry reference value.

Returns
The reference value in the Lua registry

References myRef.

◆ inc()

void makVre::DtLuaReference::inc ( )
inline

Increments the reference count.

Called when another C++ object starts using this reference.

References myRefCount.

◆ dec()

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.

◆ operator=()

const DtLuaReference & makVre::DtLuaReference::operator= ( const DtLuaReference & src)
private

Assignment operator (private, not implemented)

References should not be assigned directly; instead, use reference counting.

References DtLuaReference().

Member Data Documentation

◆ myState

lua_State& makVre::DtLuaReference::myState
private

Reference to the Lua state.

◆ myRefCount

int makVre::DtLuaReference::myRefCount
private

Number of C++ objects using this reference.

Referenced by inc().

◆ myRef

int makVre::DtLuaReference::myRef
private

The actual reference value in the Lua registry.

Referenced by value().


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