Trigger
Trigger
#include <icy/sched/trigger.h>Inherits:
ISerializableSubclassed by:DailyTrigger,IntervalTrigger,OnceOnlyTrigger
Base class for scheduled task triggers that determine when a task should run.
Public Attributes
| Return | Name | Description |
|---|---|---|
std::string | type | The type of this trigger class. |
std::string | name | The display name of this trigger class. |
int | timesRun | The number of times the task has run since creation; |
DateTime | createdAt | The time the task was created. |
DateTime | scheduleAt | The time the task is scheduled to run. |
DateTime | lastRunAt | The time the task was last run. |
type
std::string typeThe type of this trigger class.
name
std::string nameThe display name of this trigger class.
timesRun
int timesRunThe number of times the task has run since creation;
createdAt
DateTime createdAtThe time the task was created.
scheduleAt
DateTime scheduleAtThe time the task is scheduled to run.
lastRunAt
DateTime lastRunAtThe time the task was last run.
Public Methods
| Return | Name | Description |
|---|---|---|
Trigger | #### Parameters | |
void | update | Updates the scheduleAt value to the next scheduled time. |
std::int64_t | remaining virtual | Returns the milliseconds remaining until the next scheduled timeout. |
bool | timeout virtual | Returns true if the task is ready to be run, false otherwise. |
bool | expired virtual | Returns true if the task is expired and should be destroyed. Returns false by default. |
void | serialize virtual | Serializes timing state (type, name, createdAt, scheduleAt, lastRunAt, timesRun) to root. |
void | deserialize virtual | Deserializes timing state from root. |
Trigger
Trigger(const std::string & type, const std::string & name)Parameters
typeRegistered type name used by TaskFactory.nameHuman-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
rootJSON object to populate.
deserialize
virtual
virtual void deserialize(json::Value & root)Deserializes timing state from root.
Parameters
rootJSON object previously produced by serialize().
