-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.h
112 lines (100 loc) · 3.19 KB
/
actions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// check_uap checks on access point controllers
// Copyright (C) 2015 thoto
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef _ACTIONS_H_
#define _ACTIONS_H_
#include<jsoncpp/json/json.h>
#include<string>
using namespace std;
class action_generic{
public:
action_generic(){};
~action_generic(){};
virtual void scan(const Json::Value&)=0;
virtual bool match_range(const string def)=0;
virtual bool match_range()=0;
virtual string toString(){ return "generic"; }
virtual string perfdata()=0;
string vmsg="";
};
class action_boolean: public action_generic{
protected:
bool state;
public:
action_boolean():state(false){};
bool match_range(const string pdef);
bool match_range();
virtual string toString(){
return "action_boolean: "+string(state?"true":"false"); }
virtual string perfdata()=0;
#ifdef RUN_TEST
// bool test_action_boolean();
#endif
};
// TODO: Match_range(null) implementieren!
class action_numeric: public action_generic{
protected:
bool parse_range(const string pdef);
int num;
bool infmin=false,infmax=false,inside=false;
int lmin=0;int lmax=0;
public:
action_numeric():num(0){};
bool match_range(const string pdef);
bool match_range();
virtual string toString(){
return "action_numeric: "+to_string(num); }
virtual string perfdata()=0;
#ifdef RUN_TEST
bool test_action_numeric();
#endif
};
class action_numguest: public virtual action_numeric{
protected:
bool guest_add=true; // add or subtract value: numuser
public:
void scan(const Json::Value &v);
virtual string toString(){
return "action_numguest: "+to_string(num); }
virtual string perfdata(){ return "numguest="+to_string(num); };
};
class action_numall: public virtual action_numeric{
public:
void scan(const Json::Value &v);
virtual string toString(){
return "action_numall: "+to_string(num); }
virtual string perfdata(){ return "numall="+to_string(num); };
};
class action_numuser: public virtual action_numeric, public action_numall,
public action_numguest {
public:
action_numuser():action_numeric(),action_numall(),action_numguest(){
guest_add=false;
};
void scan(const Json::Value &v);
virtual string toString(){
return "action_numuser: "+to_string(num); }
virtual string perfdata(){ return "numuser="+to_string(num); };
};
class action_online: public virtual action_boolean {
public:
action_online():action_boolean(){};
void scan(const Json::Value &v);
virtual string toString(){
return "action_online: "+string(state?"true":"false"); }
virtual string perfdata(){
return "online="+string(state?"true":"false"); };
};
#endif //_ACTIONS_H_