The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
attack_type::recursion_guard Class Reference

Helper similar to std::unique_lock for detecting when calculations such as has_special have entered infinite recursion. More...

#include <attack_type.hpp>

Public Member Functions

 recursion_guard ()
 Construct an empty instance, only useful for extending the lifetime of a recursion_guard returned from weapon.update_variables_recursion() by std::moving it to an instance declared in a larger scope. More...
 
 operator bool () const
 Returns true if a level of recursion was available at the time when update_variables_recursion() created this object. More...
 
 recursion_guard (recursion_guard &&other)
 
 recursion_guard (const recursion_guard &other)=delete
 
recursion_guardoperator= (recursion_guard &&)
 
recursion_guardoperator= (const recursion_guard &)=delete
 
 ~recursion_guard ()
 

Private Member Functions

 recursion_guard (const attack_type &weapon, const config &special)
 Only expected to be called in update_variables_recursion(), which handles some of the checks. More...
 

Private Attributes

std::shared_ptr< const attack_typeparent
 

Friends

class attack_type
 

Detailed Description

Helper similar to std::unique_lock for detecting when calculations such as has_special have entered infinite recursion.

This assumes that there's only a single thread accessing the attack_type, it's a lightweight increment/decrement counter rather than a mutex.

Definition at line 183 of file attack_type.hpp.

Constructor & Destructor Documentation

◆ recursion_guard() [1/4]

attack_type::recursion_guard::recursion_guard ( const attack_type weapon,
const config special 
)
explicitprivate

Only expected to be called in update_variables_recursion(), which handles some of the checks.

Definition at line 684 of file attack_type.cpp.

References parent.

◆ recursion_guard() [2/4]

attack_type::recursion_guard::recursion_guard ( )
explicitdefault

Construct an empty instance, only useful for extending the lifetime of a recursion_guard returned from weapon.update_variables_recursion() by std::moving it to an instance declared in a larger scope.

◆ recursion_guard() [3/4]

attack_type::recursion_guard::recursion_guard ( attack_type::recursion_guard &&  other)

Definition at line 690 of file attack_type.cpp.

References swap().

◆ recursion_guard() [4/4]

attack_type::recursion_guard::recursion_guard ( const recursion_guard other)
delete

◆ ~recursion_guard()

attack_type::recursion_guard::~recursion_guard ( )

Definition at line 710 of file attack_type.cpp.

Member Function Documentation

◆ operator bool()

attack_type::recursion_guard::operator bool ( ) const

Returns true if a level of recursion was available at the time when update_variables_recursion() created this object.

Definition at line 695 of file attack_type.cpp.

◆ operator=() [1/2]

recursion_guard& attack_type::recursion_guard::operator= ( const recursion_guard )
delete

◆ operator=() [2/2]

attack_type::recursion_guard & attack_type::recursion_guard::operator= ( attack_type::recursion_guard &&  other)

Definition at line 699 of file attack_type.cpp.

References swap().

Friends And Related Function Documentation

◆ attack_type

friend class attack_type
friend

Definition at line 184 of file attack_type.hpp.

Member Data Documentation

◆ parent

std::shared_ptr<const attack_type> attack_type::recursion_guard::parent
private

Definition at line 209 of file attack_type.hpp.

Referenced by recursion_guard().


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