Sched module

Trigger

Base class for scheduled task triggers that determine when a task should run.

Trigger

#include <icy/sched/trigger.h>

Inherits: ISerializable Subclassed by: DailyTrigger, IntervalTrigger, OnceOnlyTrigger

Base class for scheduled task triggers that determine when a task should run.

Public Attributes

ReturnNameDescription
std::stringtypeThe type of this trigger class.
std::stringnameThe display name of this trigger class.
inttimesRunThe number of times the task has run since creation;
DateTimecreatedAtThe time the task was created.
DateTimescheduleAtThe time the task is scheduled to run.
DateTimelastRunAtThe time the task was last run.

type

std::string type

The type of this trigger class.


name

std::string name

The display name of this trigger class.


timesRun

int timesRun

The number of times the task has run since creation;


createdAt

DateTime createdAt

The time the task was created.


scheduleAt

DateTime scheduleAt

The time the task is scheduled to run.


lastRunAt

DateTime lastRunAt

The time the task was last run.

Public Methods

ReturnNameDescription
Trigger#### Parameters
voidupdateUpdates the scheduleAt value to the next scheduled time.
std::int64_tremaining virtualReturns the milliseconds remaining until the next scheduled timeout.
booltimeout virtualReturns true if the task is ready to be run, false otherwise.
boolexpired virtualReturns true if the task is expired and should be destroyed. Returns false by default.
voidserialize virtualSerializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root.
voiddeserialize virtualDeserializes timing state from root.

Trigger

Trigger(const std::string & type, const std::string & name)

Parameters

  • type Registered type name used by TaskFactory.

  • name Human-readable display name.


update

void update()

Updates the scheduleAt value to the next scheduled time.


remaining

virtual

virtual std::int64_t remaining()

Returns the milliseconds remaining until the next scheduled timeout.


timeout

virtual

virtual bool timeout()

Returns true if the task is ready to be run, false otherwise.


expired

virtual

virtual bool expired()

Returns true if the task is expired and should be destroyed. Returns false by default.


serialize

virtual

virtual void serialize(json::Value & root)

Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root.

Parameters

  • root JSON object to populate.

deserialize

virtual

virtual void deserialize(json::Value & root)

Deserializes timing state from root.

Parameters