Merge "sensord: delete batch latency/attribute when client is terminated unexpectedly...
[platform/core/system/sensord.git] / src / server / external_sensor_service.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2015 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 #ifndef _EXTERNAL_SENSOR_SERVICE_H_
21 #define _EXTERNAL_SENSOR_SERVICE_H_
22
23 #include <external_sensor.h>
24 #include <csocket.h>
25 #include <string>
26 #include <unordered_map>
27
28 class external_client_manager;
29
30 class external_sensor_service {
31 public:
32         static external_sensor_service& get_instance();
33         bool register_sensor(external_sensor *sensor);
34         bool unregister_sensor(external_sensor *sensor);
35         external_sensor* get_sensor(const std::string& key);
36
37         void accept_command_channel(csocket client_socket);
38         bool run(void);
39 private:
40         external_sensor_service();
41         ~external_sensor_service();
42         external_sensor_service(const external_sensor_service&) {};
43         external_sensor_service& operator=(const external_sensor_service&);
44
45         static external_client_manager& get_client_manager(void);
46
47         void dispatch_command(void);
48
49         std::unordered_map<std::string, external_sensor*> m_external_sensors;
50 };
51 #endif /* _EXTERNAL_SENSOR_SERVICE_H_ */
52