M1M3 Support System
Loading...
Searching...
No Matches
LimitTrigger.h
1/*
2 * Abstract class for limitting an execution.
3 *
4 * Developed for the Telescope & Site Software Systems. This product includes
5 * software developed by the LSST Project (https://www.lsst.org). See the
6 * COPYRIGHT file at the top-level directory of this distribution for details
7 * of code ownership.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef LIMITTRIGGER_H_
24#define LIMITTRIGGER_H_
25
26namespace LSST {
27namespace M1M3 {
28namespace SS {
29
67template <typename... TcheckArgs>
68class LimitTrigger {
69public:
70 LimitTrigger() {}
71
79 void check(TcheckArgs... args) {
80 if (trigger()) {
81 execute(args...);
82 }
83 }
84
90 virtual void reset() = 0;
91
92protected:
98 virtual bool trigger() = 0;
99
108 virtual void execute(TcheckArgs... args) = 0;
109};
110
111} // namespace SS
112} // namespace M1M3
113} // namespace LSST
114
115#endif // !LIMITTRIGGER_H_
void check(TcheckArgs... args)
Should be called from code when out of bounds conditions for triggering is detected.
Definition LimitTrigger.h:77
virtual void reset()=0
Pure virtual placeholder to reset any internal variables.
virtual void execute(TcheckArgs... args)=0
Pure virtual placeholder for executing limited action.
virtual bool trigger()=0
Pure virtual placeholder for check if triggering criteria are met.