|
Open Model Railroad Network (OpenMRN)
|
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. | |
| Notifiable * | Transfer () |
| Transfers the ownership of the notification; it will NOT be called in the destructor. | |
Private Attributes | |
| Notifiable * | n_ |
| Stored notifiable to notify upon destruction. | |
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.
|
inline |
Constructor.
| n | Notifiable 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.
|
inline |
Destructor. Notifies the stored notifiable.
Definition at line 287 of file Notifiable.hxx.
|
inline |
Transfers the ownership of the notification; it will NOT be called in the destructor.
The caller is now responsible for calling it.
Definition at line 298 of file Notifiable.hxx.
|
private |
Stored notifiable to notify upon destruction.
Definition at line 307 of file Notifiable.hxx.