TaskManagerIO
Loading...
Searching...
No Matches
ExecWithParameter.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 https://www.thecoderscorner.com (Dave Cherry)..
3 * This product is licensed under an Apache license, see the LICENSE file in the top-level directory.
4 */
5
6#ifndef TASKMANAGERIO_EXECWITHPARAMETER_H
7#define TASKMANAGERIO_EXECWITHPARAMETER_H
8
13
14#include "TaskTypes.h"
15
27template <class TParam> class ExecWithParameter : public Executable {
28private:
29 void (*fnParam)(TParam);
30 TParam param;
31public:
37 ExecWithParameter(void (*fn)(TParam), TParam storedParam) : fnParam(fn), param(storedParam){}
38 ~ExecWithParameter() override = default;
39
40 void exec() override {
41 fnParam(param);
42 }
43};
44
52template <class TParam1, class TParam2> class ExecWith2Parameters : public Executable {
53private:
54 void (*fnParam)(TParam1, TParam2);
55 TParam1 param1;
56 TParam2 param2;
57public:
64 ExecWith2Parameters(void (*fn)(TParam1, TParam2), TParam1 storedParam1, TParam2 storedParam2 ) :
65 fnParam(fn), param1(storedParam1), param2(storedParam2) {}
66 ~ExecWith2Parameters() override = default;
67
68 void exec() override {
69 fnParam(param1, param2);
70 }
71};
72
73
74#endif //TASKMANAGERIO_EXECWITHPARAMETER_H
This class represents the core tasks that are added to task manager, and the TimerTask object itself.
Definition ExecWithParameter.h:52
ExecWith2Parameters(void(*fn)(TParam1, TParam2), TParam1 storedParam1, TParam2 storedParam2)
Definition ExecWithParameter.h:64
void exec() override
Definition ExecWithParameter.h:68
Definition ExecWithParameter.h:27
ExecWithParameter(void(*fn)(TParam), TParam storedParam)
Definition ExecWithParameter.h:37
void exec() override
Definition ExecWithParameter.h:40
Definition TaskTypes.h:28