Antkeeper  0.0.1
Public Types | Public Member Functions | List of all members
input::action Class Reference

Evaluates an activation state given input values and publishes events on activation state changes. More...

#include <action.hpp>

Public Types

using threshold_function_type = std::function< bool(float)>
 Threshold function type. More...
 

Public Member Functions

 action ()
 Constructs an action. More...
 
void set_threshold_function (const threshold_function_type &function) noexcept
 Sets the threshold function. More...
 
void evaluate (float value)
 Evaluates the activation state of the action, according to its threshold function and an input value. More...
 
void update () const
 Publishes an action active event if the action is active. More...
 
void reset () noexcept
 Resets the activation state of the action without publishing any events. More...
 
const threshold_function_typeget_threshold_function () const noexcept
 Returns the threshold function. More...
 
bool is_active () const noexcept
 Returns true if the action is active, false otherwise. More...
 
float get_input_value () const noexcept
 Returns the most recently evaluated input value. More...
 
::event::channel< action_activated_event > & get_activated_channel () noexcept
 Returns the channel through which action activated events are published. More...
 
::event::channel< action_active_event > & get_active_channel () noexcept
 Returns the channel through which action active events are published. More...
 
::event::channel< action_deactivated_event > & get_deactivated_channel () noexcept
 Returns the channel through which action deactivated events are published. More...
 

Detailed Description

Evaluates an activation state given input values and publishes events on activation state changes.

Definition at line 32 of file action.hpp.

Member Typedef Documentation

◆ threshold_function_type

using input::action::threshold_function_type = std::function<bool(float)>

Threshold function type.

Given an input value, returns true if the action should be considered active, and false otherwise.

Definition at line 40 of file action.hpp.

Constructor & Destructor Documentation

◆ action()

input::action::action ( )

Constructs an action.

Definition at line 33 of file action.cpp.

Member Function Documentation

◆ evaluate()

void input::action::evaluate ( float  value)

Evaluates the activation state of the action, according to its threshold function and an input value.

Parameters
valueInput value.

Definition at line 37 of file action.cpp.

◆ get_activated_channel()

::event::channel<action_activated_event>& input::action::get_activated_channel ( )
inlinenoexcept

Returns the channel through which action activated events are published.

Definition at line 91 of file action.hpp.

◆ get_active_channel()

::event::channel<action_active_event>& input::action::get_active_channel ( )
inlinenoexcept

Returns the channel through which action active events are published.

Definition at line 97 of file action.hpp.

◆ get_deactivated_channel()

::event::channel<action_deactivated_event>& input::action::get_deactivated_channel ( )
inlinenoexcept

Returns the channel through which action deactivated events are published.

Definition at line 103 of file action.hpp.

◆ get_input_value()

float input::action::get_input_value ( ) const
inlinenoexcept

Returns the most recently evaluated input value.

Definition at line 85 of file action.hpp.

◆ get_threshold_function()

const threshold_function_type& input::action::get_threshold_function ( ) const
inlinenoexcept

Returns the threshold function.

Definition at line 73 of file action.hpp.

◆ is_active()

bool input::action::is_active ( ) const
inlinenoexcept

Returns true if the action is active, false otherwise.

Definition at line 79 of file action.hpp.

◆ reset()

void input::action::reset ( )
noexcept

Resets the activation state of the action without publishing any events.

Definition at line 75 of file action.cpp.

◆ set_threshold_function()

void input::action::set_threshold_function ( const threshold_function_type function)
inlinenoexcept

Sets the threshold function.

Parameters
functionThreshold function.

Definition at line 50 of file action.hpp.

◆ update()

void input::action::update ( ) const

Publishes an action active event if the action is active.

Definition at line 66 of file action.cpp.


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