sensorctl: remove unnecessary keyword/macro
[platform/core/system/sensord.git] / src / sensorctl / injector.h
1 /*
2  * sensorctl
3  *
4  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #pragma once /* __INJECTOR_H__ */
21
22 #include <sensor_internal.h>
23 #include <string>
24 #include <vector>
25
26 #include "sensor_manager.h"
27
28 #define INJECTOR_ARGC 4 /* e.g. {sensorctl, inject, wristup, conf} */
29
30 #define REGISTER_INJECTOR(sensor_type, event_name, injector_type) \
31 static injector_type injector(sensor_type, event_name);
32
33 class injector {
34 public:
35         injector(sensor_type_t sensor_type, const char *event_name);
36         virtual ~injector() {}
37
38         virtual bool setup(void) { return true; }
39         virtual bool teardown(void) { return true; }
40
41         const std::string& name() const { return m_name; }
42         const sensor_type_t type() const { return m_type; }
43
44         virtual bool inject(int argc, char *argv[]) = 0;
45
46 private:
47         sensor_type_t m_type;
48         std::string m_name;
49 };
50
51 class injector_manager : public sensor_manager {
52 public:
53         static void register_injector(injector *inject);
54
55         injector_manager();
56         virtual ~injector_manager();
57
58         bool run(int argc, char *argv[]);
59
60 private:
61         static std::vector<injector *> injectors;
62
63         injector *get_injector(sensor_type_t type, const char *name);
64         void usage(void);
65 };