aGrUM 3.3.2
a C++ library for (probabilistic) graphical models
gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_ Class Reference

restores the state of the inference engine (see stateRestorer_) when destroyed More...

#include <graphicalModelInference.h>

Public Member Functions

 StateGuard_ (GraphicalModelInference< GUM_SCALAR > &inference)
 ~StateGuard_ () noexcept(false)
 StateGuard_ (const StateGuard_ &)=delete
StateGuard_ & operator= (const StateGuard_ &)=delete

Private Attributes

std::function< void() > _restore_
int _uncaught_exceptions_
 number of uncaught exceptions when the guard was created

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_

restores the state of the inference engine (see stateRestorer_) when destroyed

If the restoration throws while no exception is propagating, this exception is propagated. If the guard is destroyed during stack unwinding, the restoration is still attempted but its own exception (if any) is discarded: the original exception is propagated (a second exception would call std::terminate).

Definition at line 441 of file graphicalModelInference.h.

Constructor & Destructor Documentation

◆ StateGuard_() [1/2]

template<GUM_Numeric GUM_SCALAR>
gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::StateGuard_ ( GraphicalModelInference< GUM_SCALAR > & inference)
explicit

Definition at line 660 of file graphicalModelInference_tpl.h.

661 :
int _uncaught_exceptions_
number of uncaught exceptions when the guard was created
<agrum/base/graphicalModels/graphicalModel.h>
virtual std::function< void() > stateRestorer_()
Returns a function restoring the current state of the inference engine.

References gum::GraphicalModelInference< GUM_SCALAR >::GraphicalModelInference(), _restore_, _uncaught_exceptions_, and gum::GraphicalModelInference< GUM_SCALAR >::stateRestorer_().

Referenced by StateGuard_(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~StateGuard_()

template<GUM_Numeric GUM_SCALAR>
gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::~StateGuard_ ( )

Definition at line 665 of file graphicalModelInference_tpl.h.

665 {
667 // stack unwinding: a second exception would call std::terminate, the original one wins
668 try {
669 _restore_();
670 } catch (...) {}
671 } else {
672 _restore_();
673 }
674 }

References _restore_, and _uncaught_exceptions_.

◆ StateGuard_() [2/2]

template<GUM_Numeric GUM_SCALAR>
gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::StateGuard_ ( const StateGuard_ & )
delete

References StateGuard_().

Here is the call graph for this function:

Member Function Documentation

◆ operator=()

template<GUM_Numeric GUM_SCALAR>
StateGuard_ & gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::operator= ( const StateGuard_ & )
delete

References StateGuard_().

Here is the call graph for this function:

Member Data Documentation

◆ _restore_

template<GUM_Numeric GUM_SCALAR>
std::function< void() > gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::_restore_
private

Definition at line 450 of file graphicalModelInference.h.

Referenced by StateGuard_(), and ~StateGuard_().

◆ _uncaught_exceptions_

template<GUM_Numeric GUM_SCALAR>
int gum::GraphicalModelInference< GUM_SCALAR >::StateGuard_::_uncaught_exceptions_
private

number of uncaught exceptions when the guard was created

Definition at line 453 of file graphicalModelInference.h.

Referenced by StateGuard_(), and ~StateGuard_().


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