#include <activebackup.hh>
Public Member Functions | |
ActiveBackup () | |
T * | Active () |
T * | Backup () |
void | Switch () |
T * | operator-> () |
T & | operator * () |
Public Attributes | |
T * | mpActive |
pointer to active object | |
T * | mpBackup |
pointer to backup object | |
Private Attributes | |
T | mObject1 |
object 1 | |
T | mObject2 |
object 2 |
Implements Active/Backup object switcher. The class holds 2 instances of T, one of them being active, other one backup. It is possible to switch between those two. This class can be used in situations where two copies of an object are necessary, one being used, other one being prepared and vice versa.
Maybe this pattern has a name, but I don't know that.
nnl::ActiveBackup< T >::ActiveBackup | ( | ) | [inline] |
Constructor.
T* nnl::ActiveBackup< T >::Active | ( | ) | [inline] |
Get active object.
T* nnl::ActiveBackup< T >::Backup | ( | ) | [inline] |
Get backup object.
T& nnl::ActiveBackup< T >::operator * | ( | ) | [inline] |
Get active object and dereference it.
T* nnl::ActiveBackup< T >::operator-> | ( | ) | [inline] |
Get active object.
void nnl::ActiveBackup< T >::Switch | ( | ) | [inline] |
Switch active to backup and vv.