Holds the return status from execution of an event handler function, or the effective status after a series of handler executions due to dispatching of simultaneous events.
Drake API users will typically use only the four factory methods below to return status, and optionally a human-readable message, from their event handlers.
#include <drake/systems/framework/event_status.h>
Public Types | |
enum | Severity { kDidNothing = 0, kSucceeded = 1, kReachedTermination = 2, kFailed = 3 } |
The numerical values are ordered, with did_nothing < success < terminate < fatal. More... | |
Public Member Functions | |
bool | did_nothing () const |
Returns true if the status is DidNothing. More... | |
bool | succeeded () const |
Returns true if the status is Succeeded. More... | |
bool | reached_termination () const |
Returns true if the status is ReachedTermination. More... | |
bool | failed () const |
Returns true if the status is Failed. More... | |
Severity | severity () const |
Returns the severity of the current status. More... | |
const SystemBase * | system () const |
Returns the optionally-provided subsystem that generated a status return that can include a message (reached termination or failed). More... | |
const std::string & | message () const |
Returns the optionally-provided human-readable message supplied by the event handler that produced the current status. More... | |
void | ThrowOnFailure (const char *function_name) const |
If failed(), throws an std::exception with a human-readable message. More... | |
EventStatus & | KeepMoreSevere (EventStatus candidate) |
(Advanced) Replaces the contents of this with the more-severe status if candidate is a more severe status than this one. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
EventStatus (const EventStatus &)=default | |
EventStatus & | operator= (const EventStatus &)=default |
EventStatus (EventStatus &&)=default | |
EventStatus & | operator= (EventStatus &&)=default |
Static Public Member Functions | |
static EventStatus | DidNothing () |
Returns "did nothing" status, with no message. More... | |
static EventStatus | Succeeded () |
Returns "succeeded" status, with no message. More... | |
static EventStatus | ReachedTermination (const SystemBase *system, std::string message) |
Returns "reached termination" status, with a message explaining why. More... | |
static EventStatus | Failed (const SystemBase *system, std::string message) |
Returns "failed" status, with a message explaining why. More... | |
enum Severity |
The numerical values are ordered, with did_nothing < success < terminate < fatal.
Enumerator | |
---|---|
kDidNothing | Successful, but nothing happened; no state update needed. |
kSucceeded | Handler executed successfully; state may have been updated. |
kReachedTermination | Handler succeeded but detected a normal termination condition (has message). Intended primarily for internal use by the Simulator. |
kFailed | Handler was unable to perform its job (has message). |
|
default |
|
default |
bool did_nothing | ( | ) | const |
Returns true
if the status is DidNothing.
|
static |
Returns "did nothing" status, with no message.
|
static |
Returns "failed" status, with a message explaining why.
bool failed | ( | ) | const |
Returns true
if the status is Failed.
There will also be a message() with more detail.
EventStatus& KeepMoreSevere | ( | EventStatus | candidate | ) |
(Advanced) Replaces the contents of this
with the more-severe status if candidate
is a more severe status than this
one.
Does nothing if candidate
severity is less than or equal to this
severity. This method is for use in event dispatchers for accumulating status returns from a series of event handlers for a set of simultaneous events.
const std::string& message | ( | ) | const |
Returns the optionally-provided human-readable message supplied by the event handler that produced the current status.
Returns an empty string if no message was provided.
|
default |
|
default |
bool reached_termination | ( | ) | const |
Returns true
if the status is ReachedTermination.
There will also be a message() with more detail.
|
static |
Returns "reached termination" status, with a message explaining why.
Severity severity | ( | ) | const |
Returns the severity of the current status.
|
static |
Returns "succeeded" status, with no message.
bool succeeded | ( | ) | const |
Returns true
if the status is Succeeded.
"Did nothing" can also be viewed as successful but you have to check for that separately.
const SystemBase* system | ( | ) | const |
Returns the optionally-provided subsystem that generated a status return that can include a message (reached termination or failed).
Returns nullptr if no subsystem was provided.
void ThrowOnFailure | ( | const char * | function_name | ) | const |
If failed(), throws an std::exception with a human-readable message.
function_name | The name of the user-callable API that encountered the failure. Don't include "()". |