SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A return value for methods that need to indicate both success/failure and modification/stasis. More...
#include <Status.h>
Public Member Functions | |
Status (const Status &)=default | |
Status (Status &&)=default | |
Status & | operator= (const Status &)=default |
bool | success () const |
Return whether or not a method succeeded (true) or not (false). | |
bool | modified () const |
Return whether a method modified its object (true) or not (false). | |
bool | markModified () |
Mark the Status to indicate an object was modified. | |
bool | markFailed () |
Mark the Status to indicate a method failed. | |
Status & | operator&= (const Status &other) |
Combine this status object with another instance. More... | |
operator bool () const | |
Protected Attributes | |
bool | m_success { true } |
bool | m_modified { false } |
A return value for methods that need to indicate both success/failure and modification/stasis.
This convenience class provides a default cast to a boolean that returns whether the method succeeded; this way it is backwards compatible with any API that previously returned a success/failure boolean.
Upon construction, a Status object indicates success without modification. You may then mark whether failure or modification occurred.
Combine this status object with another instance.
This AND-s the success bits together (both must succeed for either to succeed) while OR-ing the modified bits together (if either is modified, the result is).