Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
AutoNotify Class Reference

This class sends a notification in its destructor. More...

#include <Notifiable.hxx>

Public Member Functions

 AutoNotify (Notifiable *n)
 Constructor.
 
 ~AutoNotify ()
 Destructor. Notifies the stored notifiable.
 
NotifiableTransfer ()
 Transfers the ownership of the notification; it will NOT be called in the destructor.
 

Private Attributes

Notifiablen_
 Stored notifiable to notify upon destruction.
 

Detailed Description

This class sends a notification in its destructor.

Use as RAII class:

bool DoFoo(Notifiable* done) { AutoNotify n(done); // ... doo stuuufff ... if (something_wrong) return false; // do more stuff return true; }

The notification will be called on all return statements.

Definition at line 273 of file Notifiable.hxx.

Constructor & Destructor Documentation

◆ AutoNotify()

AutoNotify::AutoNotify ( Notifiable n)
inline

Constructor.

Parameters
nNotifiable to notify when *this goes out of scope. May be null in which case nothing will be notified.

Definition at line 281 of file Notifiable.hxx.

◆ ~AutoNotify()

AutoNotify::~AutoNotify ( )
inline

Destructor. Notifies the stored notifiable.

Definition at line 287 of file Notifiable.hxx.

Member Function Documentation

◆ Transfer()

Notifiable * AutoNotify::Transfer ( )
inline

Transfers the ownership of the notification; it will NOT be called in the destructor.

The caller is now responsible for calling it.

Returns
the notification pointer stored in the constructor.

Definition at line 298 of file Notifiable.hxx.

Member Data Documentation

◆ n_

Notifiable* AutoNotify::n_
private

Stored notifiable to notify upon destruction.

Definition at line 307 of file Notifiable.hxx.


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