Python YASMIN (Yet Another State MachINe)
Loading...
Searching...
No Matches
yasmin.cb_state.CbState Class Reference
Inheritance diagram for yasmin.cb_state.CbState:
Collaboration diagram for yasmin.cb_state.CbState:

Public Member Functions

None __init__ (self, Set[str] outcomes, Callable cb)
 
str execute (self, Blackboard blackboard)
 
- Public Member Functions inherited from yasmin.state.State
str __call__ (self, Blackboard blackboard=None)
 
str __str__ (self)
 
None cancel_state (self)
 
bool is_canceled (self)
 
bool is_running (self)
 
Set[str] get_outcomes (self)
 

Protected Attributes

Callable _cb = cb
 A callable that will be invoked when the state is executed.
 
- Protected Attributes inherited from yasmin.state.State
Set _outcomes = set()
 A set of valid outcomes for this state.
 
bool _running = False
 A flag indicating whether the state is currently running.
 
bool _canceled = False
 A flag indicating whether the state has been canceled.
 

Detailed Description

CbState is a subclass of State that encapsulates a callback function
which can be executed in response to a specific state.

Attributes:
    _cb (Callable): A callback function that defines the action to take
                    when the state is executed.

Parameters:
    outcomes (Set[str]): A set of possible outcomes for this state.
    cb (Callable): A callable that will be invoked when the state is executed.

Constructor & Destructor Documentation

◆ __init__()

None yasmin.cb_state.CbState.__init__ ( self,
Set[str] outcomes,
Callable cb )
Initializes a new instance of CbState.

Args:
    outcomes (Set[str]): A set of possible outcomes for this state.
    cb (Callable): A callable that defines the action to take when
                   the state is executed.

Raises:
    TypeError: If 'outcomes' is not a set or 'cb' is not callable.

Reimplemented from yasmin.state.State.

Member Function Documentation

◆ execute()

str yasmin.cb_state.CbState.execute ( self,
Blackboard blackboard )
Executes the callback function with the provided blackboard context.

Args:
    blackboard: The context in which the callback will be executed.
                This is typically an object that holds the necessary
                state or data for the callback.

Returns:
    str: The result of the callback function execution.

Raises:
    Exception: Propagates any exceptions raised by the callback function.

Reimplemented from yasmin.state.State.

Member Data Documentation

◆ _cb

Callable yasmin.cb_state.CbState._cb = cb
protected

A callable that will be invoked when the state is executed.


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