Drake
Drake C++ Documentation
EventStatus Class Reference

Detailed Description

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 SystemBasesystem () 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...
 
EventStatusKeepMoreSevere (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
 
EventStatusoperator= (const EventStatus &)=default
 
 EventStatus (EventStatus &&)=default
 
EventStatusoperator= (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...
 

Member Enumeration Documentation

◆ Severity

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).

Constructor & Destructor Documentation

◆ EventStatus() [1/2]

EventStatus ( const EventStatus )
default

◆ EventStatus() [2/2]

EventStatus ( EventStatus &&  )
default

Member Function Documentation

◆ did_nothing()

bool did_nothing ( ) const

Returns true if the status is DidNothing.

◆ DidNothing()

static EventStatus DidNothing ( )
static

Returns "did nothing" status, with no message.

◆ Failed()

static EventStatus Failed ( const SystemBase system,
std::string  message 
)
static

Returns "failed" status, with a message explaining why.

◆ failed()

bool failed ( ) const

Returns true if the status is Failed.

There will also be a message() with more detail.

◆ KeepMoreSevere()

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.

◆ message()

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.

◆ operator=() [1/2]

EventStatus& operator= ( const EventStatus )
default

◆ operator=() [2/2]

EventStatus& operator= ( EventStatus &&  )
default

◆ reached_termination()

bool reached_termination ( ) const

Returns true if the status is ReachedTermination.

There will also be a message() with more detail.

◆ ReachedTermination()

static EventStatus ReachedTermination ( const SystemBase system,
std::string  message 
)
static

Returns "reached termination" status, with a message explaining why.

◆ severity()

Severity severity ( ) const

Returns the severity of the current status.

◆ Succeeded()

static EventStatus Succeeded ( )
static

Returns "succeeded" status, with no message.

◆ succeeded()

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.

◆ system()

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.

◆ ThrowOnFailure()

void ThrowOnFailure ( const char *  function_name) const

If failed(), throws an std::exception with a human-readable message.

Parameters
function_nameThe name of the user-callable API that encountered the failure. Don't include "()".

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