roboligo
Loading...
Searching...
No Matches
roboligo::Trigger Class Reference

Represents a trigger that can transition between different modes in a state machine. More...

#include <Trigger.hpp>

Collaboration diagram for roboligo::Trigger:

Public Member Functions

void execute (void)
 Executes the trigger and invokes its registered callback.
std::string get_name (void)
 Gets the name of the trigger.
std::string get_value (void)
 Gets the value of the trigger.
bool is_available (void)
 Checks if the trigger is available for execution.
void register_callback (const std::function< void()> &callback)
 Registers a callback function to be executed when the trigger fires.
void set_name (std::string new_name)
 Sets a new name for the trigger.
void set_next_modes (std::vector< Mode > modes)
 Sets the next modes for this trigger.
void set_previous_modes (std::vector< Mode > modes)
 Sets the previous modes for this trigger.
void set_value (std::string new_value)
 Sets a new value for the trigger.
 Trigger (std::string name, std::string value, std::vector< Mode > previous, std::vector< Mode > next)
 Constructor for Trigger.
virtual ~Trigger ()=default
 Destructor.

Public Attributes

std::function< void()> cb
 Callback function.

Protected Attributes

bool available_ {false}
 If trigger is available.
std::string name_
 Trigger name.
std::vector< Modenext_
 Vector of next modes.
std::vector< Modeprevious_
 Vector of previous modes.
std::string value_
 Value for the trigger.

Detailed Description

Represents a trigger that can transition between different modes in a state machine.

A Trigger encapsulates the logic for transitioning from one or more previous modes to one or more next modes. It supports callbacks and maintains availability status.

Constructor & Destructor Documentation

◆ Trigger()

roboligo::Trigger::Trigger ( std::string name,
std::string value,
std::vector< Mode > previous,
std::vector< Mode > next )
inline

Constructor for Trigger.

Parameters
nameThe name identifier of the trigger.
valueThe value associated with the trigger.
previousVector of modes that precede this trigger.
nextVector of modes that follow this trigger.

◆ ~Trigger()

virtual roboligo::Trigger::~Trigger ( )
virtualdefault

Destructor.

Member Function Documentation

◆ execute()

void roboligo::Trigger::execute ( void )

Executes the trigger and invokes its registered callback.

◆ get_name()

std::string roboligo::Trigger::get_name ( void )

Gets the name of the trigger.

Returns
The trigger's name as a string.

◆ get_value()

std::string roboligo::Trigger::get_value ( void )

Gets the value of the trigger.

Returns
The trigger's value as a string.

◆ is_available()

bool roboligo::Trigger::is_available ( void )

Checks if the trigger is available for execution.

Returns
True if the trigger is available, false otherwise.

◆ register_callback()

void roboligo::Trigger::register_callback ( const std::function< void()> & callback)

Registers a callback function to be executed when the trigger fires.

Parameters
callbackThe callback function to register.

◆ set_name()

void roboligo::Trigger::set_name ( std::string new_name)

Sets a new name for the trigger.

Parameters
new_nameThe new name to assign.

◆ set_next_modes()

void roboligo::Trigger::set_next_modes ( std::vector< Mode > modes)

Sets the next modes for this trigger.

Parameters
modesVector of modes to set as next.

◆ set_previous_modes()

void roboligo::Trigger::set_previous_modes ( std::vector< Mode > modes)

Sets the previous modes for this trigger.

Parameters
modesVector of modes to set as previous.

◆ set_value()

void roboligo::Trigger::set_value ( std::string new_value)

Sets a new value for the trigger.

Parameters
new_valueThe new value to assign.

Member Data Documentation

◆ available_

bool roboligo::Trigger::available_ {false}
protected

If trigger is available.

◆ cb

std::function<void()> roboligo::Trigger::cb

Callback function.

◆ name_

std::string roboligo::Trigger::name_
protected

Trigger name.

◆ next_

std::vector<Mode> roboligo::Trigger::next_
protected

Vector of next modes.

◆ previous_

std::vector<Mode> roboligo::Trigger::previous_
protected

Vector of previous modes.

◆ value_

std::string roboligo::Trigger::value_
protected

Value for the trigger.


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