Botcraft 1.21.4
Loading...
Searching...
No Matches
Botcraft::NotifyOnEndUseRef< T > Class Template Reference

Wrapper around a reference that will run a callback on destruct. More...

#include <Blackboard.hpp>

Public Member Functions

 NotifyOnEndUseRef (T &r, const std::function< void()> &on_destruct_callback_)
 
 ~NotifyOnEndUseRef ()
 
T & ref () const &
 Reference getter.
 
T & ref () const &&=delete
 

Private Attributes

T & _ref
 
std::function< void()> on_destruct_callback
 

Detailed Description

template<typename T>
class Botcraft::NotifyOnEndUseRef< T >

Wrapper around a reference that will run a callback on destruct.

Template Parameters
TType of the reference

Definition at line 14 of file Blackboard.hpp.

Constructor & Destructor Documentation

◆ NotifyOnEndUseRef()

template<typename T >
Botcraft::NotifyOnEndUseRef< T >::NotifyOnEndUseRef ( T &  r,
const std::function< void()> &  on_destruct_callback_ 
)
inline

Definition at line 17 of file Blackboard.hpp.

◆ ~NotifyOnEndUseRef()

template<typename T >
Botcraft::NotifyOnEndUseRef< T >::~NotifyOnEndUseRef ( )
inline

Member Function Documentation

◆ ref() [1/2]

template<typename T >
T & Botcraft::NotifyOnEndUseRef< T >::ref ( ) const &
inline

Reference getter.

Only works on lvalue to prevent calling it on a temporary object (which would run the callback immediately instead of when going out of scope.

Returns
The wrapped reference

Definition at line 29 of file Blackboard.hpp.

References Botcraft::NotifyOnEndUseRef< T >::_ref.

◆ ref() [2/2]

template<typename T >
T & Botcraft::NotifyOnEndUseRef< T >::ref ( ) const &&
delete

Member Data Documentation

◆ _ref

template<typename T >
T& Botcraft::NotifyOnEndUseRef< T >::_ref
private

Definition at line 33 of file Blackboard.hpp.

Referenced by Botcraft::NotifyOnEndUseRef< T >::ref().

◆ on_destruct_callback

template<typename T >
std::function<void()> Botcraft::NotifyOnEndUseRef< T >::on_destruct_callback
private

Definition at line 34 of file Blackboard.hpp.

Referenced by Botcraft::NotifyOnEndUseRef< T >::~NotifyOnEndUseRef().


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