SObjectizer  5.8
Loading...
Searching...
No Matches
so_5::state_t::time_limit_t Class Reference

Information of time_limit for a state. More...

Classes

struct  activation_data_t
 

Public Types

using msg_timeout = so_5::details::msg_state_timeout
 Type of signal to be used for controlling timeouts.
 
using steady_clock = std::chrono::steady_clock
 Type of clock to be used.
 

Public Member Functions

 time_limit_t (duration_t limit, const state_t &state_to_switch) noexcept
 Initializing constructor.
 
void change (duration_t limit, const state_t &state_to_switch) noexcept
 
void on_state_activation (const agent_t::state_time_limit_handling_data_t &info) noexcept
 
void on_state_deactivation () noexcept
 
void activate (const agent_t::state_time_limit_handling_data_t &info)
 
void deactivate ()
 
bool is_limit_exceeded (const steady_clock::time_point current_time) const noexcept
 
const state_tstate_to_switch () const noexcept
 

Private Attributes

duration_t m_limit
 
std::reference_wrapper< const state_tm_state_to_switch
 The target state to switch after the timeout.
 
std::optional< activation_data_tm_activation_data
 

Detailed Description

Information of time_limit for a state.

Definition at line 198 of file agent.cpp.

Member Typedef Documentation

◆ msg_timeout

Type of signal to be used for controlling timeouts.

Definition at line 202 of file agent.cpp.

◆ steady_clock

using so_5::state_t::time_limit_t::steady_clock = std::chrono::steady_clock

Type of clock to be used.

Definition at line 205 of file agent.cpp.

Constructor & Destructor Documentation

◆ time_limit_t()

so_5::state_t::time_limit_t::time_limit_t ( duration_t limit,
const state_t & state_to_switch )
inlinenoexcept

Initializing constructor.

Parameters
limitValue of the time limit.
state_to_switchThe target state to switch to after the time limit has been exceeded.

Definition at line 208 of file agent.cpp.

Member Function Documentation

◆ activate()

void so_5::state_t::time_limit_t::activate ( const agent_t::state_time_limit_handling_data_t & info)
inline

Sends the delayed msg_timeout signal.

Updates the value of m_activation_data.

It's assumed that this method will be called only if time_limit is not active yet.

Definition at line 268 of file agent.cpp.

◆ change()

void so_5::state_t::time_limit_t::change ( duration_t limit,
const state_t & state_to_switch )
inlinenoexcept

Change parameters of time limit.

Note
This method only changes m_limit and m_state_to_switch but doesn't change m_activation_data. If time_limit is activated it has to be deactivated explicitly via deactivate() method.

Definition at line 224 of file agent.cpp.

◆ deactivate()

void so_5::state_t::time_limit_t::deactivate ( )
inline

Deactivates the time limit.

This method can be called even if the time limit is not active.

Resets the value of m_activation_data and cancels the delayed msg_timeout signal.

Definition at line 287 of file agent.cpp.

◆ is_limit_exceeded()

bool so_5::state_t::time_limit_t::is_limit_exceeded ( const steady_clock::time_point current_time) const
inlinenodiscardnoexcept
Return values
trueif timeout has been exceeded and the agent has to be switched to a new state.
falseif timeout has not been exceeded yet (or if time limit isn't activated).

Definition at line 300 of file agent.cpp.

◆ on_state_activation()

void so_5::state_t::time_limit_t::on_state_activation ( const agent_t::state_time_limit_handling_data_t & info)
inlinenoexcept

React to activation of the state for that time_limit is defined.

Sends delayed msg_timeout message and sets the m_activation_data.

Attention
This method is marked as noexcept because it has to be called in a noexcept context. But it calls methods those can throw (like so_5::send_periodic). This is a consequence of the current design of SObjectizer-5 (there is no non-throwing ways to send a message yet).

Definition at line 243 of file agent.cpp.

◆ on_state_deactivation()

void so_5::state_t::time_limit_t::on_state_deactivation ( )
inlinenoexcept

React to deactivation of the state for that time_limit is defined.

Resets the value of m_activation_data and cancels the delayed msg_timeout message.

Definition at line 254 of file agent.cpp.

◆ state_to_switch()

const state_t & so_5::state_t::time_limit_t::state_to_switch ( ) const
inlinenodiscardnoexcept
Returns
Reference to the state to switch after expiration of the timeout.

Definition at line 314 of file agent.cpp.

Member Data Documentation

◆ m_activation_data

std::optional< activation_data_t > so_5::state_t::time_limit_t::m_activation_data
private

Information required to serve timeout when it's activated.

Empty value means that the timeout isn't activated.

Definition at line 355 of file agent.cpp.

◆ m_limit

duration_t so_5::state_t::time_limit_t::m_limit
private

The current duration of the timeout.

Will be changed on the next call to state_t::time_limit().

Definition at line 347 of file agent.cpp.

◆ m_state_to_switch

std::reference_wrapper< const state_t > so_5::state_t::time_limit_t::m_state_to_switch
private

The target state to switch after the timeout.

Definition at line 350 of file agent.cpp.


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