Opm::GenericGuard< Callback > Class Template Reference

A simple class which makes sure that a cleanup function is called once the object is destroyed. More...

#include <genericguard.hh>

Public Member Functions

 GenericGuard (Callback &callback)
 
 GenericGuard (GenericGuard &&other)
 
 GenericGuard (const GenericGuard &other)=delete
 
 ~GenericGuard ()
 
void setEnabled (bool value)
 Specify whether the guard object is "on duty" or not. More...
 
bool enabled () const
 Returns whether the guard object is "on duty" or not. More...
 

Detailed Description

template<class Callback>
class Opm::GenericGuard< Callback >

A simple class which makes sure that a cleanup function is called once the object is destroyed.

This class is particularly useful in conjunction with lambdas for code that might throw exceptions.

Constructor & Destructor Documentation

◆ GenericGuard() [1/3]

template<class Callback >
Opm::GenericGuard< Callback >::GenericGuard ( Callback &  callback)
inline

◆ GenericGuard() [2/3]

template<class Callback >
Opm::GenericGuard< Callback >::GenericGuard ( GenericGuard< Callback > &&  other)
inline

◆ GenericGuard() [3/3]

template<class Callback >
Opm::GenericGuard< Callback >::GenericGuard ( const GenericGuard< Callback > &  other)
delete

◆ ~GenericGuard()

template<class Callback >
Opm::GenericGuard< Callback >::~GenericGuard ( )
inline

Member Function Documentation

◆ enabled()

template<class Callback >
bool Opm::GenericGuard< Callback >::enabled ( ) const
inline

Returns whether the guard object is "on duty" or not.

◆ setEnabled()

template<class Callback >
void Opm::GenericGuard< Callback >::setEnabled ( bool  value)
inline

Specify whether the guard object is "on duty" or not.

If the guard object is destroyed while it is "off-duty", the cleanup callback is not called. At construction, guards are on duty.


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