IQRF Gateway Daemon
Public Types | Public Member Functions | Static Public Attributes | List of all members
IScheduler Class Referenceabstract

IScheduler interface. More...

#include <IScheduler.h>

Inheritance diagram for IScheduler:
Scheduler

Public Types

typedef long TaskHandle
 Task handle is task identification. More...
 
typedef std::function< void(const std::string &)> TaskHandlerFunc
 Task to be processed handler functional type. More...
 

Public Member Functions

virtual ~IScheduler ()
 
virtual void registerMessageHandler (const std::string &clientId, TaskHandlerFunc fun)=0
 Register task handler. More...
 
virtual void unregisterMessageHandler (const std::string &clientId)=0
 Unregister task handler. More...
 
virtual std::vector< std::string > getMyTasks (const std::string &clientId) const =0
 Get scheduled tasks for a client. More...
 
virtual std::string getMyTask (const std::string &clientId, const TaskHandle &hndl) const =0
 Get a particular tasks for a client. More...
 
virtual TaskHandle scheduleTaskAt (const std::string &clientId, const std::string &task, const std::chrono::system_clock::time_point &tp)=0
 Schedule task at time point. More...
 
virtual TaskHandle scheduleTaskPeriodic (const std::string &clientId, const std::string &task, const std::chrono::seconds &sec, const std::chrono::system_clock::time_point &tp=std::chrono::system_clock::now())=0
 Schedule periodic task. More...
 
virtual void removeAllMyTasks (const std::string &clientId)=0
 Remove all task for client. More...
 
virtual void removeTask (const std::string &clientId, TaskHandle hndl)=0
 Remove task for client. More...
 
virtual void removeTasks (const std::string &clientId, std::vector< TaskHandle > hndls)=0
 Remove tasks for client. More...
 
virtual void start ()=0
 Start IScheduler instance. More...
 
virtual void stop ()=0
 Stop IScheduler instance. More...
 

Static Public Attributes

static const TaskHandle TASK_HANDLE_INVALID = 0
 Invalid task handle. More...
 

Detailed Description

IScheduler interface.

Provides interface for planning task fired at proper time

Member Typedef Documentation

◆ TaskHandle

typedef long IScheduler::TaskHandle

Task handle is task identification.

◆ TaskHandlerFunc

typedef std::function<void(const std::string&)> IScheduler::TaskHandlerFunc

Task to be processed handler functional type.

Constructor & Destructor Documentation

◆ ~IScheduler()

virtual IScheduler::~IScheduler ( )
inlinevirtual

Member Function Documentation

◆ getMyTask()

virtual std::string IScheduler::getMyTask ( const std::string &  clientId,
const TaskHandle hndl 
) const
pure virtual

Get a particular tasks for a client.

Parameters
[in]clientIdclient identification
[in]hndltask handle identification
Returns
scheduled tasks

Returns a particular task planned for a client or an empty task if doesn't exists

Implemented in Scheduler.

◆ getMyTasks()

virtual std::vector<std::string> IScheduler::getMyTasks ( const std::string &  clientId) const
pure virtual

Get scheduled tasks for a client.

Parameters
[in]clientIdclient identification
Returns
scheduled tasks

Returns all pending scheduled tasks for the client

Implemented in Scheduler.

◆ registerMessageHandler()

virtual void IScheduler::registerMessageHandler ( const std::string &  clientId,
TaskHandlerFunc  fun 
)
pure virtual

Register task handler.

Parameters
[in]clientIdclient identification registering handler function
[in]funhandler function

Whenever the scheduler evaluate a task to be handled it is passed to the handler function. The only tasks planned for particular clientId are delivered. Repeated registration with the same client identification replaces previously registered handler

Implemented in Scheduler.

◆ removeAllMyTasks()

virtual void IScheduler::removeAllMyTasks ( const std::string &  clientId)
pure virtual

Remove all task for client.

Parameters
[in]clientIdclient identification

Scheduler removes all tasks for the client

Implemented in Scheduler.

◆ removeTask()

virtual void IScheduler::removeTask ( const std::string &  clientId,
TaskHandle  hndl 
)
pure virtual

Remove task for client.

Parameters
[in]clientIdclient identification
[in]hndltask handle identification

Scheduler removes a particular tasks for the client

Implemented in Scheduler.

◆ removeTasks()

virtual void IScheduler::removeTasks ( const std::string &  clientId,
std::vector< TaskHandle hndls 
)
pure virtual

Remove tasks for client.

Parameters
[in]clientIdclient identification
[in]hndlstask handles identification

Scheduler removes a group of tasks passed in hndls for the client

Implemented in Scheduler.

◆ scheduleTaskAt()

virtual TaskHandle IScheduler::scheduleTaskAt ( const std::string &  clientId,
const std::string &  task,
const std::chrono::system_clock::time_point &  tp 
)
pure virtual

Schedule task at time point.

Parameters
[in]clientIdclient identification
[in]taskplanned task
[in]tptime point
Returns
scheduled task handle

Schedules task at exact time point. When the time point is reached the task is passed to its handler and released Use it for one shot tasks

Implemented in Scheduler.

◆ scheduleTaskPeriodic()

virtual TaskHandle IScheduler::scheduleTaskPeriodic ( const std::string &  clientId,
const std::string &  task,
const std::chrono::seconds &  sec,
const std::chrono::system_clock::time_point &  tp = std::chrono::system_clock::now() 
)
pure virtual

Schedule periodic task.

Parameters
[in]clientIdclient identification
[in]taskplanned task
[in]secperiod in seconds
[in]tptime point of delayed start
Returns
scheduled task handle

Schedules periodic task. It is started immediatelly by default, the first shot after one period. If the start shall be delayed use appropriate time point of start

Implemented in Scheduler.

◆ start()

virtual void IScheduler::start ( )
pure virtual

Start IScheduler instance.

Scheduler implementation starts to process scheduled tasks

Implemented in Scheduler.

◆ stop()

virtual void IScheduler::stop ( )
pure virtual

Stop IScheduler instance.

Scheduler implementation stops processing of scheduled tasks

Implemented in Scheduler.

◆ unregisterMessageHandler()

virtual void IScheduler::unregisterMessageHandler ( const std::string &  clientId)
pure virtual

Unregister task handler.

Parameters
[in]clientIdclient identification

If the handler is not required anymore, it is possible to unregister via this method.

Implemented in Scheduler.

Member Data Documentation

◆ TASK_HANDLE_INVALID

const TaskHandle IScheduler::TASK_HANDLE_INVALID = 0
static

Invalid task handle.


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