Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ScriptLockPasser< LockType > Class Template Reference

Class for Scripts to receive and pass on references to locks in native or script stacks. More...

#include <ScriptLock.h>

+ Inheritance diagram for Leviathan::ScriptLockPasser< LockType >:

Public Member Functions

DLLEXPORT ScriptLockPasser (LockType &objectsguard)
 
DLLEXPORT ScriptLockPasser ()
 Creates a passer that doesn't have a lock. More...
 
DLLEXPORT ~ScriptLockPasser ()
 
DLLEXPORT auto GetLock ()
 Returns a reference to held lock. More...
 
DLLEXPORT void MakeInvalid ()
 Makes this invalid. More...
 
- Public Member Functions inherited from Leviathan::ReferenceCounted
 ReferenceCounted (const ReferenceCounted &other)=delete
 
ReferenceCountedoperator= (const ReferenceCounted &other)=delete
 
FORCE_INLINE void AddRef ()
 
FORCE_INLINE void Release ()
 removes a reference and deletes the object if reference count reaches zero More...
 
int32_t GetRefCount () const
 Returns the reference count. More...
 

Additional Inherited Members

- Public Types inherited from Leviathan::ReferenceCounted
using basepointer = boost::intrusive_ptr< ReferenceCounted >
 
using refcountedpointer = boost::intrusive_ptr< ReferenceCounted >
 
- Static Public Member Functions inherited from Leviathan::ReferenceCounted
template<class ActualType >
static boost::intrusive_ptr< ActualType > WrapPtr (ActualType *ptr)
 Creates an intrusive_ptr from raw pointer. More...
 
template<class ActualType , class... Args>
static boost::intrusive_ptr< ActualType > MakeShared (Args &&... args)
 Constructs a new instance and wraps it. More...
 
- Protected Member Functions inherited from Leviathan::ReferenceCounted
DLLEXPORT ReferenceCounted ()
 
virtual DLLEXPORT ~ReferenceCounted ()
 

Detailed Description

template<class LockType>
class Leviathan::ScriptLockPasser< LockType >

Class for Scripts to receive and pass on references to locks in native or script stacks.

Definition at line 13 of file ScriptLock.h.

Constructor & Destructor Documentation

◆ ScriptLockPasser() [1/2]

template<class LockType >
DLLEXPORT Leviathan::ScriptLockPasser< LockType >::ScriptLockPasser ( LockType &  objectsguard)
inline

Definition at line 16 of file ScriptLock.h.

16  : OurLockPtr(&objectsguard){
17 
18 
19  }

◆ ScriptLockPasser() [2/2]

template<class LockType >
DLLEXPORT Leviathan::ScriptLockPasser< LockType >::ScriptLockPasser ( )
inline

Creates a passer that doesn't have a lock.

Definition at line 22 of file ScriptLock.h.

22  : OurLockPtr(nullptr){
23 
24  }

◆ ~ScriptLockPasser()

template<class LockType >
DLLEXPORT Leviathan::ScriptLockPasser< LockType >::~ScriptLockPasser ( )
inline

Definition at line 26 of file ScriptLock.h.

26  {
27 
28  OurLockPtr = nullptr;
29  }

Member Function Documentation

◆ GetLock()

template<class LockType >
DLLEXPORT auto Leviathan::ScriptLockPasser< LockType >::GetLock ( )
inline

Returns a reference to held lock.

Exceptions
InvalidStateif this object doesn't hold a reference to a lock

Calling this while MakeInvalid is called or this is being destructed is invalid

Definition at line 35 of file ScriptLock.h.

35  {
36 
37  auto ptr = OurLockPtr;
38  if(!ptr)
39  throw InvalidState("ScriptLockPasser doesn't have a lock pointer");
40 
41  return std::move(*ptr);
42  }

◆ MakeInvalid()

template<class LockType >
DLLEXPORT void Leviathan::ScriptLockPasser< LockType >::MakeInvalid ( )
inline

Makes this invalid.

Call before destructing the lock to which OurLockPtr points to

Definition at line 47 of file ScriptLock.h.

47  {
48 
49  OurLockPtr = nullptr;
50  }

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