IQRF Gateway Daemon
IScheduler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-2017 MICRORISC s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 #include <functional>
21 #include <vector>
22 #include <chrono>
23 
29 {
30 public:
32  typedef long TaskHandle;
33 
35  static const TaskHandle TASK_HANDLE_INVALID = 0;
36 
38  typedef std::function<void(const std::string&)> TaskHandlerFunc;
39 
40  virtual ~IScheduler() {};
41 
49  virtual void registerMessageHandler(const std::string& clientId, TaskHandlerFunc fun) = 0;
50 
55  virtual void unregisterMessageHandler(const std::string& clientId) = 0;
56 
62  virtual std::vector<std::string> getMyTasks(const std::string& clientId) const = 0;
63 
70  virtual std::string getMyTask(const std::string& clientId, const TaskHandle& hndl) const = 0;
71 
80  virtual TaskHandle scheduleTaskAt(const std::string& clientId, const std::string& task, const std::chrono::system_clock::time_point& tp) = 0;
81 
91  virtual TaskHandle scheduleTaskPeriodic(const std::string& clientId, const std::string& task, const std::chrono::seconds& sec,
92  const std::chrono::system_clock::time_point& tp = std::chrono::system_clock::now()) = 0;
93 
98  virtual void removeAllMyTasks(const std::string& clientId) = 0;
99 
105  virtual void removeTask(const std::string& clientId, TaskHandle hndl) = 0;
106 
112  virtual void removeTasks(const std::string& clientId, std::vector<TaskHandle> hndls) = 0;
113 
117  virtual void start() = 0;
118 
122  virtual void stop() = 0;
123 };
long TaskHandle
Task handle is task identification.
Definition: IScheduler.h:32
virtual ~IScheduler()
Definition: IScheduler.h:40
std::function< void(const std::string &)> TaskHandlerFunc
Task to be processed handler functional type.
Definition: IScheduler.h:38
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.
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.
virtual std::string getMyTask(const std::string &clientId, const TaskHandle &hndl) const =0
Get a particular tasks for a client.
virtual void registerMessageHandler(const std::string &clientId, TaskHandlerFunc fun)=0
Register task handler.
virtual void removeTasks(const std::string &clientId, std::vector< TaskHandle > hndls)=0
Remove tasks for client.
static const TaskHandle TASK_HANDLE_INVALID
Invalid task handle.
Definition: IScheduler.h:35
virtual void removeTask(const std::string &clientId, TaskHandle hndl)=0
Remove task for client.
IScheduler interface.
Definition: IScheduler.h:28
virtual void removeAllMyTasks(const std::string &clientId)=0
Remove all task for client.
virtual void unregisterMessageHandler(const std::string &clientId)=0
Unregister task handler.
virtual void stop()=0
Stop IScheduler instance.
virtual std::vector< std::string > getMyTasks(const std::string &clientId) const =0
Get scheduled tasks for a client.
virtual void start()=0
Start IScheduler instance.