Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Private Types | List of all members
cLuaState::cOptionalCallback Class Reference

Same thing as cCallback, but GetStackValue() won't fail if the callback value is nil. More...

#include <LuaState.h>

Inheritance diagram for cLuaState::cOptionalCallback:
Inheritance graph
[legend]
Collaboration diagram for cLuaState::cOptionalCallback:
Collaboration graph
[legend]

Public Member Functions

 cOptionalCallback (void)
 
bool RefStack (cLuaState &a_LuaState, int a_StackPos)
 Set the contained callback to the function in the specified Lua state's stack position. More...
 
- Public Member Functions inherited from cLuaState::cCallback
template<typename... Args>
bool Call (Args &&... args)
 Calls the Lua callback, if still available. More...
 
 cCallback (void)
 
bool RefStack (cLuaState &a_LuaState, int a_StackPos)
 Set the contained callback to the function in the specified Lua state's stack position. More...
 
- Public Member Functions inherited from cLuaState::cTrackedRef
void Clear (void)
 Frees the contained reference, if any. More...
 
 cTrackedRef (void)
 Creates an unbound ref instance. More...
 
bool IsSameLuaState (cLuaState &a_LuaState)
 Returns true if the reference resides in the specified Lua state. More...
 
bool IsValid (void)
 Returns true if the contained reference is valid. More...
 
bool RefStack (cLuaState &a_LuaState, int a_StackPos)
 Set the contained reference to the object at the specified Lua state's stack position. More...
 
 ~cTrackedRef ()
 

Protected Member Functions

 cOptionalCallback (const cOptionalCallback &)=delete
 This class cannot be copied, because it is tracked in the LuaState by-ptr. More...
 
 cOptionalCallback (cOptionalCallback &&)=delete
 This class cannot be moved, because it is tracked in the LuaState by-ptr. More...
 
- Protected Member Functions inherited from cLuaState::cCallback
 cCallback (cCallback &&)=delete
 This class cannot be moved, because it is tracked in the LuaState by-ptr. More...
 
 cCallback (const cCallback &)=delete
 This class cannot be copied, because it is tracked in the LuaState by-ptr. More...
 
- Protected Member Functions inherited from cLuaState::cTrackedRef
 cTrackedRef (const cTrackedRef &)=delete
 This class cannot be copied, because it is tracked in the LuaState by-ptr. More...
 
 cTrackedRef (cTrackedRef &&)=delete
 This class cannot be moved, because it is tracked in the LuaState by-ptr. More...
 
cRefGetRef ()
 Returns the internal reference. More...
 
void Invalidate (void)
 Invalidates the callback, without untracking it from the cLuaState. More...
 

Private Types

using Super = cCallback
 

Additional Inherited Members

- Protected Attributes inherited from cLuaState::cTrackedRef
std::atomic< cCriticalSection * > m_CS
 The mutex protecting m_Ref against multithreaded access. More...
 
cRef m_Ref
 Reference to the Lua callback. More...
 

Detailed Description

Same thing as cCallback, but GetStackValue() won't fail if the callback value is nil.

Used for callbacks that are optional - they needn't be present and in such a case they won't get called.

Definition at line 332 of file LuaState.h.

Member Typedef Documentation

◆ Super

Definition at line 335 of file LuaState.h.

Constructor & Destructor Documentation

◆ cOptionalCallback() [1/3]

cLuaState::cOptionalCallback::cOptionalCallback ( void  )
inline

Definition at line 339 of file LuaState.h.

◆ cOptionalCallback() [2/3]

cLuaState::cOptionalCallback::cOptionalCallback ( const cOptionalCallback )
protecteddelete

This class cannot be copied, because it is tracked in the LuaState by-ptr.

Use cCallbackPtr for a copyable object.

◆ cOptionalCallback() [3/3]

cLuaState::cOptionalCallback::cOptionalCallback ( cOptionalCallback &&  )
protecteddelete

This class cannot be moved, because it is tracked in the LuaState by-ptr.

Use cCallbackPtr for a copyable object.

Member Function Documentation

◆ RefStack()

bool cLuaState::cOptionalCallback::RefStack ( cLuaState a_LuaState,
int  a_StackPos 
)

Set the contained callback to the function in the specified Lua state's stack position.

If a callback has been previously contained, it is unreferenced first. Returns true on success, false on failure (not a function at the specified stack pos).

Definition at line 337 of file LuaState.cpp.


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