vt::timetrigger::Trigger struct

A time-based trigger that fires with some time period.

Constructors, destructors, conversion operators

Trigger(std::chrono::milliseconds in_period, ActionType in_trigger, int in_id)
Create a new time-based trigger.

Public functions

auto getLastTriggerTime() const -> TimeType
Get the last trigger time.
auto nextTriggerTime() const -> TimeType
Get the next trigger time.
void runAction(TimeType current_time)
Run the trigger.
auto getID() const -> int
Get the ID for the trigger.
auto ready(TimeType current_time) const -> bool
Check if the trigger is ready to be fired.
void setLastTriggerTime(TimeType trigger_time)
Update last trigger time—used the first time to set up the trigger.
template<typename Serializer>
void serialize(Serializer& s)

Friends

auto operator<(Trigger const& lhs, Trigger const& rhs) -> bool

Function documentation

vt::timetrigger::Trigger::Trigger(std::chrono::milliseconds in_period, ActionType in_trigger, int in_id)

Create a new time-based trigger.

Parameters
in_period in the period to trigger
in_trigger in the action
in_id in the id for the trigger

TimeType vt::timetrigger::Trigger::getLastTriggerTime() const

Get the last trigger time.

Returns the last time this was triggered

TimeType vt::timetrigger::Trigger::nextTriggerTime() const

Get the next trigger time.

Returns the next time this should be triggered

void vt::timetrigger::Trigger::runAction(TimeType current_time)

Run the trigger.

Parameters
current_time in current time

int vt::timetrigger::Trigger::getID() const

Get the ID for the trigger.

Returns the ID

bool vt::timetrigger::Trigger::ready(TimeType current_time) const

Check if the trigger is ready to be fired.

Parameters
current_time in current time
Returns whether the trigger can be run already

void vt::timetrigger::Trigger::setLastTriggerTime(TimeType trigger_time)

Update last trigger time—used the first time to set up the trigger.

Parameters
trigger_time in the last trigger time