add_library(${PROJECT_NAME} SHARED
client.cpp
- csensor_client_info.cpp
- csensor_event_listener.cpp
+ sensor_client_info.cpp
+ sensor_event_listener.cpp
sensor_info_manager.cpp
- csensor_handle_info.cpp
+ sensor_handle_info.cpp
client_common.cpp
command_channel.cpp
)
configure_file(${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc @ONLY)
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries)
-install(FILES creg_event_info.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES csensor_event_listener.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
+install(FILES reg_event_info.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
+install(FILES sensor_event_listener.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
install(FILES sensor_info_manager.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
-install(FILES csensor_handle_info.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
+install(FILES sensor_handle_info.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
install(FILES client_common.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sensor/)
install(FILES ${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
#include <sf_common.h>
#include <sensor_internal_deprecated.h>
#include <sensor_internal.h>
-#include <csensor_event_listener.h>
+#include <sensor_event_listener.h>
#include <client_common.h>
#include <vconf.h>
#include <cmutex.h>
static const int OP_SUCCESS = 0;
static const int OP_ERROR = -1;
-static csensor_event_listener &event_listener = csensor_event_listener::get_instance();
-static csensor_client_info &client_info = csensor_client_info::get_instance();
+static sensor_event_listener &event_listener = sensor_event_listener::get_instance();
+static sensor_client_info &client_info = sensor_client_info::get_instance();
static cmutex lock;
static int g_power_save_state = 0;
return ((unsigned long long)(t.tv_sec)*1000000000LL + t.tv_nsec) / 1000;
}
-void print_event_occurrence_log(csensor_handle_info &sensor_handle_info, const creg_event_info *event_info)
+void print_event_occurrence_log(sensor_handle_info &sensor_handle_info, const reg_event_info *event_info)
{
log_attr *log_attr;
*
*/
-#ifndef CLIENT_COMMON_H_
-#define CLIENT_COMMON_H_
+#ifndef _CLIENT_COMMON_H_
+#define _CLIENT_COMMON_H_
/*header for each sensor type*/
#include <sensor_internal.h>
-#include <csensor_handle_info.h>
-#include <creg_event_info.h>
+#include <sensor_handle_info.h>
+#include <reg_event_info.h>
#include <sensor_logs.h>
#define BASE_GATHERING_INTERVAL 100
int sensor_state;
int sensor_option;
sensor_type_t sensor;
- creg_event_info event_info;
+ reg_event_info event_info;
} log_info;
bool is_one_shot_event(unsigned int event_type);
const char* get_sensor_name(sensor_id_t sensor_id);
const char* get_event_name(unsigned int event_type);
const char* get_data_name(unsigned int data_id);
-void print_event_occurrence_log(csensor_handle_info &sensor_handle_info, const creg_event_info *event_info);
+void print_event_occurrence_log(sensor_handle_info &sensor_handle_info, const reg_event_info *event_info);
class sensor_info;
sensor_info *sensor_to_sensor_info(sensor_t sensor);
sensor_t sensor_info_to_sensor(const sensor_info *info);
-#endif /* CLIENT_COMMON_H_ */
+#endif /* _CLIENT_COMMON_H_ */
#ifndef _COMMAND_CHANNEL_H_
#define _COMMAND_CHANNEL_H_
+
#include <sf_common.h>
#include <sensor_internal.h>
#include <cpacket.h>
*
*/
-#ifndef CREG_EVENT_INFO_H_
-#define CREG_EVENT_INFO_H_
+#ifndef _REG_EVENT_INFO_H_
+#define _REG_EVENT_INFO_H_
#include <sensor_internal.h>
#include <sf_common.h>
SENSOR_LEGACY_CB,
} event_cb_type_t;
-class creg_event_info {
+class reg_event_info {
public:
unsigned long long m_id;
int m_handle;
bool m_fired;
GMainContext *m_maincontext;
- creg_event_info():m_id(0), m_handle(-1),
+ reg_event_info():m_id(0), m_handle(-1),
type(0), m_interval(POLL_1HZ_MS),
m_latency(0),
m_cb_type(SENSOR_EVENT_CB), m_cb(NULL), m_user_data(NULL),
m_previous_event_time(0), m_fired(false), m_maincontext(NULL){}
- ~creg_event_info(){}
+ ~reg_event_info(){}
};
-#endif /* CREG_EVENT_INFO_H_ */
+#endif /* _REG_EVENT_INFO_H_ */
*
*/
-#include <csensor_event_listener.h>
+#include <sensor_event_listener.h>
#include <client_common.h>
#include <sf_common.h>
#include <sensor_info_manager.h>
using std::thread;
using std::pair;
-csensor_client_info::csensor_client_info()
+sensor_client_info::sensor_client_info()
: m_client_id(CLIENT_ID_INVALID)
{
}
-csensor_client_info::~csensor_client_info()
+sensor_client_info::~sensor_client_info()
{
}
-csensor_client_info& csensor_client_info::get_instance(void)
+sensor_client_info& sensor_client_info::get_instance(void)
{
- static csensor_client_info inst;
+ static sensor_client_info inst;
return inst;
}
-int csensor_client_info::create_handle(sensor_id_t sensor)
+int sensor_client_info::create_handle(sensor_id_t sensor)
{
- csensor_handle_info handle_info;
+ sensor_handle_info handle_info;
int handle = 0;
AUTOLOCK(m_handle_info_lock);
handle_info.m_accuracy_cb = NULL;
handle_info.m_accuracy_user_data = NULL;
- m_sensor_handle_infos.insert(pair<int,csensor_handle_info> (handle, handle_info));
+ m_sensor_handle_infos.insert(pair<int,sensor_handle_info> (handle, handle_info));
return handle;
}
-bool csensor_client_info::delete_handle(int handle)
+bool sensor_client_info::delete_handle(int handle)
{
AUTOLOCK(m_handle_info_lock);
}
-bool csensor_client_info::is_active()
+bool sensor_client_info::is_active()
{
AUTOLOCK(m_handle_info_lock);
return !m_sensor_handle_infos.empty();
}
-bool csensor_client_info::register_event(int handle, unsigned int event_type,
+bool sensor_client_info::register_event(int handle, unsigned int event_type,
unsigned int interval, unsigned int latency, int cb_type, void *cb, void* user_data)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::unregister_event(int handle, unsigned int event_type)
+bool sensor_client_info::unregister_event(int handle, unsigned int event_type)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void* user_data)
+bool sensor_client_info::register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void* user_data)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::unregister_accuracy_cb(int handle)
+bool sensor_client_info::unregister_accuracy_cb(int handle)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_sensor_params(int handle, int sensor_state, int sensor_option)
+bool sensor_client_info::set_sensor_params(int handle, int sensor_state, int sensor_option)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::get_sensor_params(int handle, int &sensor_state, int &sensor_option)
+bool sensor_client_info::get_sensor_params(int handle, int &sensor_state, int &sensor_option)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_sensor_state(int handle, int sensor_state)
+bool sensor_client_info::set_sensor_state(int handle, int sensor_state)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_sensor_option(int handle, int sensor_option)
+bool sensor_client_info::set_sensor_option(int handle, int sensor_option)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency)
+bool sensor_client_info::set_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext)
+bool sensor_client_info::set_event_maincontext(int handle, unsigned int event_type, GMainContext *maincontext)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_accuracy(int handle, int accuracy)
+bool sensor_client_info::set_accuracy(int handle, int accuracy)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_bad_accuracy(int handle, int bad_accuracy)
+bool sensor_client_info::set_bad_accuracy(int handle, int bad_accuracy)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::get_event_info(int handle, unsigned int event_type, unsigned int &interval, unsigned int &latency, int &cb_type, void* &cb, void* &user_data)
+bool sensor_client_info::get_event_info(int handle, unsigned int event_type, unsigned int &interval, unsigned int &latency, int &cb_type, void* &cb, void* &user_data)
{
AUTOLOCK(m_handle_info_lock);
return false;
}
- const creg_event_info *event_info;
+ const reg_event_info *event_info;
event_info = it_handle->second.get_reg_event_info(event_type);
}
-void csensor_client_info::get_listening_sensors(sensor_id_vector &sensors)
+void sensor_client_info::get_listening_sensors(sensor_id_vector &sensors)
{
AUTOLOCK(m_handle_info_lock);
unique(sensors.begin(),sensors.end());
}
-void csensor_client_info::get_sensor_rep(sensor_id_t sensor, sensor_rep& rep) {
+void sensor_client_info::get_sensor_rep(sensor_id_t sensor, sensor_rep& rep) {
const unsigned int INVALID_BATCH_VALUE = std::numeric_limits<unsigned int>::max();
rep.active = is_sensor_active(sensor);
get_active_event_types(sensor, rep.event_types);
}
-bool csensor_client_info::add_command_channel(sensor_id_t sensor, command_channel *cmd_channel)
+bool sensor_client_info::add_command_channel(sensor_id_t sensor, command_channel *cmd_channel)
{
auto it_channel = m_command_channels.find(sensor);
return true;
}
-bool csensor_client_info::get_command_channel(sensor_id_t sensor, command_channel **cmd_channel)
+bool sensor_client_info::get_command_channel(sensor_id_t sensor, command_channel **cmd_channel)
{
auto it_channel = m_command_channels.find(sensor);
}
-bool csensor_client_info::close_command_channel(void)
+bool sensor_client_info::close_command_channel(void)
{
auto it_channel = m_command_channels.begin();
return true;
}
-bool csensor_client_info::close_command_channel(sensor_id_t sensor_id)
+bool sensor_client_info::close_command_channel(sensor_id_t sensor_id)
{
auto it_channel = m_command_channels.find(sensor_id);
}
-bool csensor_client_info::has_client_id(void)
+bool sensor_client_info::has_client_id(void)
{
return (m_client_id != CLIENT_ID_INVALID);
}
-int csensor_client_info::get_client_id(void)
+int sensor_client_info::get_client_id(void)
{
return m_client_id;
}
-void csensor_client_info::set_client_id(int client_id)
+void sensor_client_info::set_client_id(int client_id)
{
m_client_id = client_id;
}
-bool csensor_client_info::get_active_batch(sensor_id_t sensor, unsigned int &interval, unsigned int &latency)
+bool sensor_client_info::get_active_batch(sensor_id_t sensor, unsigned int &interval, unsigned int &latency)
{
unsigned int min_interval = POLL_MAX_HZ_MS;
unsigned int min_latency = std::numeric_limits<unsigned int>::max();
return true;
}
-unsigned int csensor_client_info::get_active_option(sensor_id_t sensor)
+unsigned int sensor_client_info::get_active_option(sensor_id_t sensor)
{
int active_option = SENSOR_OPTION_DEFAULT;
bool active_sensor_found = false;
return active_option;
}
-bool csensor_client_info::get_sensor_id(int handle, sensor_id_t &sensor)
+bool sensor_client_info::get_sensor_id(int handle, sensor_id_t &sensor)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::get_sensor_state(int handle, int &sensor_state)
+bool sensor_client_info::get_sensor_state(int handle, int &sensor_state)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::get_sensor_wakeup(int handle, int &sensor_wakeup)
+bool sensor_client_info::get_sensor_wakeup(int handle, int &sensor_wakeup)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-bool csensor_client_info::set_sensor_wakeup(int handle, int sensor_wakeup)
+bool sensor_client_info::set_sensor_wakeup(int handle, int sensor_wakeup)
{
AUTOLOCK(m_handle_info_lock);
return true;
}
-void csensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_vector &active_event_types)
+void sensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_vector &active_event_types)
{
event_type_vector event_types;
}
-void csensor_client_info::get_all_handles(handle_vector &handles)
+void sensor_client_info::get_all_handles(handle_vector &handles)
{
AUTOLOCK(m_handle_info_lock);
}
}
-void csensor_client_info::get_sensor_handle_info(sensor_id_t sensor, sensor_handle_info_map &handles_info) {
+void sensor_client_info::get_sensor_handle_info(sensor_id_t sensor, sensor_handle_info_map &handles_info) {
AUTOLOCK(m_handle_info_lock);
while (it_handle != m_sensor_handle_infos.end()) {
if (it_handle->second.m_sensor_id == sensor) {
- handles_info.insert(pair<int,csensor_handle_info> (it_handle->first, it_handle->second));
+ handles_info.insert(pair<int,sensor_handle_info> (it_handle->first, it_handle->second));
}
++it_handle;
}
}
-void csensor_client_info::get_all_handle_info(sensor_handle_info_map &handles_info) {
+void sensor_client_info::get_all_handle_info(sensor_handle_info_map &handles_info) {
AUTOLOCK(m_handle_info_lock);
auto it_handle = m_sensor_handle_infos.begin();
while (it_handle != m_sensor_handle_infos.end()) {
- handles_info.insert(pair<int,csensor_handle_info> (it_handle->first, it_handle->second));
+ handles_info.insert(pair<int,sensor_handle_info> (it_handle->first, it_handle->second));
++it_handle;
}
}
-bool csensor_client_info::is_sensor_registered(sensor_id_t sensor)
+bool sensor_client_info::is_sensor_registered(sensor_id_t sensor)
{
AUTOLOCK(m_handle_info_lock);
}
-bool csensor_client_info::is_sensor_active(sensor_id_t sensor)
+bool sensor_client_info::is_sensor_active(sensor_id_t sensor)
{
AUTOLOCK(m_handle_info_lock);
return false;
}
-bool csensor_client_info::is_event_active(int handle, unsigned int event_type, unsigned long long event_id)
+bool sensor_client_info::is_event_active(int handle, unsigned int event_type, unsigned long long event_id)
{
- creg_event_info *event_info;
+ reg_event_info *event_info;
AUTOLOCK(m_handle_info_lock);
return true;
}
-void csensor_client_info::clear(void)
+void sensor_client_info::clear(void)
{
close_command_channel();
m_sensor_handle_infos.clear();
*
*/
-#ifndef CSENSOR_CLIENT_INFO_H_
-#define CSENSOR_CLIENT_INFO_H_
+#ifndef _SENSOR_CLIENT_INFO_H_
+#define _SENSOR_CLIENT_INFO_H_
#include <glib.h>
#include <sys/types.h>
-#include <csensor_handle_info.h>
+#include <sensor_handle_info.h>
#include <unistd.h>
#include <csocket.h>
#include <string.h>
typedef vector<unsigned int> handle_vector;
typedef vector<sensor_id_t> sensor_id_vector;
-typedef unordered_map<int,csensor_handle_info> sensor_handle_info_map;
+typedef unordered_map<int,sensor_handle_info> sensor_handle_info_map;
typedef unordered_map<sensor_id_t, command_channel*> sensor_command_channel_map;
typedef struct sensor_rep
event_type_vector event_types;
} sensor_rep;
-class csensor_client_info {
+class sensor_client_info {
public:
- static csensor_client_info& get_instance(void);
+ static sensor_client_info& get_instance(void);
int create_handle(sensor_id_t sensor_id);
bool delete_handle(int handle);
bool register_event(int handle, unsigned int event_type,
void clear(void);
- csensor_client_info();
- ~csensor_client_info();
+ sensor_client_info();
+ ~sensor_client_info();
private:
sensor_handle_info_map m_sensor_handle_infos;
cmutex m_handle_info_lock;
};
-#endif /* CSENSOR_CLIENT_INFO_H_ */
+#endif /* _SENSOR_CLIENT_INFO_H_ */
*
*/
-#include <csensor_event_listener.h>
+#include <sensor_event_listener.h>
#include <client_common.h>
#include <sf_common.h>
#include <sensor_info_manager.h>
using std::pair;
using std::vector;
-csensor_event_listener::csensor_event_listener()
+sensor_event_listener::sensor_event_listener()
: m_poller(NULL)
, m_thread_state(THREAD_STATE_TERMINATE)
, m_hup_observer(NULL)
-, m_client_info(csensor_client_info::get_instance())
+, m_client_info(sensor_client_info::get_instance())
{
}
-csensor_event_listener::~csensor_event_listener()
+sensor_event_listener::~sensor_event_listener()
{
stop_event_listener();
}
-csensor_event_listener::csensor_event_listener(const csensor_event_listener& listener)
+sensor_event_listener::sensor_event_listener(const sensor_event_listener& listener)
: m_poller(listener.m_poller)
, m_thread_state(listener.m_thread_state)
, m_hup_observer(listener.m_hup_observer)
{
}
-csensor_event_listener& csensor_event_listener::get_instance(void)
+sensor_event_listener& sensor_event_listener::get_instance(void)
{
- static csensor_event_listener inst;
+ static sensor_event_listener inst;
return inst;
}
-bool csensor_event_listener::start_handle(int handle)
+bool sensor_event_listener::start_handle(int handle)
{
return m_client_info.set_sensor_state(handle, SENSOR_STATE_STARTED);
}
-bool csensor_event_listener::stop_handle(int handle)
+bool sensor_event_listener::stop_handle(int handle)
{
return m_client_info.set_sensor_state(handle, SENSOR_STATE_STOPPED);
}
-void csensor_event_listener::operate_sensor(sensor_id_t sensor, int power_save_state)
+void sensor_event_listener::operate_sensor(sensor_id_t sensor, int power_save_state)
{
sensor_handle_info_map handles_info;
}
}
-client_callback_info* csensor_event_listener::handle_calibration_cb(csensor_handle_info &handle_info, unsigned event_type, unsigned long long time, int accuracy)
+client_callback_info* sensor_event_listener::handle_calibration_cb(sensor_handle_info &handle_info, unsigned event_type, unsigned long long time, int accuracy)
{
unsigned int cal_event_type = get_calibration_event_type(event_type);
- creg_event_info *event_info = NULL;
- creg_event_info *cal_event_info = NULL;
+ reg_event_info *event_info = NULL;
+ reg_event_info *cal_event_info = NULL;
client_callback_info* cal_callback_info = NULL;
if (!cal_event_type)
}
-void csensor_event_listener::handle_events(void* event)
+void sensor_event_listener::handle_events(void* event)
{
unsigned long long cur_time;
- creg_event_info *event_info = NULL;
+ reg_event_info *event_info = NULL;
sensor_event_data_t event_data;
sensor_id_t sensor_id;
sensor_handle_info_map handles_info;
for (auto it_handle = handles_info.begin(); it_handle != handles_info.end(); ++it_handle) {
- csensor_handle_info &sensor_handle_info = it_handle->second;
+ sensor_handle_info &sensor_handle_info = it_handle->second;
event_info = sensor_handle_info.get_reg_event_info(event_type);
if ((sensor_handle_info.m_sensor_id != sensor_id) ||
}
-client_callback_info* csensor_event_listener::get_callback_info(sensor_id_t sensor_id, const creg_event_info *event_info, void* sensor_data, void *buffer)
+client_callback_info* sensor_event_listener::get_callback_info(sensor_id_t sensor_id, const reg_event_info *event_info, void* sensor_data, void *buffer)
{
client_callback_info* callback_info;
return callback_info;
}
-void csensor_event_listener::post_callback_to_main_loop(client_callback_info* cb_info)
+void sensor_event_listener::post_callback_to_main_loop(client_callback_info* cb_info)
{
if (cb_info->maincontext) {
GSource *_source = g_idle_source_new();
}
}
-bool csensor_event_listener::is_valid_callback(client_callback_info *cb_info)
+bool sensor_event_listener::is_valid_callback(client_callback_info *cb_info)
{
return m_client_info.is_event_active(cb_info->handle, cb_info->event_type, cb_info->event_id);
}
-gboolean csensor_event_listener::callback_dispatcher(gpointer data)
+gboolean sensor_event_listener::callback_dispatcher(gpointer data)
{
client_callback_info *cb_info = (client_callback_info*) data;
- if (csensor_event_listener::get_instance().is_valid_callback(cb_info)) {
+ if (sensor_event_listener::get_instance().is_valid_callback(cb_info)) {
if (cb_info->accuracy_cb)
cb_info->accuracy_cb(cb_info->sensor, cb_info->timestamp, cb_info->accuracy, cb_info->accuracy_user_data);
-ssize_t csensor_event_listener::sensor_event_poll(void* buffer, int buffer_len, struct epoll_event &event)
+ssize_t sensor_event_listener::sensor_event_poll(void* buffer, int buffer_len, struct epoll_event &event)
{
ssize_t len;
-void csensor_event_listener::listen_events(void)
+void sensor_event_listener::listen_events(void)
{
struct epoll_event event;
ssize_t len = -1;
}
-bool csensor_event_listener::create_event_channel(void)
+bool sensor_event_listener::create_event_channel(void)
{
int client_id;
event_channel_ready_t event_channel_ready;
}
-void csensor_event_listener::close_event_channel(void)
+void sensor_event_listener::close_event_channel(void)
{
m_event_socket.close();
}
-void csensor_event_listener::stop_event_listener(void)
+void sensor_event_listener::stop_event_listener(void)
{
const int THREAD_TERMINATING_TIMEOUT = 2;
}
}
-void csensor_event_listener::set_thread_state(thread_state state)
+void sensor_event_listener::set_thread_state(thread_state state)
{
lock l(m_thread_mutex);
m_thread_state = state;
}
-void csensor_event_listener::clear(void)
+void sensor_event_listener::clear(void)
{
close_event_channel();
stop_event_listener();
}
-void csensor_event_listener::set_hup_observer(hup_observer_t observer)
+void sensor_event_listener::set_hup_observer(hup_observer_t observer)
{
m_hup_observer = observer;
}
-bool csensor_event_listener::start_event_listener(void)
+bool sensor_event_listener::start_event_listener(void)
{
if (!create_event_channel()) {
ERR("Event channel is not established for %s", get_client_name());
set_thread_state(THREAD_STATE_START);
- thread listener(&csensor_event_listener::listen_events, this);
+ thread listener(&sensor_event_listener::listen_events, this);
listener.detach();
return true;
*
*/
-#ifndef CSENSOR_EVENT_LISTENER_H_
-#define CSENSOR_EVENT_LISTENER_H_
+#ifndef _SENSOR_EVENT_LISTENER_H_
+#define _SENSOR_EVENT_LISTENER_H_
#include <glib.h>
#include <sys/types.h>
#include <sys/epoll.h>
-#include <csensor_handle_info.h>
-#include <csensor_client_info.h>
+#include <sensor_handle_info.h>
+#include <sensor_client_info.h>
#include <unistd.h>
#include <csocket.h>
#include <string.h>
typedef std::vector<unsigned int> handle_vector;
typedef std::vector<sensor_id_t> sensor_id_vector;
-typedef std::unordered_map<int,csensor_handle_info> sensor_handle_info_map;
+typedef std::unordered_map<int,sensor_handle_info> sensor_handle_info_map;
typedef std::unordered_map<sensor_id_t, command_channel*> sensor_command_channel_map;
typedef struct {
typedef void (*hup_observer_t)(void);
-class csensor_event_listener {
+class sensor_event_listener {
public:
- static csensor_event_listener& get_instance(void);
+ static sensor_event_listener& get_instance(void);
bool start_handle(int handle);
bool stop_handle(int handle);
hup_observer_t m_hup_observer;
- csensor_event_listener();
- ~csensor_event_listener();
+ sensor_event_listener();
+ ~sensor_event_listener();
- csensor_event_listener(const csensor_event_listener&);
- csensor_event_listener& operator=(const csensor_event_listener&);
+ sensor_event_listener(const sensor_event_listener&);
+ sensor_event_listener& operator=(const sensor_event_listener&);
bool create_event_channel(void);
void close_event_channel(void);
ssize_t sensor_event_poll(void* buffer, int buffer_len, struct epoll_event &event);
void listen_events(void);
- client_callback_info* handle_calibration_cb(csensor_handle_info &handle_info, unsigned event_type, unsigned long long time, int accuracy);
+ client_callback_info* handle_calibration_cb(sensor_handle_info &handle_info, unsigned event_type, unsigned long long time, int accuracy);
void handle_events(void* event);
- client_callback_info* get_callback_info(sensor_id_t sensor_id, const creg_event_info *event_info, void *sensor_data, void *buffer);
+ client_callback_info* get_callback_info(sensor_id_t sensor_id, const reg_event_info *event_info, void *sensor_data, void *buffer);
unsigned long long renew_event_id(void);
void set_thread_state(thread_state state);
- csensor_client_info &m_client_info;
+ sensor_client_info &m_client_info;
};
-#endif /* CSENSOR_EVENT_LISTENER_H_ */
+#endif /* _SENSOR_EVENT_LISTENER_H_ */
*/
#include <client_common.h>
-#include <csensor_handle_info.h>
+#include <sensor_handle_info.h>
#include <limits>
using std::pair;
-unsigned long long csensor_handle_info::m_event_id = 0;
+unsigned long long sensor_handle_info::m_event_id = 0;
-csensor_handle_info::csensor_handle_info()
+sensor_handle_info::sensor_handle_info()
: m_handle(0)
, m_sensor_id(UNKNOWN_SENSOR)
, m_sensor_state(SENSOR_STATE_UNKNOWN)
}
-csensor_handle_info::~csensor_handle_info()
+sensor_handle_info::~sensor_handle_info()
{
clear_all_events();
}
-creg_event_info* csensor_handle_info::get_reg_event_info(unsigned int event_type)
+reg_event_info* sensor_handle_info::get_reg_event_info(unsigned int event_type)
{
auto it_event = m_reg_event_infos.find(event_type);
return &(it_event->second);
}
-void csensor_handle_info::get_reg_event_types(event_type_vector &event_types)
+void sensor_handle_info::get_reg_event_types(event_type_vector &event_types)
{
auto it_event = m_reg_event_infos.begin();
}
}
-bool csensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb, void *user_data)
+bool sensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb, void *user_data)
{
- creg_event_info event_info;
+ reg_event_info event_info;
auto it_event = m_reg_event_infos.find(event_type);
event_info.m_cb = cb;
event_info.m_user_data = user_data;
- m_reg_event_infos.insert(pair<unsigned int,creg_event_info> (event_type, event_info));
+ m_reg_event_infos.insert(pair<unsigned int,reg_event_info> (event_type, event_info));
return true;
}
-bool csensor_handle_info::delete_reg_event_info(unsigned int event_type)
+bool sensor_handle_info::delete_reg_event_info(unsigned int event_type)
{
auto it_event = m_reg_event_infos.find(event_type);
return true;
}
-void csensor_handle_info::clear_all_events(void)
+void sensor_handle_info::clear_all_events(void)
{
m_reg_event_infos.clear();
}
-unsigned long long csensor_handle_info::renew_event_id(void)
+unsigned long long sensor_handle_info::renew_event_id(void)
{
return m_event_id++;
}
-bool csensor_handle_info::change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency)
+bool sensor_handle_info::change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency)
{
auto it_event = m_reg_event_infos.find(event_type);
return true;
}
-bool csensor_handle_info::change_reg_event_maincontext(unsigned int event_type, GMainContext *maincontext)
+bool sensor_handle_info::change_reg_event_maincontext(unsigned int event_type, GMainContext *maincontext)
{
auto it_event = m_reg_event_infos.find(event_type);
return true;
}
-void csensor_handle_info::get_batch(unsigned int &interval, unsigned int &latency)
+void sensor_handle_info::get_batch(unsigned int &interval, unsigned int &latency)
{
if (m_reg_event_infos.empty()) {
DBG("No events are registered for client %s", get_client_name());
latency = min_latency;
}
-unsigned int csensor_handle_info::get_reg_event_count(void)
+unsigned int sensor_handle_info::get_reg_event_count(void)
{
return m_reg_event_infos.size();
}
*
*/
-#ifndef CSENSOR_HANDLE_INFO_H_
-#define CSENSOR_HANDLE_INFO_H_
+#ifndef _SENSOR_HANDLE_INFO_H_
+#define _SENSOR_HANDLE_INFO_H_
-#include <creg_event_info.h>
+#include <reg_event_info.h>
#include <command_channel.h>
#include <sensor_logs.h>
#include <string.h>
#include <unordered_map>
#include <glib.h>
-typedef std::unordered_map<unsigned int,creg_event_info> event_info_map;
+typedef std::unordered_map<unsigned int,reg_event_info> event_info_map;
-class csensor_handle_info {
+class sensor_handle_info {
public:
int m_handle;
sensor_id_t m_sensor_id;
sensor_accuracy_changed_cb_t m_accuracy_cb;
void *m_accuracy_user_data;
- csensor_handle_info();
- ~csensor_handle_info();
+ sensor_handle_info();
+ ~sensor_handle_info();
bool add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, int cb_type, void *cb,void *user_data);
bool delete_reg_event_info(unsigned int event_type);
bool change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency);
bool change_reg_event_maincontext(unsigned int event_type, GMainContext *maincontext);
- creg_event_info* get_reg_event_info(const unsigned int event_type);
+ reg_event_info* get_reg_event_info(const unsigned int event_type);
void get_reg_event_types(event_type_vector &event_types);
void get_batch(unsigned int &interval, unsigned int &latency);
unsigned int get_reg_event_count(void);
};
-#endif /* CSENSOR_HANDLE_INFO_H_ */
+#endif /* _SENSOR_HANDLE_INFO_H_ */
*
*/
-#include <cclient_info_manager.h>
+#include <client_info_manager.h>
#include <sensor_logs.h>
#include <csocket.h>
using std::pair;
using std::string;
-cclient_info_manager::cclient_info_manager()
+client_info_manager::client_info_manager()
{
}
-cclient_info_manager::~cclient_info_manager()
+client_info_manager::~client_info_manager()
{
m_clients.clear();
}
-cclient_info_manager& cclient_info_manager::get_instance()
+client_info_manager& client_info_manager::get_instance()
{
- static cclient_info_manager inst;
+ static client_info_manager inst;
return inst;
}
-bool cclient_info_manager::get_registered_events(int client_id, sensor_id_t sensor_id, event_type_vector &event_vec)
+bool client_info_manager::get_registered_events(int client_id, sensor_id_t sensor_id, event_type_vector &event_vec)
{
AUTOLOCK(m_mutex);
}
-bool cclient_info_manager::register_event(int client_id, sensor_id_t sensor_id, unsigned int event_type)
+bool client_info_manager::register_event(int client_id, sensor_id_t sensor_id, unsigned int event_type)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::unregister_event(int client_id, sensor_id_t sensor_id, unsigned int event_type)
+bool client_info_manager::unregister_event(int client_id, sensor_id_t sensor_id, unsigned int event_type)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned latency)
+bool client_info_manager::set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned latency)
{
AUTOLOCK(m_mutex);
return it_record->second.set_batch(sensor_id, interval, latency);
}
-bool cclient_info_manager::get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
+bool client_info_manager::get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
{
AUTOLOCK(m_mutex);
return it_record->second.get_batch(sensor_id, interval, latency);
}
-bool cclient_info_manager::set_option(int client_id, sensor_id_t sensor_id, int option)
+bool client_info_manager::set_option(int client_id, sensor_id_t sensor_id, int option)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::set_wakeup(int client_id, sensor_id_t sensor_id, int wakeup)
+bool client_info_manager::set_wakeup(int client_id, sensor_id_t sensor_id, int wakeup)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool start)
+bool client_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool start)
{
AUTOLOCK(m_mutex);
}
-bool cclient_info_manager::is_started(int client_id, sensor_id_t sensor_id)
+bool client_info_manager::is_started(int client_id, sensor_id_t sensor_id)
{
AUTOLOCK(m_mutex);
return it_record->second.is_started(sensor_id);
}
-int cclient_info_manager::create_client_record(void)
+int client_info_manager::create_client_record(void)
{
AUTOLOCK(m_mutex);
int client_id = 0;
- cclient_sensor_record client_record;
+ client_sensor_record client_record;
while (m_clients.count(client_id) > 0)
client_id++;
client_record.set_client_id(client_id);
- m_clients.insert(pair<int,cclient_sensor_record> (client_id, client_record));
+ m_clients.insert(pair<int,client_sensor_record> (client_id, client_record));
return client_id;
}
-bool cclient_info_manager::remove_client_record(int client_id)
+bool client_info_manager::remove_client_record(int client_id)
{
AUTOLOCK(m_mutex);
}
-bool cclient_info_manager::has_client_record(int client_id)
+bool client_info_manager::has_client_record(int client_id)
{
AUTOLOCK(m_mutex);
}
-void cclient_info_manager::set_client_info(int client_id, pid_t pid, const string &name)
+void client_info_manager::set_client_info(int client_id, pid_t pid, const string &name)
{
AUTOLOCK(m_mutex);
return;
}
-const char* cclient_info_manager::get_client_info(int client_id)
+const char* client_info_manager::get_client_info(int client_id)
{
AUTOLOCK(m_mutex);
return it_record->second.get_client_info();
}
-bool cclient_info_manager::set_permission(int client_id, int permission)
+bool client_info_manager::set_permission(int client_id, int permission)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::get_permission(int client_id, int &permission)
+bool client_info_manager::get_permission(int client_id, int &permission)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::create_sensor_record(int client_id, sensor_id_t sensor_id)
+bool client_info_manager::create_sensor_record(int client_id, sensor_id_t sensor_id)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::remove_sensor_record(int client_id, sensor_id_t sensor_id)
+bool client_info_manager::remove_sensor_record(int client_id, sensor_id_t sensor_id)
{
AUTOLOCK(m_mutex);
}
-bool cclient_info_manager::has_sensor_record(int client_id, sensor_id_t sensor_id)
+bool client_info_manager::has_sensor_record(int client_id, sensor_id_t sensor_id)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::has_sensor_record(int client_id)
+bool client_info_manager::has_sensor_record(int client_id)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::get_listener_ids(sensor_id_t sensor_id, unsigned int event_type, client_id_vec &id_vec)
+bool client_info_manager::get_listener_ids(sensor_id_t sensor_id, unsigned int event_type, client_id_vec &id_vec)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::get_event_socket(int client_id, csocket &socket)
+bool client_info_manager::get_event_socket(int client_id, csocket &socket)
{
AUTOLOCK(m_mutex);
return true;
}
-bool cclient_info_manager::set_event_socket(int client_id, const csocket &socket)
+bool client_info_manager::set_event_socket(int client_id, const csocket &socket)
{
AUTOLOCK(m_mutex);
*
*/
-#ifndef CCLIENT_INFO_MANAGER_H_
-#define CCLIENT_INFO_MANAGER_H_
+#ifndef _CLIENT_INFO_MANAGER_H_
+#define _CLIENT_INFO_MANAGER_H_
-#include <cclient_sensor_record.h>
+#include <client_sensor_record.h>
#include <unordered_map>
#include <sensor_logs.h>
#include <cmutex.h>
#include <vector>
-typedef std::unordered_map<int,cclient_sensor_record> client_id_sensor_record_map;
+typedef std::unordered_map<int,client_sensor_record> client_id_sensor_record_map;
typedef std::vector<int> client_id_vec;
-class cclient_info_manager {
+class client_info_manager {
public:
- static cclient_info_manager& get_instance();
+ static client_info_manager& get_instance();
int create_client_record(void);
bool remove_client_record(int client_id);
bool has_client_record(int client_id);
client_id_sensor_record_map m_clients;
cmutex m_mutex;
- cclient_info_manager();
- ~cclient_info_manager();
- cclient_info_manager(cclient_info_manager const&) {};
- cclient_info_manager& operator=(cclient_info_manager const&);
+ client_info_manager();
+ ~client_info_manager();
+ client_info_manager(client_info_manager const&) {};
+ client_info_manager& operator=(client_info_manager const&);
};
-#endif /* CCLIENT_INFO_MANAGER_H_ */
+#endif /* _CLIENT_INFO_MANAGER_H_ */
*
*/
-#include <cclient_sensor_record.h>
+#include <client_sensor_record.h>
#include <sensor_logs.h>
using std::pair;
using std::string;
-cclient_sensor_record::cclient_sensor_record()
+client_sensor_record::client_sensor_record()
: m_client_id(0)
, m_pid(-1)
, m_permission(SENSOR_PERMISSION_NONE)
}
-cclient_sensor_record::~cclient_sensor_record()
+client_sensor_record::~client_sensor_record()
{
m_sensor_usages.clear();
close_event_socket();
}
-bool cclient_sensor_record::register_event(sensor_id_t sensor_id, unsigned int event_type)
+bool client_sensor_record::register_event(sensor_id_t sensor_id, unsigned int event_type)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
- csensor_usage usage;
+ sensor_usage usage;
usage.register_event(event_type);
- m_sensor_usages.insert(pair<sensor_id_t,csensor_usage>(sensor_id, usage));
+ m_sensor_usages.insert(pair<sensor_id_t,sensor_usage>(sensor_id, usage));
return true;
}
return true;
}
-bool cclient_sensor_record::unregister_event(sensor_id_t sensor_id, unsigned int event_type)
+bool client_sensor_record::unregister_event(sensor_id_t sensor_id, unsigned int event_type)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return true;
}
-bool cclient_sensor_record::set_option(sensor_id_t sensor_id, int option)
+bool client_sensor_record::set_option(sensor_id_t sensor_id, int option)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
- csensor_usage usage;
+ sensor_usage usage;
usage.m_option = option;
- m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
+ m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
} else {
it_usage->second.m_option = option;
}
return true;
}
-bool cclient_sensor_record::set_wakeup(sensor_id_t sensor_id, int wakeup)
+bool client_sensor_record::set_wakeup(sensor_id_t sensor_id, int wakeup)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
- csensor_usage usage;
+ sensor_usage usage;
usage.m_wakeup = wakeup;
- m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
+ m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
} else {
it_usage->second.m_wakeup = wakeup;
}
return true;
}
-bool cclient_sensor_record::set_start(sensor_id_t sensor_id, bool start)
+bool client_sensor_record::set_start(sensor_id_t sensor_id, bool start)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
- csensor_usage usage;
+ sensor_usage usage;
usage.m_start = start;
- m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
+ m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
} else {
it_usage->second.m_start = start;
}
return true;
}
-bool cclient_sensor_record::is_started(sensor_id_t sensor_id)
+bool client_sensor_record::is_started(sensor_id_t sensor_id)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return it_usage->second.m_start;
}
-bool cclient_sensor_record::set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency)
+bool client_sensor_record::set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency)
{
auto it_usage = m_sensor_usages.find(sensor_id);
if (it_usage == m_sensor_usages.end()) {
- csensor_usage usage;
+ sensor_usage usage;
usage.m_interval = interval;
usage.m_latency = latency;
- m_sensor_usages.insert(pair<sensor_id_t, csensor_usage>(sensor_id, usage));
+ m_sensor_usages.insert(pair<sensor_id_t, sensor_usage>(sensor_id, usage));
} else {
it_usage->second.m_interval = interval;
it_usage->second.m_latency = latency;
return true;
}
-bool cclient_sensor_record::get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
+bool client_sensor_record::get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return true;
}
-bool cclient_sensor_record::is_listening_event(sensor_id_t sensor_id, unsigned int event_type)
+bool client_sensor_record::is_listening_event(sensor_id_t sensor_id, unsigned int event_type)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return false;
}
-bool cclient_sensor_record::add_sensor_usage(sensor_id_t sensor_id)
+bool client_sensor_record::add_sensor_usage(sensor_id_t sensor_id)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return false;
}
- csensor_usage usage;
- m_sensor_usages.insert(pair<sensor_id_t,csensor_usage> (sensor_id, usage));
+ sensor_usage usage;
+ m_sensor_usages.insert(pair<sensor_id_t,sensor_usage> (sensor_id, usage));
return true;
}
-bool cclient_sensor_record::remove_sensor_usage(sensor_id_t sensor_id)
+bool client_sensor_record::remove_sensor_usage(sensor_id_t sensor_id)
{
auto it_usage = m_sensor_usages.find(sensor_id);
return true;
}
-bool cclient_sensor_record::has_sensor_usage(void)
+bool client_sensor_record::has_sensor_usage(void)
{
if (m_sensor_usages.empty())
return false;
}
-bool cclient_sensor_record::has_sensor_usage(sensor_id_t sensor_id)
+bool client_sensor_record::has_sensor_usage(sensor_id_t sensor_id)
{
auto it_usage = m_sensor_usages.find(sensor_id);
}
-bool cclient_sensor_record::get_registered_events(sensor_id_t sensor_id, event_type_vector &event_vec)
+bool client_sensor_record::get_registered_events(sensor_id_t sensor_id, event_type_vector &event_vec)
{
auto it_usage = m_sensor_usages.find(sensor_id);
}
-void cclient_sensor_record::set_client_id(int client_id)
+void client_sensor_record::set_client_id(int client_id)
{
m_client_id = client_id;
}
-void cclient_sensor_record::set_client_info(pid_t pid, const string &name)
+void client_sensor_record::set_client_info(pid_t pid, const string &name)
{
char client_info[NAME_MAX + 32];
m_pid = pid;
m_client_info.assign(client_info);
}
-const char* cclient_sensor_record::get_client_info(void)
+const char* client_sensor_record::get_client_info(void)
{
return m_client_info.c_str();
}
-void cclient_sensor_record::set_permission(int permission)
+void client_sensor_record::set_permission(int permission)
{
m_permission = permission;
}
-int cclient_sensor_record::get_permission(void)
+int client_sensor_record::get_permission(void)
{
return m_permission;
}
-void cclient_sensor_record::set_event_socket(const csocket &socket)
+void client_sensor_record::set_event_socket(const csocket &socket)
{
m_event_socket = socket;
}
-void cclient_sensor_record::get_event_socket(csocket &socket)
+void client_sensor_record::get_event_socket(csocket &socket)
{
socket = m_event_socket;
}
-bool cclient_sensor_record::close_event_socket(void)
+bool client_sensor_record::close_event_socket(void)
{
return m_event_socket.close();
}
*
*/
-#ifndef CCLIENT_SENSOR_RECORD_H_
-#define CCLIENT_SENSOR_RECORD_H_
+#ifndef _CLIENT_SENSOR_RECORD_H_
+#define _CLIENT_SENSOR_RECORD_H_
#include <sensor_internal.h>
#include <sf_common.h>
-#include <csensor_usage.h>
+#include <sensor_usage.h>
#include <csocket.h>
#include <unordered_map>
#include <string>
-typedef std::unordered_map<sensor_id_t, csensor_usage> sensor_usage_map;
+typedef std::unordered_map<sensor_id_t, sensor_usage> sensor_usage_map;
-class cclient_sensor_record {
+class client_sensor_record {
public:
- cclient_sensor_record();
- ~cclient_sensor_record();
+ client_sensor_record();
+ ~client_sensor_record();
void set_client_id(int client_id);
sensor_usage_map m_sensor_usages;
};
-#endif /* CCLIENT_SENSOR_RECORD_H_ */
+#endif /* _CLIENT_SENSOR_RECORD_H_ */
}
-cclient_info_manager& command_worker::get_client_info_manager(void)
+client_info_manager& command_worker::get_client_info_manager(void)
{
- return cclient_info_manager::get_instance();
+ return client_info_manager::get_instance();
}
-csensor_event_dispatcher& command_worker::get_event_dispathcher(void)
+sensor_event_dispatcher& command_worker::get_event_dispathcher(void)
{
- return csensor_event_dispatcher::get_instance();
+ return sensor_event_dispatcher::get_instance();
}
void insert_priority_list(unsigned int event_type)
*
*/
-#ifndef COMMAND_WORKER_H_
-#define COMMAND_WORKER_H_
+#ifndef _COMMAND_WORKER_H_
+#define _COMMAND_WORKER_H_
#include <worker_thread.h>
-#include <cclient_info_manager.h>
-#include <csensor_event_dispatcher.h>
+#include <client_info_manager.h>
+#include <sensor_event_dispatcher.h>
#include <sensor_base.h>
#include <map>
#include <cpacket.h>
int get_permission(void);
bool is_permission_allowed(void);
- static cclient_info_manager& get_client_info_manager(void);
- static csensor_event_dispatcher& get_event_dispathcher(void);
+ static client_info_manager& get_client_info_manager(void);
+ static sensor_event_dispatcher& get_event_dispathcher(void);
public:
command_worker(const csocket& socket);
virtual ~command_worker();
};
-#endif /* COMMAND_WORKER_H_ */
+#endif /* _COMMAND_WORKER_H_ */
void init_dbus(void);
void fini_dbus(void);
-#endif /* SENSORD_GDBUS_H_ */
+#endif /* _DBUS_UTIL_H_ */
*
*/
-#include <cconfig.h>
+#include <device_config.h>
#include <fstream>
#include <string>
using std::string;
using std::istringstream;
-cconfig::cconfig(void)
+device_config::device_config(void)
{
}
-cconfig::~cconfig(void)
+device_config::~device_config(void)
{
}
-bool cconfig::get_device_id(void)
+bool device_config::get_device_id(void)
{
const string INFO_INI_PATH = "/etc/info.ini";
const string START_DELIMETER = "Model=";
*
*/
-#ifndef _CCONFIG_H_
-#define _CCONFIG_H_
+#ifndef _DEVICE_CONFIG_H_
+#define _DEVICE_CONFIG_H_
#include <string>
#include <unordered_map>
#include <sensor_logs.h>
-class cconfig
+class device_config
{
protected:
virtual bool load_config(const std::string& config_path) = 0;
std::string m_device_id;
public:
- cconfig();
- virtual ~cconfig();
+ device_config();
+ virtual ~device_config();
bool get_device_id(void);
};
-#endif /* _CCONFIG_H_ */
+#endif /* _DEVICE_CONFIG_H_ */
int get_permission(int sock_fd);
};
-#endif /* COMMAND_WORKER_H_ */
+#endif /* _PERMISSION_CHECKER_H_ */
*/
#include <physical_sensor.h>
-#include <csensor_event_queue.h>
+#include <sensor_event_queue.h>
#define UNKNOWN_NAME "UNKNOWN_SENSOR"
virtual bool get_properties(sensor_properties_s &properties);
};
-#endif
+#endif /* _PHYSICAL_SENSOR_H_ */
*
*/
-#include <cplugin_info_list.h>
+#include <plugin_info_list.h>
#include <algorithm>
this->wakeup = wakeup;
}
-bool cplugin_info_list::comp_interval_info(cinterval_info a, cinterval_info b)
+bool plugin_info_list::comp_interval_info(cinterval_info a, cinterval_info b)
{
return a.interval < b.interval;
}
-bool cplugin_info_list::comp_batch_info(cbatch_info a, cbatch_info b)
+bool plugin_info_list::comp_batch_info(cbatch_info a, cbatch_info b)
{
return a.latency < b.latency;
}
-cinterval_info_iterator cplugin_info_list::find_if_interval_info(int client_id, bool is_processor)
+cinterval_info_iterator plugin_info_list::find_if_interval_info(int client_id, bool is_processor)
{
auto iter = m_interval_info_list.begin();
return iter;
}
-cbatch_info_iterator cplugin_info_list::find_if_batch_info(int client_id)
+cbatch_info_iterator plugin_info_list::find_if_batch_info(int client_id)
{
auto iter = m_batch_info_list.begin();
return iter;
}
-cwakeup_info_iterator cplugin_info_list::find_if_wakeup_info(int client_id)
+cwakeup_info_iterator plugin_info_list::find_if_wakeup_info(int client_id)
{
auto iter = m_wakeup_info_list.begin();
return iter;
}
-bool cplugin_info_list::add_interval(int client_id, unsigned int interval, bool is_processor)
+bool plugin_info_list::add_interval(int client_id, unsigned int interval, bool is_processor)
{
auto iter = find_if_interval_info(client_id, is_processor);
return true;
}
-bool cplugin_info_list::delete_interval(int client_id, bool is_processor)
+bool plugin_info_list::delete_interval(int client_id, bool is_processor)
{
auto iter = find_if_interval_info(client_id, is_processor);
return true;
}
-unsigned int cplugin_info_list::get_interval(int client_id, bool is_processor)
+unsigned int plugin_info_list::get_interval(int client_id, bool is_processor)
{
auto iter = find_if_interval_info(client_id, is_processor);
return iter->interval;
}
-unsigned int cplugin_info_list::get_min_interval(void)
+unsigned int plugin_info_list::get_min_interval(void)
{
if (m_interval_info_list.empty())
return 0;
return iter->interval;
}
-bool cplugin_info_list::add_batch(int client_id, unsigned int latency)
+bool plugin_info_list::add_batch(int client_id, unsigned int latency)
{
auto iter = find_if_batch_info(client_id);
return true;
}
-bool cplugin_info_list::delete_batch(int client_id)
+bool plugin_info_list::delete_batch(int client_id)
{
auto iter = find_if_batch_info(client_id);
return true;
}
-unsigned int cplugin_info_list::get_batch(int client_id)
+unsigned int plugin_info_list::get_batch(int client_id)
{
auto iter = find_if_batch_info(client_id);
return iter->latency;
}
-unsigned int cplugin_info_list::get_max_batch(void)
+unsigned int plugin_info_list::get_max_batch(void)
{
if (m_batch_info_list.empty())
return 0;
return iter->latency;
}
-bool cplugin_info_list::add_wakeup(int client_id, int wakeup)
+bool plugin_info_list::add_wakeup(int client_id, int wakeup)
{
auto iter = find_if_wakeup_info(client_id);
return true;
}
-bool cplugin_info_list::delete_wakeup(int client_id)
+bool plugin_info_list::delete_wakeup(int client_id)
{
auto iter = find_if_wakeup_info(client_id);
return true;
}
-int cplugin_info_list::get_wakeup(int client_id)
+int plugin_info_list::get_wakeup(int client_id)
{
auto iter = find_if_wakeup_info(client_id);
return iter->wakeup;
}
-int cplugin_info_list::is_wakeup_on(void)
+int plugin_info_list::is_wakeup_on(void)
{
if (m_wakeup_info_list.empty())
return -1;
*
*/
-#ifndef _CPLUGIN_INFO_LIST_CLASS_H_
-#define _CPLUGIN_INFO_LIST_CLASS_H_
+#ifndef _PLUGIN_INFO_LIST_H_
+#define _PLUGIN_INFO_LIST_H_
#include <list>
typedef std::list<cwakeup_info>::iterator cwakeup_info_iterator;
-class cplugin_info_list
+class plugin_info_list
{
private:
static bool comp_interval_info(cinterval_info a, cinterval_info b);
int get_wakeup(int client_id);
int is_wakeup_on(void);
};
-#endif
+#endif /* _PLUGIN_INFO_LIST_H_ */
#include <virtual_sensor.h>
#include <auto_rotation_sensor.h>
#include <sensor_plugin_loader.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
#include <auto_rotation_alg.h>
#include <auto_rotation_alg_emul.h>
, m_rotation_time(1) // rotation state is valid from initial state, so set rotation time to non-zero value
, m_alg(NULL)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
if (!config.get(SENSOR_TYPE_AUTO_ROTATION, ELEMENT_VENDOR, m_vendor)) {
ERR("[VENDOR] is empty\n");
#include <fusion_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
#include <algorithm>
using std::string;
, m_magnetic_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
m_name = string(SENSOR_NAME);
m_enable_fusion = 0;
#include <sf_common.h>
#include <gravity_sensor.h>
#include <sensor_plugin_loader.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
if (!fusion_sensor_hal)
#include <sf_common.h>
#include <linear_accel_sensor.h>
#include <sensor_plugin_loader.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
m_name = string(SENSOR_NAME);
m_enable_linear_accel = 0;
#include <orientation_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
if (!fusion_sensor_hal)
#include <gaming_rv_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_accuracy(-1)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
if (!fusion_sensor_hal)
#include <geomagnetic_rv_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
if (!fusion_sensor_hal)
#include <rv_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
// Will check if fusion_sensor is in the list of hal sensors.
sensor_hal *fusion_sensor_hal = sensor_plugin_loader::get_instance().get_sensor_hal(SENSOR_HAL_TYPE_FUSION);
#include <tilt_sensor.h>
#include <sensor_plugin_loader.h>
#include <orientation_filter.h>
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
using std::string;
using std::vector;
, m_fusion_sensor(NULL)
, m_time(0)
{
- cvirtual_sensor_config &config = cvirtual_sensor_config::get_instance();
+ virtual_sensor_config &config = virtual_sensor_config::get_instance();
m_name = string(SENSOR_NAME);
register_supported_event(TILT_RAW_DATA_EVENT);
#include <utility>
#include <functional>
-#include <csensor_event_queue.h>
+#include <sensor_event_queue.h>
using std::make_pair;
using std::vector;
if (m_client <= 0)
return false;
- csensor_event_queue::get_instance().push(event, event_length);
+ sensor_event_queue::get_instance().push(event, event_length);
return true;
}
if (m_client <= 0)
return false;
- csensor_event_queue::get_instance().push(event);
+ sensor_event_queue::get_instance().push(event);
return true;
}
if (m_client <= 0)
return false;
- csensor_event_queue::get_instance().push(event);
+ sensor_event_queue::get_instance().push(event);
return true;
}
if (m_client <= 0)
return false;
- csensor_event_queue::get_instance().push(event);
+ sensor_event_queue::get_instance().push(event);
return true;
}
if (m_client <= 0)
return false;
- csensor_event_queue::get_instance().push(event);
+ sensor_event_queue::get_instance().push(event);
return true;
}
*/
#include <string>
#include <sensor_internal.h>
-#include <cplugin_info_list.h>
+#include <plugin_info_list.h>
#include <cmutex.h>
#include <sensor_logs.h>
int m_permission;
- cplugin_info_list m_plugin_info_list;
+ plugin_info_list m_plugin_info_list;
cmutex m_plugin_info_list_mutex;
unsigned int m_client;
static unsigned long long get_timestamp(timeval *t);
};
-#endif
+#endif /* _SENSOR_BASE_H_ */
*
*/
-#include <csensor_event_dispatcher.h>
+#include <sensor_event_dispatcher.h>
#include <sensor_logs.h>
#include <sf_common.h>
#include <thread>
#define MAX_PENDING_CONNECTION 32
-csensor_event_dispatcher::csensor_event_dispatcher()
+sensor_event_dispatcher::sensor_event_dispatcher()
: m_lcd_on(false)
{
}
-csensor_event_dispatcher::~csensor_event_dispatcher() { }
+sensor_event_dispatcher::~sensor_event_dispatcher() { }
-csensor_event_dispatcher& csensor_event_dispatcher::get_instance()
+sensor_event_dispatcher& sensor_event_dispatcher::get_instance()
{
- static csensor_event_dispatcher inst;
+ static sensor_event_dispatcher inst;
return inst;
}
-bool csensor_event_dispatcher::run(void)
+bool sensor_event_dispatcher::run(void)
{
INFO("Starting Event Dispatcher\n");
return false;
}
- thread accepter(&csensor_event_dispatcher::accept_connections, this);
+ thread accepter(&sensor_event_dispatcher::accept_connections, this);
accepter.detach();
- thread dispatcher(&csensor_event_dispatcher::dispatch_event, this);
+ thread dispatcher(&sensor_event_dispatcher::dispatch_event, this);
dispatcher.detach();
return true;
}
-void csensor_event_dispatcher::accept_event_channel(csocket client_socket)
+void sensor_event_dispatcher::accept_event_channel(csocket client_socket)
{
int client_id;
event_channel_ready_t event_channel_ready;
- cclient_info_manager& client_info_manager = get_client_info_manager();
+ client_info_manager& client_info_manager = get_client_info_manager();
client_socket.set_connection_mode();
}
}
-void csensor_event_dispatcher::accept_connections(void)
+void sensor_event_dispatcher::accept_connections(void)
{
INFO("Event channel acceptor is started.\n");
INFO("New client connected (socket_fd : %d)\n", client_socket.get_socket_fd());
- thread event_channel_creator(&csensor_event_dispatcher::accept_event_channel, this, client_socket);
+ thread event_channel_creator(&sensor_event_dispatcher::accept_event_channel, this, client_socket);
event_channel_creator.detach();
}
}
-void csensor_event_dispatcher::dispatch_event(void)
+void sensor_event_dispatcher::dispatch_event(void)
{
const int MAX_SYNTH_PER_SENSOR = 5;
}
-void csensor_event_dispatcher::send_sensor_events(vector< pair<void*, int> > &events)
+void sensor_event_dispatcher::send_sensor_events(vector< pair<void*, int> > &events)
{
sensor_event_t *sensor_events = NULL;
- cclient_info_manager& client_info_manager = get_client_info_manager();
+ client_info_manager& client_info_manager = get_client_info_manager();
const int RESERVED_CLIENT_CNT = 20;
static client_id_vec id_vec(RESERVED_CLIENT_CNT);
}
}
-void csensor_event_dispatcher::send_sensorhub_events(void* events)
+void sensor_event_dispatcher::send_sensorhub_events(void* events)
{
sensorhub_event_t *sensor_hub_events;
- cclient_info_manager& client_info_manager = get_client_info_manager();
+ client_info_manager& client_info_manager = get_client_info_manager();
const int RESERVED_CLIENT_CNT = 20;
static client_id_vec id_vec(RESERVED_CLIENT_CNT);
free(sensor_hub_events);
}
-cclient_info_manager& csensor_event_dispatcher::get_client_info_manager(void)
+client_info_manager& sensor_event_dispatcher::get_client_info_manager(void)
{
- return cclient_info_manager::get_instance();
+ return client_info_manager::get_instance();
}
-csensor_event_queue& csensor_event_dispatcher::get_event_queue(void)
+sensor_event_queue& sensor_event_dispatcher::get_event_queue(void)
{
- return csensor_event_queue::get_instance();
+ return sensor_event_queue::get_instance();
}
-bool csensor_event_dispatcher::is_record_event(unsigned int event_type)
+bool sensor_event_dispatcher::is_record_event(unsigned int event_type)
{
return false;
}
-void csensor_event_dispatcher::put_last_event(unsigned int event_type, const sensor_event_t &event)
+void sensor_event_dispatcher::put_last_event(unsigned int event_type, const sensor_event_t &event)
{
AUTOLOCK(m_last_events_mutex);
m_last_events[event_type] = event;
}
-bool csensor_event_dispatcher::get_last_event(unsigned int event_type, sensor_event_t &event)
+bool sensor_event_dispatcher::get_last_event(unsigned int event_type, sensor_event_t &event)
{
AUTOLOCK(m_last_events_mutex);
return true;
}
-bool csensor_event_dispatcher::has_active_virtual_sensor(virtual_sensor *sensor)
+bool sensor_event_dispatcher::has_active_virtual_sensor(virtual_sensor *sensor)
{
AUTOLOCK(m_active_virtual_sensors_mutex);
}
-virtual_sensors csensor_event_dispatcher::get_active_virtual_sensors(void)
+virtual_sensors sensor_event_dispatcher::get_active_virtual_sensors(void)
{
AUTOLOCK(m_active_virtual_sensors_mutex);
}
};
-void csensor_event_dispatcher::sort_sensor_events(vector< pair<void*, int> > &events)
+void sensor_event_dispatcher::sort_sensor_events(vector< pair<void*, int> > &events)
{
std::sort(events.begin(), events.end(), sort_comp());
}
-void csensor_event_dispatcher::request_last_event(int client_id, sensor_id_t sensor_id)
+void sensor_event_dispatcher::request_last_event(int client_id, sensor_id_t sensor_id)
{
- cclient_info_manager& client_info_manager = get_client_info_manager();
+ client_info_manager& client_info_manager = get_client_info_manager();
event_type_vector event_vec;
csocket client_socket;
}
-bool csensor_event_dispatcher::add_active_virtual_sensor(virtual_sensor * sensor)
+bool sensor_event_dispatcher::add_active_virtual_sensor(virtual_sensor * sensor)
{
AUTOLOCK(m_active_virtual_sensors_mutex);
return true;
}
-bool csensor_event_dispatcher::delete_active_virtual_sensor(virtual_sensor * sensor)
+bool sensor_event_dispatcher::delete_active_virtual_sensor(virtual_sensor * sensor)
{
AUTOLOCK(m_active_virtual_sensors_mutex);
#define _SENSOR_EVENT_DISPATCHER_H_
#include <sf_common.h>
-#include <csensor_event_queue.h>
-#include <cclient_info_manager.h>
+#include <sensor_event_queue.h>
+#include <client_info_manager.h>
#include <csocket.h>
#include <virtual_sensor.h>
#include <unordered_map>
typedef std::unordered_map<unsigned int, sensor_event_t> event_type_last_event_map;
typedef std::list<virtual_sensor *> virtual_sensors;
-class csensor_event_dispatcher
+class sensor_event_dispatcher
{
private:
bool m_lcd_on;
virtual_sensors m_active_virtual_sensors;
cmutex m_active_virtual_sensors_mutex;
- csensor_event_dispatcher();
- ~csensor_event_dispatcher();
- csensor_event_dispatcher(csensor_event_dispatcher const&) {};
- csensor_event_dispatcher& operator=(csensor_event_dispatcher const&);
+ sensor_event_dispatcher();
+ ~sensor_event_dispatcher();
+ sensor_event_dispatcher(sensor_event_dispatcher const&) {};
+ sensor_event_dispatcher& operator=(sensor_event_dispatcher const&);
void accept_connections(void);
void accept_event_channel(csocket client_socket);
void dispatch_event(void);
void send_sensor_events(std::vector< std::pair<void*, int> > &events);
void send_sensorhub_events(void* events);
- static cclient_info_manager& get_client_info_manager(void);
- static csensor_event_queue& get_event_queue(void);
+ static client_info_manager& get_client_info_manager(void);
+ static sensor_event_queue& get_event_queue(void);
bool is_record_event(unsigned int event_type);
void put_last_event(unsigned int event_type, const sensor_event_t &event);
void sort_sensor_events(std::vector< std::pair<void*, int> > &events);
public:
- static csensor_event_dispatcher& get_instance();
+ static sensor_event_dispatcher& get_instance();
bool run(void);
void request_last_event(int client_id, sensor_id_t sensor_id);
bool delete_active_virtual_sensor(virtual_sensor *sensor);
};
-#endif
+#endif /* _SENSOR_EVENT_DISPATCHER_H_ */
*
*/
+#ifndef _SENSOR_EVENT_POLLER_H_
+#define _SENSOR_EVENT_POLLER_H_
+
#include <map>
#include <poller.h>
#include <physical_sensor.h>
bool is_data_ready(int fd);
bool process_event(int fd);
};
+
+#endif /* _SENSOR_EVENT_POLLER_H_ */
*
*/
-#include <csensor_event_queue.h>
+#include <sensor_event_queue.h>
#include "sensor_logs.h"
-csensor_event_queue& csensor_event_queue::get_instance()
+sensor_event_queue& sensor_event_queue::get_instance()
{
- static csensor_event_queue inst;
+ static sensor_event_queue inst;
return inst;
}
-void csensor_event_queue::push_internal(void *event, int length)
+void sensor_event_queue::push_internal(void *event, int length)
{
lock l(m_mutex);
bool wake = m_queue.empty();
m_cond_var.notify_one();
}
-void* csensor_event_queue::pop(int *length)
+void* sensor_event_queue::pop(int *length)
{
ulock u(m_mutex);
while (m_queue.empty())
return event.first;
}
-void csensor_event_queue::push(sensor_event_t *event, int event_length)
+void sensor_event_queue::push(sensor_event_t *event, int event_length)
{
push_internal(event, event_length);
}
*
*/
-#if !defined(_CSENSOR_EVENT_QUEUE_CLASS_H_)
-#define _CSENSOR_EVENT_QUEUE_CLASS_H_
+#ifndef _SENSOR_EVENT_QUEUE_H_
+#define _SENSOR_EVENT_QUEUE_H_
+
#include <sf_common.h>
#include <cstring>
#include <utility>
extern std::set<unsigned int> priority_list;
-class csensor_event_queue
+class sensor_event_queue
{
private:
static const unsigned int QUEUE_FULL_SIZE = 1000;
typedef std::lock_guard<std::mutex> lock;
typedef std::unique_lock<std::mutex> ulock;
- csensor_event_queue() {};
- ~csensor_event_queue() {};
- csensor_event_queue(const csensor_event_queue &) {};
- csensor_event_queue& operator=(const csensor_event_queue &);
+ sensor_event_queue() {};
+ ~sensor_event_queue() {};
+ sensor_event_queue(const sensor_event_queue &) {};
+ sensor_event_queue& operator=(const sensor_event_queue &);
void push_internal(void *event, int length);
public:
- static csensor_event_queue& get_instance();
+ static sensor_event_queue& get_instance();
void push(sensor_event_t *event, int event_length);
void* pop(int *length);
};
-#endif
+#endif /* _SENSOR_EVENT_QUEUE_H_*/
*
*/
-#if !defined(_SENSOR_PLUGIN_LOADER_CLASS_H_)
-#define _SENSOR_PLUGIN_LOADER_CLASS_H_
+#ifndef _SENSOR_PLUGIN_LOADER_H_
+#define _SENSOR_PLUGIN_LOADER_H_
#include <sensor_common.h>
#include <sensor_types.h>
std::vector<sensor_base *> get_sensors(sensor_type_t type);
std::vector<sensor_base*> get_virtual_sensors(void);
};
-#endif /* _SENSOR_PLUGIN_LOADER_CLASS_H_ */
+#endif /* _SENSOR_PLUGIN_LOADER_H_ */
*/
#include <sensor_internal.h>
-#include <csensor_usage.h>
+#include <sensor_usage.h>
#include <sensor_logs.h>
-csensor_usage::csensor_usage()
+sensor_usage::sensor_usage()
: m_interval(POLL_MAX_HZ_MS)
, m_latency(0)
, m_option(SENSOR_OPTION_DEFAULT)
{
}
-csensor_usage::~csensor_usage()
+sensor_usage::~sensor_usage()
{
m_reg_events.clear();
}
-bool csensor_usage::register_event(unsigned int event_type)
+bool sensor_usage::register_event(unsigned int event_type)
{
auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
return true;
}
-bool csensor_usage::unregister_event(unsigned int event_type)
+bool sensor_usage::unregister_event(unsigned int event_type)
{
auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type);
return true;
}
-bool csensor_usage::is_event_registered(unsigned int event_type)
+bool sensor_usage::is_event_registered(unsigned int event_type)
{
auto it_event = find (m_reg_events.begin(), m_reg_events.end(), event_type);
*
*/
-#ifndef CSENSOR_USAGE_H_
-#define CSENSOR_USAGE_H_
+#ifndef _SENSOR_USAGE_H_
+#define _SENSOR_USAGE_H_
#include <sf_common.h>
#include <algorithm>
typedef std::vector<unsigned int> reg_event_vector;
-class csensor_usage {
+class sensor_usage {
public:
unsigned int m_interval;
unsigned int m_latency;
reg_event_vector m_reg_events;
bool m_start;
- csensor_usage();
- ~csensor_usage();
+ sensor_usage();
+ ~sensor_usage();
bool register_event(unsigned int event_type);
bool unregister_event(unsigned int event_type);
bool is_event_registered(unsigned int event_type);
};
-#endif /* CSENSOR_USAGE_H_ */
+#endif /* _SENSOR_USAGE_H_ */
}
}
- csensor_event_dispatcher::get_instance().run();
+ sensor_event_dispatcher::get_instance().run();
thread client_accepter(&server::accept_client, this);
client_accepter.detach();
*
*/
-#ifndef SERVER_H_
-#define SERVER_H_
+#ifndef _SERVER_H_
+#define _SERVER_H_
#include <glib.h>
#include <csocket.h>
static server& get_instance();
};
-#endif
+#endif /* _SERVER_H_ */
*/
#include <virtual_sensor.h>
-#include <csensor_event_dispatcher.h>
+#include <sensor_event_dispatcher.h>
virtual_sensor::virtual_sensor()
bool virtual_sensor::activate(void)
{
- return csensor_event_dispatcher::get_instance().add_active_virtual_sensor(this);
+ return sensor_event_dispatcher::get_instance().add_active_virtual_sensor(this);
}
bool virtual_sensor::deactivate(void)
{
- return csensor_event_dispatcher::get_instance().delete_active_virtual_sensor(this);
+ return sensor_event_dispatcher::get_instance().delete_active_virtual_sensor(this);
}
bool m_hardware_fusion;
};
-#endif
+#endif /* _VIRTUAL_SENSOR_H_ */
*
*/
-#include <cvirtual_sensor_config.h>
+#include <virtual_sensor_config.h>
#include "sensor_logs.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#define DEFAULT_ATTR3 "value3"
#define DEFAULT_DEVICE "Default"
-cvirtual_sensor_config::cvirtual_sensor_config()
+virtual_sensor_config::virtual_sensor_config()
{
}
-cvirtual_sensor_config& cvirtual_sensor_config::get_instance(void)
+virtual_sensor_config& virtual_sensor_config::get_instance(void)
{
static bool load_done = false;
- static cvirtual_sensor_config inst;
+ static virtual_sensor_config inst;
if (!load_done) {
inst.load_config(VIRTUAL_SENSOR_CONFIG_FILE_PATH);
return inst;
}
-bool cvirtual_sensor_config::load_config(const string& config_path)
+bool virtual_sensor_config::load_config(const string& config_path)
{
xmlDocPtr doc;
xmlNodePtr cur;
- DBG("cvirtual_sensor_config::load_config(\"%s\") is called!\n",config_path.c_str());
+ DBG("virtual_sensor_config::load_config(\"%s\") is called!\n",config_path.c_str());
doc = xmlParseFile(config_path.c_str());
free(prop);
//insert device to device_list
- m_virtual_sensor_config[device_type];
+ m_virtual_sensor_configs[device_type];
DBG("<type=\"%s\">\n",device_type.c_str());
virtual_sensor_node_ptr = device_node_ptr->xmlChildrenNode;
continue;
}
- m_virtual_sensor_config[device_type][(const char*)virtual_sensor_node_ptr->name];
+ m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name];
DBG("<type=\"%s\"><%s>\n",device_type.c_str(),(const char*)virtual_sensor_node_ptr->name);
element_node_ptr = virtual_sensor_node_ptr->xmlChildrenNode;
}
//insert Element to Model
- m_virtual_sensor_config[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name];
+ m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name];
DBG("<type=\"%s\"><%s><%s>\n",device_type.c_str(),(const char*)virtual_sensor_node_ptr->name,(const char*)element_node_ptr->name);
attr_ptr = element_node_ptr->properties;
free(prop);
//insert attribute to Element
- m_virtual_sensor_config[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name][key]=value;
+ m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name][key]=value;
DBG("<type=\"%s\"><%s><%s \"%s\"=\"%s\">\n",device_type.c_str(),(const char*)virtual_sensor_node_ptr->name,(const char*)element_node_ptr->name,key.c_str(),value.c_str());
attr_ptr = attr_ptr->next;
}
return true;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, string& value)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, string& value)
{
- auto it_device_list = m_virtual_sensor_config.find(m_device_id);
+ auto it_device_list = m_virtual_sensor_configs.find(m_device_id);
- if (it_device_list == m_virtual_sensor_config.end()) {
+ if (it_device_list == m_virtual_sensor_configs.end()) {
ERR("There is no <%s> device\n",m_device_id.c_str());
m_device_id = DEFAULT_DEVICE;
- it_device_list = m_virtual_sensor_config.find(m_device_id);
+ it_device_list = m_virtual_sensor_configs.find(m_device_id);
- if (it_device_list == m_virtual_sensor_config.end()) {
+ if (it_device_list == m_virtual_sensor_configs.end()) {
ERR("There is no Default device\n");
return false;
}
return true;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, float *value)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, float *value)
{
string str_value;
return true;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, int *value)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, const string& attr, int *value)
{
string str_value;
return true;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, string& value)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, string& value)
{
if (get(sensor_type, element, DEFAULT_ATTR, value))
return true;
return false;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, float *value, int count)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, float *value, int count)
{
if (count == 1)
{
return false;
}
-bool cvirtual_sensor_config::get(const string& sensor_type, const string& element, int *value, int count)
+bool virtual_sensor_config::get(const string& sensor_type, const string& element, int *value, int count)
{
if (count == 1)
{
return false;
}
-bool cvirtual_sensor_config::is_supported(const string& sensor_type)
+bool virtual_sensor_config::is_supported(const string& sensor_type)
{
- auto it_device_list = m_virtual_sensor_config.find(m_device_id);
+ auto it_device_list = m_virtual_sensor_configs.find(m_device_id);
- if (it_device_list == m_virtual_sensor_config.end())
+ if (it_device_list == m_virtual_sensor_configs.end())
return false;
auto it_virtual_sensor_list = it_device_list->second.find(sensor_type);
*
*/
-#if !defined(_CVIRTUAL_SENSOR_CONFIG_CLASS_H_)
-#define _CVIRTUAL_SENSOR_CONFIG_CLASS_H_
+#ifndef _VIRTUAL_SENSOR_CONFIG_H_
+#define _VIRTUAL_SENSOR_CONFIG_H_
-#include <cconfig.h>
+#include <device_config.h>
#define VIRTUAL_SENSOR_CONFIG_FILE_PATH "/usr/etc/virtual_sensors.xml"
* ...
*/
-typedef std::unordered_map<std::string,Virtual_sensor> virtual_sensor_config;
+typedef std::unordered_map<std::string,Virtual_sensor> virtual_sensor_configs;
/*
* a Virtual_sensor_config represents virtual_sensors.xml
* <ORIENTATION/>
*
*/
-typedef std::unordered_map<std::string,virtual_sensor_config> virtual_sensor_device_config;
+typedef std::unordered_map<std::string,virtual_sensor_configs> virtual_sensor_device_configs;
/*
* a virtual_sensor_device_config represents virtual_sensors.xml
* <emulator/>
*
*/
-class cvirtual_sensor_config : public cconfig
+class virtual_sensor_config : public device_config
{
private:
- cvirtual_sensor_config();
- cvirtual_sensor_config(cvirtual_sensor_config const&) {};
- cvirtual_sensor_config& operator=(cvirtual_sensor_config const&);
+ virtual_sensor_config();
+ virtual_sensor_config(virtual_sensor_config const&) {};
+ virtual_sensor_config& operator=(virtual_sensor_config const&);
bool load_config(const std::string& config_path);
- virtual_sensor_device_config m_virtual_sensor_config;
+ virtual_sensor_device_configs m_virtual_sensor_configs;
public:
- static cvirtual_sensor_config& get_instance(void);
+ static virtual_sensor_config& get_instance(void);
bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, std::string& value);
bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, float *value);
bool is_supported(const std::string &sensor_type);
};
-#endif
+#endif /* _VIRTUAL_SENSOR_CONFIG_H_ */
void set_context(void *ctx);
};
-#endif
+#endif /* _WORKER_THREAD_H_ */
*
*/
-#if !defined(_CBASE_LOCK_CLASS_H_)
-#define _CBASE_LOCK_CLASS_H_
+#ifndef _CBASE_LOCK_H_
+#define _CBASE_LOCK_H_
#include <pthread.h>
~Autolock();
};
-#endif
-// End of a file
+#endif /* _CBASE_LOCK_H_ */
*
*/
-#if !defined(_CMUTEX_CLASS_H_)
-#define _CMUTEX_CLASS_H_
+#ifndef _CMUTEX_H_
+#define _CMUTEX_H_
#include "cbase_lock.h"
pthread_mutex_t m_mutex;
};
-#endif
-// End of a file
+#endif /* _CMUTEX_H_ */
*
*/
-#if !defined(_CPACKET_CLASS_H_)
-#define _CPACKET_CLASS_H_
+#ifndef _CPACKET_H_
+#define _CPACKET_H_
typedef struct packet_header {
int cmd;
packet_header *m_packet;
};
-#endif
-// End of a file
+#endif /* _CPACKET_H_ */
*
*/
-#ifndef CSOCKET_H_
-#define CSOCKET_H_
+#ifndef _CSOCKET_H_
+#define _CSOCKET_H_
#include <sys/types.h>
#include <sys/socket.h>
int m_recv_flags;
};
-#endif /* CSOCKET_H_ */
+#endif /* _CSOCKET_H_ */
*
*/
-#ifndef __SENSOR_COMMON_H__
-#define __SENSOR_COMMON_H__
+#ifndef _SENSOR_COMMON_H_
+#define _SENSOR_COMMON_H_
#ifndef DEPRECATED
#define DEPRECATED __attribute__((deprecated))
#endif
-#endif
-//! End of a file
+#endif /* _SENSOR_COMMON_H_ */
/* TODO: use get_sensors() instead of get_properties() */
virtual bool get_properties(uint32_t id, sensor_properties_s &properties) = 0;
};
-#endif /*_SENSOR_HAL_H_*/
+#endif /* _SENSOR_HAL_H_ */
*
*/
-#if !defined(_COMMON_H_)
-#define _COMMON_H_
+#ifndef _SENSOR_LOGS_H_
+#define _SENSOR_LOGS_H_
#ifndef __cplusplus
#include <stdbool.h>
}
#endif
-#endif
-//! End of a file
+#endif /* _SENSOR_LOGS_H_ */
*
*/
-#include <sensor_logs.h>
-
-#if !defined(_SF_COMMON_H_)
+#ifndef _SF_COMMON_H_
#define _SF_COMMON_H_
+
#include <unistd.h>
#include <sensor_common.h>
#include <string>
#include <vector>
+#include <sensor_logs.h>
#define COMMAND_CHANNEL_PATH "/tmp/sensord_command_socket"
#define EVENT_CHANNEL_PATH "/tmp/sensord_event_socket"
#define BIO_SENSOR_PRIVELEGE_NAME "sensord::bio"
#define BIO_SENSOR_ACCESS_RIGHT "rw"
-#endif
+#endif /* _SF_COMMON_H_ */