From 33a86529ceced3ba0b6d69e12523d5dd1fdd0c1a Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 6 Apr 2017 18:49:55 +0900 Subject: [PATCH] sensord: add application_sensor_handler skeleton class - application_sensor_handler will be created by application - application_sensor_handler provides: - events from application to observers(listeners) Change-Id: Ic33e1c164ddfc98766eec6e82b2b537ccf4c5a6a Signed-off-by: kibak.yoon --- src/server/application_sensor_handler.cpp | 90 +++++++++++++++++++++++++++++++ src/server/application_sensor_handler.h | 60 +++++++++++++++++++++ 2 files changed, 150 insertions(+) create mode 100644 src/server/application_sensor_handler.cpp create mode 100644 src/server/application_sensor_handler.h diff --git a/src/server/application_sensor_handler.cpp b/src/server/application_sensor_handler.cpp new file mode 100644 index 0000000..48e50be --- /dev/null +++ b/src/server/application_sensor_handler.cpp @@ -0,0 +1,90 @@ +/* + * sensord + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "application_sensor_handler.h" + +#include +#include + +using namespace sensor; + +application_sensor_handler::application_sensor_handler(const sensor_info &info) +: m_info(info) +{ +} + +application_sensor_handler::~application_sensor_handler() +{ +} + +int application_sensor_handler::post(sensor_data_t *data, int len) +{ + std::string uri = m_info.get_type_uri(); + + return notify(uri.c_str(), data, len); +} + +const sensor_info &application_sensor_handler::get_sensor_info(void) +{ + return m_info; +} + +int application_sensor_handler::start(sensor_observer *ob) +{ + add_observer(ob); + + return OP_SUCCESS; +} + +int application_sensor_handler::stop(sensor_observer *ob) +{ + remove_observer(ob); + + return OP_SUCCESS; +} + +int application_sensor_handler::set_interval(sensor_observer *ob, int32_t interval) +{ + return OP_SUCCESS; +} + +int application_sensor_handler::set_batch_latency(sensor_observer *ob, int32_t latency) +{ + return OP_SUCCESS; +} + +int application_sensor_handler::set_attribute(sensor_observer *ob, int32_t attr, int32_t value) +{ + return OP_SUCCESS; +} + +int application_sensor_handler::set_attribute(sensor_observer *ob, int32_t attr, const char *value, int len) +{ + return OP_SUCCESS; +} + +int application_sensor_handler::flush(sensor_observer *ob) +{ + return OP_SUCCESS; +} + +int application_sensor_handler::get_data(sensor_data_t **data, int *len) +{ + return OP_SUCCESS; +} diff --git a/src/server/application_sensor_handler.h b/src/server/application_sensor_handler.h new file mode 100644 index 0000000..87d07fd --- /dev/null +++ b/src/server/application_sensor_handler.h @@ -0,0 +1,60 @@ +/* + * sensord + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __APPLICATION_SENSOR_HANDLER_H__ +#define __APPLICATION_SENSOR_HANDLER_H__ + +#include +#include +#include + +#include "sensor_handler.h" +#include "sensor_observer.h" + +namespace sensor { + +class application_sensor_handler : public sensor_handler { +public: + application_sensor_handler(const sensor_info &info); + ~application_sensor_handler(); + + /* TODO: const */ + int post(sensor_data_t *data, int len); + + /* sensor interface */ + const sensor_info &get_sensor_info(void); + + int start(sensor_observer *ob); + int stop(sensor_observer *ob); + + int set_interval(sensor_observer *ob, int32_t interval); + int set_batch_latency(sensor_observer *ob, int32_t latency); + int set_attribute(sensor_observer *ob, int32_t attr, int32_t value); + int set_attribute(sensor_observer *ob, int32_t attr, const char *value, int len); + int flush(sensor_observer *ob); + int get_data(sensor_data_t **data, int *len); + +private: + sensor_info m_info; + std::vector m_required_sensors; +}; + +} + +#endif /* __APPLICATION_SENSOR_HANDLER_H__ */ -- 2.7.4