From: kibak.yoon Date: Tue, 10 May 2016 12:22:45 +0000 (+0900) Subject: sensord: clean up the code detected by style checker X-Git-Tag: submit/tizen/20160523.074005~1^2~15 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3a49a521b6c89cd2bc9fd706725f46fb0a43d3e7;p=platform%2Fcore%2Fsystem%2Fsensord.git sensord: clean up the code detected by style checker - [LNE_R_TWS] Redundant blank line at the start of a code block should be deleted. - [SPC_M_SEP] Missing space after , - [SPC_M_SEP] Missing space before ( in while( - [SPC_M_SEP] Extra space after ( - [SPC_M_OPR] Missing spaces around < - ... Change-Id: I238c4c0be773ef2b9f0067a09b35049ed322cacd Signed-off-by: kibak.yoon --- diff --git a/src/client/client.cpp b/src/client/client.cpp index a884b40e..73f41801 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -110,7 +110,7 @@ void clean_up(void) } } -static int get_power_save_state (void) +static int get_power_save_state(void) { int state = 0; int pm_state; @@ -155,7 +155,6 @@ static void power_save_state_cb(keynode_t *node, void *data) } } - void restore_session(void) { AUTOLOCK(lock); @@ -178,7 +177,7 @@ void restore_session(void) while (it_sensor != sensors.end()) { cmd_channel = new(std::nothrow) command_channel(); - retm_if (!cmd_channel, "Failed to allocate memory"); + retm_if(!cmd_channel, "Failed to allocate memory"); if (!cmd_channel->create_channel()) { _E("%s failed to create command channel for %s", get_client_name(), get_sensor_name(*it_sensor)); @@ -240,7 +239,6 @@ static bool get_events_diff(event_type_vector &a_vec, event_type_vector &b_vec, return !(add_vec.empty() && del_vec.empty()); } - static bool change_sensor_rep(sensor_id_t sensor_id, sensor_rep &prev_rep, sensor_rep &cur_rep) { int client_id; @@ -253,7 +251,7 @@ static bool change_sensor_rep(sensor_id_t sensor_id, sensor_rep &prev_rep, senso } client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), false, "Invalid client id : %d, %s, %s", client_id, get_sensor_name(sensor_id), get_client_name()); + retvm_if((client_id < 0), false, "Invalid client id : %d, %s, %s", client_id, get_sensor_name(sensor_id), get_client_name()); get_events_diff(prev_rep.event_types, cur_rep.event_types, add_event_types, del_event_types); @@ -278,7 +276,6 @@ static bool change_sensor_rep(sensor_id_t sensor_id, sensor_rep &prev_rep, senso return false; } } - } if (prev_rep.active && !del_event_types.empty()) { @@ -336,7 +333,7 @@ static bool get_sensor_list(void) API int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *sensor_count) { - retvm_if (!get_sensor_list(), -EPERM, "Fail to get sensor list from server"); + retvm_if(!get_sensor_list(), -EPERM, "Fail to get sensor list from server"); vector sensor_infos = sensor_info_manager::get_instance().get_infos(type); @@ -363,7 +360,7 @@ API int sensord_get_sensors(sensor_type_t type, sensor_t **list, int *sensor_cou API int sensord_get_default_sensor(sensor_type_t type, sensor_t *sensor) { - retvm_if (!get_sensor_list(), -EPERM, "Fail to get sensor list from server"); + retvm_if(!get_sensor_list(), -EPERM, "Fail to get sensor list from server"); const sensor_info *info; @@ -398,7 +395,7 @@ API bool sensord_get_type(sensor_t sensor, sensor_type_t *type) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !type, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !type, NULL, "Invalid param: sensor (%p), type(%p)", sensor, type); *type = info->get_type(); @@ -410,7 +407,7 @@ API const char* sensord_get_name(sensor_t sensor) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info), + retvm_if(!sensor_info_manager::get_instance().is_valid(info), NULL, "Invalid param: sensor (%p)", sensor); return info->get_name(); @@ -420,7 +417,7 @@ API const char* sensord_get_vendor(sensor_t sensor) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info), + retvm_if(!sensor_info_manager::get_instance().is_valid(info), NULL, "Invalid param: sensor (%p)", sensor); return info->get_vendor(); @@ -430,7 +427,7 @@ API bool sensord_get_privilege(sensor_t sensor, sensor_privilege_t *privilege) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !privilege, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !privilege, false, "Invalid param: sensor (%p), privilege(%p)", sensor, privilege); *privilege = info->get_privilege(); @@ -442,7 +439,7 @@ API bool sensord_get_min_range(sensor_t sensor, float *min_range) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !min_range, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !min_range, false, "Invalid param: sensor (%p), min_range(%p)", sensor, min_range); *min_range = info->get_min_range(); @@ -454,7 +451,7 @@ API bool sensord_get_max_range(sensor_t sensor, float *max_range) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !max_range, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !max_range, false, "Invalid param: sensor (%p), max_range(%p)", sensor, max_range); *max_range = info->get_max_range(); @@ -466,7 +463,7 @@ API bool sensord_get_resolution(sensor_t sensor, float *resolution) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !resolution, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !resolution, false, "Invalid param: sensor (%p), resolution(%p)", sensor, resolution); *resolution = info->get_resolution(); @@ -478,7 +475,7 @@ API bool sensord_get_min_interval(sensor_t sensor, int *min_interval) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !min_interval, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !min_interval, false, "Invalid param: sensor (%p), min_interval(%p)", sensor, min_interval); *min_interval = info->get_min_interval(); @@ -490,7 +487,7 @@ API bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !fifo_count, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !fifo_count, false, "Invalid param: sensor (%p), fifo_count(%p)", sensor, fifo_count); *fifo_count = info->get_fifo_count(); @@ -502,7 +499,7 @@ API bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !max_batch_count, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !max_batch_count, false, "Invalid param: sensor (%p), max_batch_count(%p)", sensor, max_batch_count); *max_batch_count = info->get_max_batch_count(); @@ -514,7 +511,7 @@ API bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !event_types || !count, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !event_types || !count, false, "Invalid param: sensor (%p), event_types(%p), count(%p)", sensor, event_types, count); unsigned int event_type; @@ -533,7 +530,7 @@ API bool sensord_is_supported_event_type(sensor_t sensor, unsigned int event_typ { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info) || !event_type || !supported, + retvm_if(!sensor_info_manager::get_instance().is_valid(info) || !event_type || !supported, false, "Invalid param: sensor (%p), event_type(%p), supported(%p)", sensor, event_type, supported); *supported = info->is_supported_event(event_type); @@ -545,7 +542,7 @@ API bool sensord_is_wakeup_supported(sensor_t sensor) { sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info), + retvm_if(!sensor_info_manager::get_instance().is_valid(info), false, "Invalid param: sensor (%p)", sensor); return info->is_wakeup_supported(); @@ -561,7 +558,7 @@ API int sensord_connect(sensor_t sensor) sensor_info* info = sensor_to_sensor_info(sensor); - retvm_if (!sensor_info_manager::get_instance().is_valid(info), + retvm_if(!sensor_info_manager::get_instance().is_valid(info), OP_ERROR, "Invalid param: sensor (%p)", sensor); sensor_id_t sensor_id = info->get_id(); @@ -663,7 +660,7 @@ API bool sensord_disconnect(int handle) } client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); + retvm_if((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); _I("%s disconnects with %s[%d]", get_client_name(), get_sensor_name(sensor_id), handle); @@ -697,14 +694,13 @@ API bool sensord_disconnect(int handle) return true; } - static bool register_event(int handle, unsigned int event_type, unsigned int interval, int max_batch_latency, void* cb, void *user_data) { sensor_id_t sensor_id; sensor_rep prev_rep, cur_rep; bool ret; - retvm_if (!cb, false, "callback is NULL"); + retvm_if(!cb, false, "callback is NULL"); AUTOLOCK(lock); @@ -760,7 +756,7 @@ API bool sensord_unregister_event(int handle, unsigned int event_type) if (!sensor_client_info::get_instance().unregister_event(handle, event_type)) { _E("%s try to unregister non registered event %s[%#x] for sensor %s[%d]", - get_client_name(),get_event_name(event_type), event_type, get_sensor_name(sensor_id), handle); + get_client_name(), get_event_name(event_type), event_type, get_sensor_name(sensor_id), handle); return false; } @@ -771,15 +767,13 @@ API bool sensord_unregister_event(int handle, unsigned int event_type) sensor_client_info::get_instance().register_event(handle, event_type, prev_interval, prev_latency, prev_cb, prev_user_data); return ret; - } - API bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t cb, void *user_data) { sensor_id_t sensor_id; - retvm_if (!cb, false, "callback is NULL"); + retvm_if(!cb, false, "callback is NULL"); AUTOLOCK(lock); @@ -788,14 +782,12 @@ API bool sensord_register_accuracy_cb(int handle, sensor_accuracy_changed_cb_t c return false; } - _I("%s registers accuracy_changed_cb for sensor %s[%d] with cb: %#x, user_data: %#x", get_client_name(), get_sensor_name(sensor_id), handle, cb, user_data); sensor_client_info::get_instance().register_accuracy_cb(handle, cb , user_data); return true; - } API bool sensord_unregister_accuracy_cb(int handle) @@ -809,7 +801,6 @@ API bool sensord_unregister_accuracy_cb(int handle) return false; } - _I("%s unregisters accuracy_changed_cb for sensor %s[%d]", get_client_name(), get_sensor_name(sensor_id), handle); @@ -818,7 +809,6 @@ API bool sensord_unregister_accuracy_cb(int handle) return true; } - API bool sensord_start(int handle, int option) { sensor_id_t sensor_id; @@ -833,7 +823,7 @@ API bool sensord_start(int handle, int option) return false; } - retvm_if ((option < 0) || (option >= SENSOR_OPTION_END), false, "Invalid option value : %d, handle: %d, %s, %s", + retvm_if((option < 0) || (option >= SENSOR_OPTION_END), false, "Invalid option value : %d, handle: %d, %s, %s", option, handle, get_sensor_name(sensor_id), get_client_name()); _I("%s starts %s[%d], with option: %d, power save state: %d", get_client_name(), get_sensor_name(sensor_id), @@ -874,10 +864,9 @@ API bool sensord_stop(int handle) return false; } - retvm_if ((sensor_state == SENSOR_STATE_STOPPED), true, "%s already stopped with %s[%d]", + retvm_if((sensor_state == SENSOR_STATE_STOPPED), true, "%s already stopped with %s[%d]", get_client_name(), get_sensor_name(sensor_id), handle); - _I("%s stops sensor %s[%d]", get_client_name(), get_sensor_name(sensor_id), handle); sensor_client_info::get_instance().get_sensor_rep(sensor_id, prev_rep); @@ -893,7 +882,6 @@ API bool sensord_stop(int handle) return ret; } - static bool change_event_batch(int handle, unsigned int event_type, unsigned int interval, unsigned int latency) { sensor_id_t sensor_id; @@ -982,10 +970,9 @@ API bool sensord_set_option(int handle, int option) return false; } - retvm_if ((option < 0) || (option >= SENSOR_OPTION_END), false, "Invalid option value : %d, handle: %d, %s, %s", + retvm_if((option < 0) || (option >= SENSOR_OPTION_END), false, "Invalid option value : %d, handle: %d, %s, %s", option, handle, get_sensor_name(sensor_id), get_client_name()); - sensor_client_info::get_instance().get_sensor_rep(sensor_id, prev_rep); sensor_client_info::get_instance().get_sensor_params(handle, prev_state, prev_option); @@ -1004,7 +991,6 @@ API bool sensord_set_option(int handle, int option) sensor_client_info::get_instance().set_sensor_option(handle, prev_option); return ret; - } API int sensord_set_attribute_int(int handle, int attribute, int value) @@ -1026,7 +1012,7 @@ API int sensord_set_attribute_int(int handle, int attribute, int value) } client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), -EPERM, + retvm_if((client_id < 0), -EPERM, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); @@ -1063,7 +1049,7 @@ API int sensord_set_attribute_str(int handle, int attribute, const char *value, value_len, value, handle, get_sensor_name(sensor_id), get_client_name()); client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), -EPERM, + retvm_if((client_id < 0), -EPERM, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); @@ -1093,7 +1079,7 @@ API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* senso int sensor_state; int client_id; - retvm_if ((!sensor_data), false, "sensor_data is NULL"); + retvm_if((!sensor_data), false, "sensor_data is NULL"); AUTOLOCK(lock); @@ -1109,7 +1095,7 @@ API bool sensord_get_data(int handle, unsigned int data_id, sensor_data_t* senso } client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); + retvm_if((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); if (sensor_state != SENSOR_STATE_STARTED) { _E("Sensor %s is not started for client %s with handle: %d, sensor_state: %d", get_sensor_name(sensor_id), get_client_name(), handle, sensor_state); @@ -1145,7 +1131,7 @@ API bool sensord_flush(int handle) } client_id = sensor_client_info::get_instance().get_client_id(); - retvm_if ((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); + retvm_if((client_id < 0), false, "Invalid client id : %d, handle: %d, %s, %s", client_id, handle, get_sensor_name(sensor_id), get_client_name()); if (sensor_state != SENSOR_STATE_STARTED) { _E("Sensor %s is not started for client %s with handle: %d, sensor_state: %d", get_sensor_name(sensor_id), get_client_name(), handle, sensor_state); diff --git a/src/client/client_common.h b/src/client/client_common.h index 3d688834..77e71f7f 100644 --- a/src/client/client_common.h +++ b/src/client/client_common.h @@ -20,7 +20,6 @@ #ifndef _CLIENT_COMMON_H_ #define _CLIENT_COMMON_H_ -/*header for each sensor type*/ #include #include #include diff --git a/src/client/command_channel.cpp b/src/client/command_channel.cpp index 7724278b..e4486b2a 100644 --- a/src/client/command_channel.cpp +++ b/src/client/command_channel.cpp @@ -28,8 +28,8 @@ command_channel::command_channel() : m_client_id(CLIENT_ID_INVALID) , m_sensor_id(UNKNOWN_SENSOR) { - } + command_channel::~command_channel() { if (m_command_socket.is_valid()) @@ -180,7 +180,6 @@ bool command_channel::cmd_get_sensor_list(void) return true; } - bool command_channel::cmd_hello(sensor_id_t sensor) { cpacket *packet; @@ -258,7 +257,6 @@ bool command_channel::cmd_byebye(void) if (m_command_socket.is_valid()) m_command_socket.close(); - m_client_id = CLIENT_ID_INVALID; m_sensor_id = UNKNOWN_SENSOR; @@ -413,7 +411,6 @@ bool command_channel::cmd_register_event(unsigned int event_type) return true; } - bool command_channel::cmd_register_events(event_type_vector &event_vec) { auto it_event = event_vec.begin(); @@ -467,7 +464,6 @@ bool command_channel::cmd_unregister_event(unsigned int event_type) return true; } - bool command_channel::cmd_unregister_events(event_type_vector &event_vec) { auto it_event = event_vec.begin(); diff --git a/src/client/sensor_client_info.cpp b/src/client/sensor_client_info.cpp index d34df176..a7dbf7ef 100644 --- a/src/client/sensor_client_info.cpp +++ b/src/client/sensor_client_info.cpp @@ -36,14 +36,12 @@ sensor_client_info::~sensor_client_info() { } - sensor_client_info& sensor_client_info::get_instance(void) { static sensor_client_info inst; return inst; } - int sensor_client_info::create_handle(sensor_id_t sensor) { sensor_handle_info handle_info; @@ -67,7 +65,7 @@ int sensor_client_info::create_handle(sensor_id_t sensor) handle_info.m_accuracy_cb = NULL; handle_info.m_accuracy_user_data = NULL; - m_sensor_handle_infos.insert(pair (handle, handle_info)); + m_sensor_handle_infos.insert(pair(handle, handle_info)); return handle; } @@ -87,7 +85,6 @@ bool sensor_client_info::delete_handle(int handle) return true; } - bool sensor_client_info::is_active() { AUTOLOCK(m_handle_info_lock); @@ -299,7 +296,6 @@ bool sensor_client_info::get_event_info(int handle, unsigned int event_type, uns if (!event_info) return NULL; - interval = event_info->m_interval; cb = event_info->m_cb; user_data = event_info->m_user_data; @@ -308,7 +304,6 @@ bool sensor_client_info::get_event_info(int handle, unsigned int event_type, uns return true; } - void sensor_client_info::get_listening_sensors(sensor_id_vector &sensors) { AUTOLOCK(m_handle_info_lock); @@ -321,7 +316,7 @@ void sensor_client_info::get_listening_sensors(sensor_id_vector &sensors) } sort(sensors.begin(), sensors.end()); - unique(sensors.begin(),sensors.end()); + unique(sensors.begin(), sensors.end()); } void sensor_client_info::get_sensor_rep(sensor_id_t sensor, sensor_rep& rep) { @@ -346,11 +341,11 @@ bool sensor_client_info::add_command_channel(sensor_id_t sensor, command_channel return false; } - m_command_channels.insert(pair (sensor, cmd_channel)); + m_command_channels.insert(pair(sensor, cmd_channel)); return true; - } + bool sensor_client_info::get_command_channel(sensor_id_t sensor, command_channel **cmd_channel) { auto it_channel = m_command_channels.find(sensor); @@ -365,7 +360,6 @@ bool sensor_client_info::get_command_channel(sensor_id_t sensor, command_channel return true; } - bool sensor_client_info::close_command_channel(void) { auto it_channel = m_command_channels.begin(); @@ -528,10 +522,8 @@ void sensor_client_info::get_active_event_types(sensor_id_t sensor, event_type_v sort(event_types.begin(), event_types.end()); unique_copy(event_types.begin(), event_types.end(), back_inserter(active_event_types)); - } - void sensor_client_info::get_all_handles(handle_vector &handles) { AUTOLOCK(m_handle_info_lock); @@ -544,29 +536,28 @@ void sensor_client_info::get_all_handles(handle_vector &handles) } } -void sensor_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); auto it_handle = m_sensor_handle_infos.begin(); while (it_handle != m_sensor_handle_infos.end()) { - if (it_handle->second.m_sensor_id == sensor) { - handles_info.insert(pair (it_handle->first, it_handle->second)); - } + if (it_handle->second.m_sensor_id == sensor) + handles_info.insert(pair(it_handle->first, it_handle->second)); ++it_handle; } } -void sensor_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 (it_handle->first, it_handle->second)); + handles_info.insert(pair(it_handle->first, it_handle->second)); ++it_handle; } } diff --git a/src/client/sensor_client_info.h b/src/client/sensor_client_info.h index f6383bc4..275e674c 100644 --- a/src/client/sensor_client_info.h +++ b/src/client/sensor_client_info.h @@ -48,8 +48,8 @@ using std::condition_variable; typedef vector handle_vector; typedef vector sensor_id_vector; -typedef unordered_map sensor_handle_info_map; -typedef unordered_map sensor_command_channel_map; +typedef unordered_map sensor_handle_info_map; +typedef unordered_map sensor_command_channel_map; typedef struct sensor_rep { bool active; @@ -120,4 +120,5 @@ private: cmutex m_handle_info_lock; }; + #endif /* _SENSOR_CLIENT_INFO_H_ */ diff --git a/src/client/sensor_event_listener.cpp b/src/client/sensor_event_listener.cpp index 63e51d9a..56cbfefe 100644 --- a/src/client/sensor_event_listener.cpp +++ b/src/client/sensor_event_listener.cpp @@ -82,13 +82,11 @@ void sensor_event_listener::operate_sensor(sensor_id_t sensor, int power_save_st if ((it_handle->second.m_sensor_state == SENSOR_STATE_STARTED) && power_save_state && !(it_handle->second.m_sensor_option & power_save_state)) { - m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_PAUSED); _I("%s's %s[%d] is paused", get_client_name(), get_sensor_name(sensor), it_handle->first); } else if ((it_handle->second.m_sensor_state == SENSOR_STATE_PAUSED) && (!power_save_state || (it_handle->second.m_sensor_option & power_save_state))) { - m_client_info.set_sensor_state(it_handle->first, SENSOR_STATE_STARTED); _I("%s's %s[%d] is resumed", get_client_name(), get_sensor_name(sensor), it_handle->first); } @@ -159,7 +157,6 @@ void sensor_event_listener::handle_events(void* event) m_client_info.get_all_handle_info(handles_info); for (auto it_handle = handles_info.begin(); it_handle != handles_info.end(); ++it_handle) { - sensor_handle_info &sensor_handle_info = it_handle->second; event_info = sensor_handle_info.get_reg_event_info(event_type); @@ -213,7 +210,7 @@ client_callback_info* sensor_event_listener::get_callback_info(sensor_id_t senso client_callback_info* callback_info; callback_info = new(std::nothrow)client_callback_info; - retvm_if (!callback_info, NULL, "Failed to allocate memory"); + retvm_if(!callback_info, NULL, "Failed to allocate memory"); callback_info->sensor = sensor_info_to_sensor(sensor_info_manager::get_instance().get_info(sensor_id)); callback_info->event_id = event_info->m_id; @@ -348,7 +345,6 @@ void sensor_event_listener::listen_events(void) if (m_hup_observer) m_hup_observer(); } - } bool sensor_event_listener::create_event_channel(void) @@ -394,13 +390,11 @@ bool sensor_event_listener::create_event_channel(void) return true; } - void sensor_event_listener::close_event_channel(void) { m_event_socket.close(); } - void sensor_event_listener::stop_event_listener(void) { const int THREAD_TERMINATING_TIMEOUT = 2; @@ -434,7 +428,6 @@ void sensor_event_listener::clear(void) m_client_info.set_client_id(CLIENT_ID_INVALID); } - void sensor_event_listener::set_hup_observer(hup_observer_t observer) { m_hup_observer = observer; @@ -450,7 +443,7 @@ bool sensor_event_listener::start_event_listener(void) m_event_socket.set_transfer_mode(); m_poller = new(std::nothrow) poller(m_event_socket.get_socket_fd()); - retvm_if (!m_poller, false, "Failed to allocate memory"); + retvm_if(!m_poller, false, "Failed to allocate memory"); set_thread_state(THREAD_STATE_START); diff --git a/src/client/sensor_event_listener.h b/src/client/sensor_event_listener.h index 5199d83b..1c944759 100644 --- a/src/client/sensor_event_listener.h +++ b/src/client/sensor_event_listener.h @@ -44,7 +44,7 @@ typedef std::vector handle_vector; typedef std::vector sensor_id_vector; -typedef std::unordered_map sensor_handle_info_map; +typedef std::unordered_map sensor_handle_info_map; typedef std::unordered_map sensor_command_channel_map; typedef struct { @@ -122,4 +122,5 @@ private: void set_thread_state(thread_state state); }; + #endif /* _SENSOR_EVENT_LISTENER_H_ */ diff --git a/src/client/sensor_handle_info.cpp b/src/client/sensor_handle_info.cpp index 6a58cb73..99647d70 100644 --- a/src/client/sensor_handle_info.cpp +++ b/src/client/sensor_handle_info.cpp @@ -35,7 +35,6 @@ sensor_handle_info::sensor_handle_info() , m_accuracy_cb(NULL) , m_accuracy_user_data(NULL) { - } sensor_handle_info::~sensor_handle_info() @@ -82,7 +81,7 @@ bool sensor_handle_info::add_reg_event_info(unsigned int event_type, unsigned in event_info.m_cb = cb; event_info.m_user_data = user_data; - m_reg_event_infos.insert(pair (event_type, event_info)); + m_reg_event_infos.insert(pair (event_type, event_info)); return true; } @@ -106,7 +105,6 @@ void sensor_handle_info::clear_all_events(void) m_reg_event_infos.clear(); } - unsigned long long sensor_handle_info::renew_event_id(void) { return m_event_id++; @@ -162,4 +160,3 @@ unsigned int sensor_handle_info::get_reg_event_count(void) { return m_reg_event_infos.size(); } - diff --git a/src/client/sensor_handle_info.h b/src/client/sensor_handle_info.h index 18361943..00eba280 100644 --- a/src/client/sensor_handle_info.h +++ b/src/client/sensor_handle_info.h @@ -26,7 +26,7 @@ #include #include -typedef std::unordered_map event_info_map; +typedef std::unordered_map event_info_map; class sensor_handle_info { public: @@ -59,5 +59,4 @@ private: static unsigned long long m_event_id; }; - #endif /* _SENSOR_HANDLE_INFO_H_ */ diff --git a/src/client/sensor_info_manager.cpp b/src/client/sensor_info_manager.cpp index 530eddde..a7a78109 100644 --- a/src/client/sensor_info_manager.cpp +++ b/src/client/sensor_info_manager.cpp @@ -34,7 +34,6 @@ sensor_info_manager::~sensor_info_manager() auto it_info = m_sensor_infos.begin(); while (it_info != m_sensor_infos.end()) { - delete it_info->second; ++it_info; } @@ -74,9 +73,8 @@ vector sensor_info_manager::get_infos(sensor_type_t type) else ret = m_sensor_infos.equal_range(type); - for (auto it_info = ret.first; it_info != ret.second; ++it_info) { + for (auto it_info = ret.first; it_info != ret.second; ++it_info) sensor_infos.push_back(it_info->second); - } return sensor_infos; } @@ -91,7 +89,6 @@ const sensor_info* sensor_info_manager::get_info(sensor_id_t id) return it_info->second; } - bool sensor_info_manager::is_valid(sensor_info* info) { auto it_info = m_info_set.find(info); diff --git a/src/client/sensor_info_manager.h b/src/client/sensor_info_manager.h index e36acc99..86fa8fed 100644 --- a/src/client/sensor_info_manager.h +++ b/src/client/sensor_info_manager.h @@ -50,4 +50,5 @@ private: id_to_info_map m_id_to_info_map; info_set m_info_set; }; + #endif /* _SENSOR_INFO_MANAGER_H_ */ diff --git a/src/client/sensor_internal.h b/src/client/sensor_internal.h index 7a0a3e14..c4c3fce7 100644 --- a/src/client/sensor_internal.h +++ b/src/client/sensor_internal.h @@ -174,7 +174,6 @@ bool sensord_get_fifo_count(sensor_t sensor, int *fifo_count); */ bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count); - /** * @brief Get the supported event types of this sensor. * @@ -185,7 +184,6 @@ bool sensord_get_max_batch_count(sensor_t sensor, int *max_batch_count); */ bool sensord_get_supported_event_types(sensor_t sensor, unsigned int **event_types, int *count); - /** * @brief Check a given event type is supporeted by this sensor. * @@ -284,7 +282,6 @@ bool sensord_unregister_accuracy_cb(int handle); * with SENSOR_OPTION_ALWAYS_ON, it continues to listening events even when LCD is off or in power save mode. * @return true on success, otherwise false. */ - bool sensord_start(int handle, int option); /** @@ -397,5 +394,4 @@ bool sensord_external_post(int handle, unsigned long long timestamp, const float } #endif - #endif diff --git a/src/client/sensor_internal_deprecated.h b/src/client/sensor_internal_deprecated.h index 469b8da9..31496db1 100644 --- a/src/client/sensor_internal_deprecated.h +++ b/src/client/sensor_internal_deprecated.h @@ -75,7 +75,7 @@ typedef struct { float sensor_resolution; } sensor_data_properties_t; -DEPRECATED int sf_is_sensor_event_available(sensor_type_t sensor_type , unsigned int event_type); +DEPRECATED int sf_is_sensor_event_available(sensor_type_t sensor_type, unsigned int event_type); DEPRECATED int sf_get_data_properties(unsigned int data_id, sensor_data_properties_t *return_data_properties); @@ -87,7 +87,7 @@ DEPRECATED int sf_check_rotation(unsigned long *rotation); * @fn int sf_connect(sensor_type_t sensor) * @brief This API connects a sensor type to respective sensor. The application calls with the type of the sensor (ex. ACCELEROMETER_SENSOR) and on basis of that server takes decision of which plug-in to be connected. Once sensor connected application can proceed for data processing. This API returns a positive handle which should be used by application to communicate on sensor type. * @param[in] sensor_type your desired sensor type - * @return if it succeed, it return handle value( >=0 ) , otherwise negative value return + * @return if it succeed, it return handle value( >=0 ), otherwise negative value return */ DEPRECATED int sf_connect(sensor_type_t sensor_type); @@ -95,57 +95,57 @@ DEPRECATED int sf_connect(sensor_type_t sensor_type); * @fn int sf_disconnect(int handle) * @brief This API disconnects an attached sensor from an application. Application must use the handle retuned after attaching the sensor. After detaching, the corresponding handle will be released. * @param[in] handle received handle value by sf_connect() - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ DEPRECATED int sf_disconnect(int handle); /** - * @fn int sf_start(int handle , int option) + * @fn int sf_start(int handle, int option) * @brief This API sends a start command to sensor server. This intimates server that the client side is ready to handle data and start processing. The parameter option should be '0' for current usages. * @param[in] handle received handle value by sf_connect() * @param[in] option With SENSOR_OPTION_DEFAULT, it stops to sense when LCD is off, and with SENSOR_OPTION_ALWAYS_ON, it continues to sense even when LCD is off - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ -DEPRECATED int sf_start(int handle , int option); +DEPRECATED int sf_start(int handle, int option); /** * @fn int sf_stop(int handle) * @brief This API sends a stop command to the Sensor server indicating that the data processing is stopped from application side for this time. * @param[in] handle received handle value by sf_connect() - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ DEPRECATED int sf_stop(int handle); /** - * @fn int sf_register_event(int handle , unsigned int event_type , event_conditon_t *event_condition , sensor_callback_func_t cb , void *user_data ) + * @fn int sf_register_event(int handle, unsigned int event_type, event_conditon_t *event_condition, sensor_callback_func_t cb, void *user_data ) * @brief This API registers a user defined callback function with a connected sensor for a particular event. This callback function will be called when there is a change in the state of respective sensor. user_data will be the parameter used during the callback call. Callback interval can be adjusted using even_contion_t argument. * @param[in] handle received handle value by sf_connect() * @param[in] event_type your desired event_type to register it * @param[in] event_condition input event_condition for special event. if you want to register without event_condition, just use a NULL value * @param[in] cb your define callback function * @param[in] user_data your option data that will be send when your define callback function called. if you don't have any option data, just use a NULL value - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ -DEPRECATED int sf_register_event(int handle , unsigned int event_type , event_condition_t *event_condition , sensor_callback_func_t cb , void *user_data ); +DEPRECATED int sf_register_event(int handle, unsigned int event_type, event_condition_t *event_condition, sensor_callback_func_t cb, void *user_data); /** * @fn int sf_unregister_event(int handle, unsigned int event_type) * @brief This API de-registers a user defined callback function with a sensor registered with the specified handle. After unsubscribe, no event will be sent to the application. * @param[in] handle received handle value by sf_connect() * @param[in] event_type your desired event_type that you want to unregister event - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ DEPRECATED int sf_unregister_event(int handle, unsigned int event_type); /** - * @fn int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values) + * @fn int sf_get_data(int handle, unsigned int data_id, sensor_data_t* values) * @brief This API gets raw data from a sensor with connecting the sensor-server. The type of sensor is supplied and return data is stored in the output parameter values []. * @param[in] handle received handle value by sf_connect() - * @param[in] data_id predefined data_ID as every sensor in own header - sensor_xxx.h , enum xxx_data_id {} + * @param[in] data_id predefined data_ID as every sensor in own header - sensor_xxx.h, enum xxx_data_id {} * @param[out] values return values - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ -DEPRECATED int sf_get_data(int handle , unsigned int data_id , sensor_data_t* values); +DEPRECATED int sf_get_data(int handle, unsigned int data_id, sensor_data_t* values); /** * @fn int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition) @@ -153,7 +153,7 @@ DEPRECATED int sf_get_data(int handle , unsigned int data_id , sensor_data_t* va * @param[in] handle received handle value by sf_connect() * @param[in] event_type your desired event_type that you want to unregister event * @param[in] event_condition your desired event condition that you want to change event - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ DEPRECATED int sf_change_event_condition(int handle, unsigned int event_type, event_condition_t *event_condition); @@ -162,7 +162,7 @@ DEPRECATED int sf_change_event_condition(int handle, unsigned int event_type, ev * @brief This API change sensor option . * @param[in] handle received handle value by sf_connect() * @param[in] option your desired option that you want to turn on sensor during LCD OFF - * @return if it succeed, it return zero value , otherwise negative value return + * @return if it succeed, it return zero value, otherwise negative value return */ DEPRECATED int sf_change_sensor_option(int handle, int option); @@ -177,10 +177,8 @@ DEPRECATED int sf_change_sensor_option(int handle, int option); */ DEPRECATED int sf_send_sensorhub_data(int handle, const char* data, int data_len); - #ifdef __cplusplus } #endif - #endif diff --git a/src/hal/sensor_hal_types.h b/src/hal/sensor_hal_types.h index 0e73602e..91630c40 100644 --- a/src/hal/sensor_hal_types.h +++ b/src/hal/sensor_hal_types.h @@ -113,7 +113,6 @@ typedef enum { SENSOR_DEVICE_STRESS_MONITOR, SENSOR_DEVICE_AUTOSESSION_EXERCISE, SENSOR_DEVICE_STAIR_TRACKER, - } sensor_device_type; /* @@ -138,7 +137,7 @@ typedef struct sensor_info_t { enum sensor_accuracy_t { SENSOR_ACCURACY_UNDEFINED = -1, SENSOR_ACCURACY_BAD = 0, - SENSOR_ACCURACY_NORMAL =1, + SENSOR_ACCURACY_NORMAL = 1, SENSOR_ACCURACY_GOOD = 2, SENSOR_ACCURACY_VERYGOOD = 3 }; diff --git a/src/sensor/accel/accel_sensor.cpp b/src/sensor/accel/accel_sensor.cpp index 90fd8bdd..3470850a 100644 --- a/src/sensor/accel/accel_sensor.cpp +++ b/src/sensor/accel/accel_sensor.cpp @@ -28,7 +28,6 @@ accel_sensor::accel_sensor() accel_sensor::~accel_sensor() { - } sensor_type_t accel_sensor::get_type(void) diff --git a/src/sensor/auto_rotation/auto_rotation_alg.h b/src/sensor/auto_rotation/auto_rotation_alg.h index ab280a2c..cfcc72de 100644 --- a/src/sensor/auto_rotation/auto_rotation_alg.h +++ b/src/sensor/auto_rotation/auto_rotation_alg.h @@ -31,4 +31,5 @@ public: virtual bool stop(void); virtual bool get_rotation(float acc[3], unsigned long long timestamp, int prev_rotation, int &rotation) = 0; }; + #endif /* _AUTO_ROTATION_ALG_H_ */ diff --git a/src/sensor/auto_rotation/auto_rotation_alg_emul.h b/src/sensor/auto_rotation/auto_rotation_alg_emul.h index 953d11d2..1c9357c8 100644 --- a/src/sensor/auto_rotation/auto_rotation_alg_emul.h +++ b/src/sensor/auto_rotation/auto_rotation_alg_emul.h @@ -32,4 +32,5 @@ public: private: int convert_rotation(int prev_rotation, float acc_pitch, float acc_theta); }; + #endif /* _AUTO_ROTATION_ALG_EMUL_H_ */ diff --git a/src/sensor/auto_rotation/auto_rotation_sensor.cpp b/src/sensor/auto_rotation/auto_rotation_sensor.cpp index e1d90f19..335d41eb 100644 --- a/src/sensor/auto_rotation/auto_rotation_sensor.cpp +++ b/src/sensor/auto_rotation/auto_rotation_sensor.cpp @@ -155,7 +155,6 @@ void auto_rotation_sensor::synthesize(const sensor_event_t& event) push(rotation_event); _D("Rotation: %d, ACC[0]: %f, ACC[1]: %f, ACC[2]: %f", rotation, event.data->values[0], event.data->values[1], event.data->values[2]); - return; } int auto_rotation_sensor::get_data(sensor_data_t **data, int *length) diff --git a/src/sensor/fusion/fusion_sensor.cpp b/src/sensor/fusion/fusion_sensor.cpp index 0a90e58d..ff56eadf 100644 --- a/src/sensor/fusion/fusion_sensor.cpp +++ b/src/sensor/fusion/fusion_sensor.cpp @@ -110,7 +110,7 @@ fusion_sensor::fusion_sensor() _I("m_accel_static_bias = (%f, %f, %f)", m_accel_static_bias[0], m_accel_static_bias[1], m_accel_static_bias[2]); - if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GYRO_STATIC_BIAS, m_gyro_static_bias,3)) { + if (!config.get(SENSOR_TYPE_FUSION, ELEMENT_GYRO_STATIC_BIAS, m_gyro_static_bias, 3)) { _E("[GYRO_STATIC_BIAS] is empty\n"); throw ENXIO; } @@ -304,8 +304,6 @@ void fusion_sensor::synthesize(const sensor_event_t &event, vector 0 ? M_PI/2.0 : -M_PI/2.0) +#define ARCTAN(x, y) ((x) == 0 ? 0 : (y) != 0 ? atan2((x), (y)) : (x) > 0 ? M_PI/2.0 : -M_PI/2.0) gravity_sensor::gravity_sensor() : m_fusion(NULL) diff --git a/src/sensor/hrm/hrm_sensor.cpp b/src/sensor/hrm/hrm_sensor.cpp index 04252268..aa48965c 100644 --- a/src/sensor/hrm/hrm_sensor.cpp +++ b/src/sensor/hrm/hrm_sensor.cpp @@ -30,5 +30,4 @@ hrm_sensor::hrm_sensor() hrm_sensor::~hrm_sensor() { - } diff --git a/src/sensor/orientation/orientation_sensor.cpp b/src/sensor/orientation/orientation_sensor.cpp index 091cb126..32e3ef73 100644 --- a/src/sensor/orientation/orientation_sensor.cpp +++ b/src/sensor/orientation/orientation_sensor.cpp @@ -248,8 +248,7 @@ void orientation_sensor::synthesize(const sensor_event_t &event, vector::euler_angles(const euler_angles& e) template euler_angles::~euler_angles() { - } template diff --git a/src/sensor/sensor_fusion/orientation_filter.cpp b/src/sensor/sensor_fusion/orientation_filter.cpp index 5af46ff3..7e1cd8d3 100644 --- a/src/sensor/sensor_fusion/orientation_filter.cpp +++ b/src/sensor/sensor_fusion/orientation_filter.cpp @@ -228,8 +228,8 @@ inline void orientation_filter::time_update() m_pred_cov = (m_tran_mat * m_pred_cov * tran(m_tran_mat)) + m_driv_cov; - for (int j=0; j::time_update() m_quat_driv = (m_quat_driv * quat_eu_er) * (TYPE) PI; m_quat_driv.quat_normalize(); - if (is_initialized(m_state_new)) - { + if (is_initialized(m_state_new)) { m_state_error.m_vec[0] = m_euler_error.m_ang.m_vec[0]; m_state_error.m_vec[1] = m_euler_error.m_ang.m_vec[1]; m_state_error.m_vec[2] = m_euler_error.m_ang.m_vec[2]; @@ -288,12 +287,9 @@ inline void orientation_filter::time_update_gaming_rv() euler_aid = quat2euler(m_quat_aid); euler_driv = quat2euler(m_quat_output); - if ((SQUARE(m_accel.m_data.m_vec[1]) < ACCEL_THRESHOLD) && (SQUARE(m_gyro.m_data.m_vec[0]) < GYRO_THRESHOLD)) - { - if ((SQUARE(m_accel.m_data.m_vec[0]) < ACCEL_THRESHOLD) && (SQUARE(m_gyro.m_data.m_vec[1]) < GYRO_THRESHOLD)) - { - if (SQUARE(m_gyro.m_data.m_vec[2]) < GYRO_THRESHOLD) - { + if ((SQUARE(m_accel.m_data.m_vec[1]) < ACCEL_THRESHOLD) && (SQUARE(m_gyro.m_data.m_vec[0]) < GYRO_THRESHOLD)) { + if ((SQUARE(m_accel.m_data.m_vec[0]) < ACCEL_THRESHOLD) && (SQUARE(m_gyro.m_data.m_vec[1]) < GYRO_THRESHOLD)) { + if (SQUARE(m_gyro.m_data.m_vec[2]) < GYRO_THRESHOLD) { euler_angles euler_gaming_rv(euler_aid.m_ang.m_vec[0], euler_aid.m_ang.m_vec[1], euler_driv.m_ang.m_vec[2]); m_quat_gaming_rv = euler2quat(euler_gaming_rv); @@ -319,22 +315,22 @@ inline void orientation_filter::measurement_update() iden.m_mat[0][0] = iden.m_mat[1][1] = iden.m_mat[2][2] = 1; iden.m_mat[3][3] = iden.m_mat[4][4] = iden.m_mat[5][5] = 1; - for (int j=0; j temp = iden; - for (int i=0; i::get_device_orientation(const sensor_data *a initialize_sensor_data(accel, gyro, magnetic); if (gyro != NULL && magnetic != NULL) { - orientation_triad_algorithm(); - compute_covariance(); - time_update(); - measurement_update(); - m_quaternion = m_quat_9axis; - } else if (!gyro && !magnetic) { - compute_accel_orientation(); - m_quaternion = m_quat_aid; - } else if (!gyro) { - orientation_triad_algorithm(); - m_quaternion = m_quat_aid; - } else if (!magnetic) { - compute_accel_orientation(); - compute_covariance(); - time_update_gaming_rv(); - measurement_update(); - m_quaternion = m_quat_gaming_rv; } } diff --git a/src/sensor/sensor_fusion/rotation_matrix.cpp b/src/sensor/sensor_fusion/rotation_matrix.cpp index fd3e6b5c..fa89881a 100644 --- a/src/sensor/sensor_fusion/rotation_matrix.cpp +++ b/src/sensor/sensor_fusion/rotation_matrix.cpp @@ -29,7 +29,6 @@ template T get_sign(T val) template rotation_matrix::rotation_matrix() : m_rot_mat() { - } template @@ -54,7 +53,6 @@ rotation_matrix::rotation_matrix(const rotation_matrix& rm) template rotation_matrix::~rotation_matrix() { - } template diff --git a/src/sensor/sensor_fusion/sensor_data.h b/src/sensor/sensor_fusion/sensor_data.h index 1fa3c5c7..68413698 100644 --- a/src/sensor/sensor_fusion/sensor_data.h +++ b/src/sensor/sensor_fusion/sensor_data.h @@ -51,7 +51,6 @@ public: const vect ref_vec); template friend void pre_process_data(sensor_data &data_out, const T *data_in, T *bias, int *sign, int scale); - }; #include "sensor_data.cpp" diff --git a/src/sensor/sensor_fusion/test/orientation_sensor.cpp b/src/sensor/sensor_fusion/test/orientation_sensor.cpp index 477b4db1..a67627ec 100644 --- a/src/sensor/sensor_fusion/test/orientation_sensor.cpp +++ b/src/sensor/sensor_fusion/test/orientation_sensor.cpp @@ -50,7 +50,6 @@ void orientation_sensor::get_device_orientation(sensor_data *accel_data, } orien_filter.get_device_orientation(accel_data, gyro_data, magnetic_data); - } -#endif +#endif /* _ORIENTATION_SENSOR_H_ */ diff --git a/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp b/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp index 4a3104d0..fc69bd55 100644 --- a/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/euler_angles_test/euler_angles_main.cpp @@ -26,10 +26,10 @@ int main() float arr2[4] = {0.6, 0.6, -.18, -.44}; float arr3[4] = {-0.5, -0.36, .43, .03}; - vect v0(arr0); - vect v1(arr1); - vect v2(arr2); - vect v3(arr3); + vect v0(arr0); + vect v1(arr1); + vect v2(arr2); + vect v3(arr3); quaternion q1(v2); quaternion q2(v3); diff --git a/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp index a9f801c4..3525c323 100644 --- a/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/gravity_sensor_test/gravity_sensor_main.cpp @@ -52,7 +52,7 @@ int main() sdata[0] = strtof(line_accel.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data accel_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n"; @@ -61,7 +61,7 @@ int main() sdata[0] = strtof(line_gyro.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data gyro_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n"; @@ -70,7 +70,7 @@ int main() sdata[0] = strtof(line_magnetic.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n"; diff --git a/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp index 302affa7..958559ab 100644 --- a/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/linear_acceleration_sensor_test/linear_acceleration_sensor_main.cpp @@ -52,7 +52,7 @@ int main() sdata[0] = strtof(line_accel.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data accel_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n"; @@ -61,7 +61,7 @@ int main() sdata[0] = strtof(line_gyro.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data gyro_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n"; @@ -70,7 +70,7 @@ int main() sdata[0] = strtof(line_magnetic.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n"; diff --git a/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp b/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp index 8227c3ab..05b17439 100644 --- a/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/matrix_test/matrix_main.cpp @@ -21,8 +21,8 @@ int main() { - float arr0[2][2] = {{-2.243, 2.57},{3.56, -3.02}}; - float arr1[2][2] = {{2.2, 2.5},{3.5, 3.0}}; + float arr0[2][2] = {{-2.243, 2.57}, {3.56, -3.02}}; + float arr1[2][2] = {{2.2, 2.5}, {3.5, 3.0}}; float arr5[3][2] = {{0.22, 4.56}, {3.652, 5.86}, {1.430, 0.45}}; float arr11[1][3] = {{2.0, 3.0, 4.0}}; float arr12[3][1] = {{2.0}, {1.0}, {3.0}}; @@ -46,83 +46,83 @@ int main() matrix m22(arr15); matrix m9(arr9); - cout<< "Constructor Test\n"; - cout<< "\n" << m6; + cout << "Constructor Test\n"; + cout << "\n" << m6; - cout<<"\n\nAddition\n"; + cout << "\n\nAddition\n"; m6 = m10 + m15; m13 = m11 + m11; - cout<< "\n" << m10 <<"\n"<< m15; - cout<< "\nSum:\n" << m6 << endl; - cout<< "\n" << m11 << "\n"<< m11; - cout<< "\nSum:\n" << m13 << endl; + cout << "\n" << m10 << "\n" << m15; + cout << "\nSum:\n" << m6 << endl; + cout << "\n" << m11 << "\n" << m11; + cout << "\nSum:\n" << m13 << endl; - cout<< "\n\n\nSubtraction\n"; + cout << "\n\n\nSubtraction\n"; m6 = m10 - m12; - cout<< "\n" << m10 << "\n" << m12; - cout<< "\nDifference:\n" << m6 << endl; + cout << "\n" << m10 << "\n" << m12; + cout << "\nDifference:\n" << m6 << endl; - cout<< "\n\n\nMultiplication\n"; + cout << "\n\n\nMultiplication\n"; m6 = m10 * m12; m3 = m1 * m2; matrix m7; m7 = m20 * m21; - cout<< "\n" << m10 << "\n" << m12; - cout<< "\nProduct:\n" << m6 << endl; - cout<< "\n" << m1 << "\n" << m2; - cout<< "\nProduct:\n" << m3 << endl; - cout<< "\n" << m20 << "\n" << m21; - cout<< "\nProduct:\n" << m7 << endl; - cout<< "\n" << m9 << "\n" << m21; + cout << "\n" << m10 << "\n" << m12; + cout << "\nProduct:\n" << m6 << endl; + cout << "\n" << m1 << "\n" << m2; + cout << "\nProduct:\n" << m3 << endl; + cout << "\n" << m20 << "\n" << m21; + cout << "\nProduct:\n" << m7 << endl; + cout << "\n" << m9 << "\n" << m21; m21 = m9 * m21; - cout<< "\nProduct:\n" << m21 << endl; + cout << "\nProduct:\n" << m21 << endl; - cout<< "\n\n\nDivision\n"; + cout << "\n\n\nDivision\n"; m3 = m1 / (float)2.5; - cout<< "\n" << m1 << "\n" << "2.5"; - cout<< "\nResult:\n" << m3 << endl; + cout << "\n" << m1 << "\n" << "2.5"; + cout << "\nResult:\n" << m3 << endl; m6 = m12 / (float)0.125; - cout<< "\n" << m12 << "\n" << ".125"; - cout<< "\nResult:\n" << m6 << endl; + cout << "\n" << m12 << "\n" << ".125"; + cout << "\nResult:\n" << m6 << endl; float num = 5.5650; float num1 = -2.32; - cout<< "\n\n\nScalar addition\n"; + cout << "\n\n\nScalar addition\n"; m3 = m2 + num; m6 = m10 + num1; - cout<< "\nNumber added:" << num; - cout<< "\n\n" << m2; - cout<< "\nResult:\n\n" << m3; - cout<< "\nNumber added:" << num1; - cout<< "\n\n" << m10; - cout<< "\nResult:\n\n" << m6; + cout << "\nNumber added:" << num; + cout << "\n\n" << m2; + cout << "\nResult:\n\n" << m3; + cout << "\nNumber added:" << num1; + cout << "\n\n" << m10; + cout << "\nResult:\n\n" << m6; float x = 4.0; float x1 = -2.5; - cout<< "\n\n\nScalar subtraction\n"; + cout << "\n\n\nScalar subtraction\n"; m13 = m11 - x; m6 = m10 - x1; - cout<< "\nNumber Subtracted:" << x; - cout<< "\n\n" << m11; - cout<< "\nResult:\n\n" << m13; - cout<< "\nNumber Subtracted:" << x1; - cout<< "\n\n" << m10; - cout<< "\nResult:\n\n" << m6; + cout << "\nNumber Subtracted:" << x; + cout << "\n\n" << m11; + cout << "\nResult:\n\n" << m13; + cout << "\nNumber Subtracted:" << x1; + cout << "\n\n" << m10; + cout << "\nResult:\n\n" << m6; float z = 3.50; float z1 = -5.567; - cout<< "\n\n\nScalar multiplication\n"; + cout << "\n\n\nScalar multiplication\n"; m3 = m1 * z; m6 = m12 * z1; - cout<< "\nNumber Multiplied:"<< z; - cout<< "\n\n" << m1; - cout<< "\nResult:\n\n" << m3; - cout<< "\nNumber Multiplied:" << z1; - cout<< "\n\n" << m12; - cout<< "\nResult:\n\n" << m6; + cout << "\nNumber Multiplied:" << z; + cout << "\n\n" << m1; + cout << "\nResult:\n\n" << m3; + cout << "\nNumber Multiplied:" << z1; + cout << "\n\n" << m12; + cout << "\nResult:\n\n" << m6; m6 = tran(m15); - cout<< "\n\n\nTranspose:"; + cout << "\n\n\nTranspose:"; cout << "\n\n" << m15; cout << "\nResult:\n\n" << m6; @@ -147,9 +147,8 @@ int main() cout << (m6 != m1); - cout<< "\n\nAssignment\n"; + cout << "\n\nAssignment\n"; matrix m30 = m12; - cout<< "Input \n" << m12; - cout<< "\nOutput:\n" << m30 << endl; - + cout << "Input \n" << m12; + cout << "\nOutput:\n" << m30 << endl; } diff --git a/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp b/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp index feb7e773..d0a41fd5 100644 --- a/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/orientation_sensor_test/orientation_sensor_main.cpp @@ -59,7 +59,7 @@ int main() sdata[0] = strtof(line_accel.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data accel_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Accel Data\t" << accel_data.m_data << "\t Time Stamp\t" << accel_data.m_time_stamp << "\n\n"; @@ -68,7 +68,7 @@ int main() sdata[0] = strtof(line_gyro.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data gyro_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Gyro Data\t" << gyro_data.m_data << "\t Time Stamp\t" << gyro_data.m_time_stamp << "\n\n"; @@ -77,7 +77,7 @@ int main() sdata[0] = strtof(line_magnetic.c_str(), &token); sdata[1] = strtof(token, &token); sdata[2] = strtof(token, &token); - time_stamp = strtoull (token, NULL, 10); + time_stamp = strtoull(token, NULL, 10); sensor_data magnetic_data(sdata[0], sdata[1], sdata[2], time_stamp); cout << "Magnetic Data\t" << magnetic_data.m_data << "\t Time Stamp\t" << magnetic_data.m_time_stamp << "\n\n"; diff --git a/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp b/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp index 09f980ff..f437d6c3 100644 --- a/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/quaternion_test/quaternion_main.cpp @@ -73,6 +73,5 @@ int main() quaternion q11 = axis2quat(v2, ang1); cout << "output\t" << q11.m_quat << "\n\n"; cout << endl; - } diff --git a/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp b/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp index 4477daa0..526bda46 100644 --- a/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/sensor_data_test/sensor_data_main.cpp @@ -23,8 +23,8 @@ int main() { float arr1[3] = {1.04, -4.678, -2.34}; float arr2[3] = {0, 0, 1}; - vect v1(arr1); - vect v2(arr2); + vect v1(arr1); + vect v2(arr2); sensor_data sd1(2.0, 3.0, 4.0, 140737488355328); sensor_data sd2(1.04, -4.678, -2.34, 0); @@ -39,31 +39,31 @@ int main() cout << "input\t" << v1 << "\n"; cout << "output\t" << sd2.m_data << "\t" << sd2.m_time_stamp << "\n\n"; - cout<< "Addition:\n"; + cout << "Addition:\n"; sensor_data sd4 = sd1 + sd2; - cout<< "\n" << sd1.m_data << "\n" << sd2.m_data; - cout<< "\nSum:\n" << sd4.m_data << endl; + cout << "\n" << sd1.m_data << "\n" << sd2.m_data; + cout << "\nSum:\n" << sd4.m_data << endl; sensor_data sd9 = sd1 + sd10; - cout<< "\n" << sd1.m_data << "\n" << sd10.m_data; - cout<< "\nSum:\n" << sd9.m_data << endl; + cout << "\n" << sd1.m_data << "\n" << sd10.m_data; + cout << "\nSum:\n" << sd9.m_data << endl; - cout<< "\n\n\nNormalization:\n"; - cout<< "\n" << sd3.m_data; + cout << "\n\n\nNormalization:\n"; + cout << "\n" << sd3.m_data; normalize(sd3); - cout<< "\nResult:\n" << sd3.m_data << endl; - cout<< "\n" << sd2.m_data; + cout << "\nResult:\n" << sd3.m_data << endl; + cout << "\n" << sd2.m_data; normalize(sd2); - cout<< "\nResult:\n" << sd2.m_data << endl; + cout << "\nResult:\n" << sd2.m_data << endl; float xx = 2.5; - cout<<"\n\n\nScale data:\n"; + cout << "\n\n\nScale data:\n"; sensor_data sd8 = scale_data(sd2, xx); - cout<< "\n" << sd2.m_data << "\n" << xx; - cout<< "\nResult:\n" << sd8.m_data << endl; + cout << "\n" << sd2.m_data << "\n" << xx; + cout << "\nResult:\n" << sd8.m_data << endl; - cout<<"\n\n\nConvert Sensor Data to Quaternion:\n"; + cout << "\n\n\nConvert Sensor Data to Quaternion:\n"; quaternion q = sensor_data2quat(sd11, v2); - cout<< "\n" << sd11.m_data << "\n" << v2; - cout<< "\nResult:\n" << q.m_quat << endl; + cout << "\n" << sd11.m_data << "\n" << v2; + cout << "\nResult:\n" << q.m_quat << endl; } diff --git a/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp b/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp index bca9d2da..2a81f831 100644 --- a/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp +++ b/src/sensor/sensor_fusion/test/test_projects/vector_test/vector_main.cpp @@ -21,123 +21,123 @@ int main() { - float arr2[3] = {0.056,2.34,-65.76}; - float arr15[3] = {1.04,-4.678,-2.34}; - float arr3[4] = {1.03,2.345,6.78,5.55}; - float arr4[4] = {-6.78,-45.213,-7.89,-3.456}; - float arr8[5] = {0.0123,5.678,2.345,0.345,8.956}; - float arr0[5] = {2344.98,345.24,456.12,98.33,144.67}; - float arr1[6] = {1.234,4.5,6.8987,3.33,5.66,77.695}; - float arr43[6] = {2.3454,-0.0384,-8.90,3.455,6.785,21.345}; - float arr5[5] = {0.2,-0.4,0.6,-0.8,1.0}; - - vect v1(arr0); - vect v2(arr8); - vect v10(arr3); - vect v12(arr4); - vect v15(arr1); - vect v20(arr43); - vect v21(arr2); - vect v22(arr15); - vect v31(arr0); - vect v3; - vect vn; - vect v61(arr4); - vect v6; - vect vm; - vect v13; - vect v95; - vect v35(arr5); - vect vl; - vect vp; - vect vr(arr4); - vect vf; + float arr2[3] = {0.056, 2.34, -65.76}; + float arr15[3] = {1.04, -4.678, -2.34}; + float arr3[4] = {1.03, 2.345, 6.78, 5.55}; + float arr4[4] = {-6.78, -45.213, -7.89, -3.456}; + float arr8[5] = {0.0123, 5.678, 2.345, 0.345, 8.956}; + float arr0[5] = {2344.98, 345.24, 456.12, 98.33, 144.67}; + float arr1[6] = {1.234, 4.5, 6.8987, 3.33, 5.66, 77.695}; + float arr43[6] = {2.3454, -0.0384, -8.90, 3.455, 6.785, 21.345}; + float arr5[5] = {0.2, -0.4, 0.6, -0.8, 1.0}; + + vect v1(arr0); + vect v2(arr8); + vect v10(arr3); + vect v12(arr4); + vect v15(arr1); + vect v20(arr43); + vect v21(arr2); + vect v22(arr15); + vect v31(arr0); + vect v3; + vect vn; + vect v61(arr4); + vect v6; + vect vm; + vect v13; + vect v95; + vect v35(arr5); + vect vl; + vect vp; + vect vr(arr4); + vect vf; float arr57[3][3] = {{2.24, 0.5, 0.023}, {3.675, 5.32, 0.556}, {1.023, 45.75, 621.6}}; - matrix m12(arr57); + matrix m12(arr57); float arr67[3][1] = {{2.0}, {3.0}, {4.0}}; - matrix m32(arr67); + matrix m32(arr67); - cout<< "Constructor Test\n"; - cout<< "\n" << v3; + cout << "Constructor Test\n"; + cout << "\n" << v3; - cout<< "\n\nAddition\n"; + cout << "\n\nAddition\n"; v3 = v21 + v22; v95 = v15 + v20; - cout<< "\n\nNumbers added\n"; - cout<< "\n" << v21 << "\n" << v22; - cout<< "\nSum:\n" << v3 << endl; - cout<< "\n\nNumbers added\n"; - cout<< "\n" << v15 << "\n" << v20; - cout<< "\nSum:\n" << v95 << endl; + cout << "\n\nNumbers added\n"; + cout << "\n" << v21 << "\n" << v22; + cout << "\nSum:\n" << v3 << endl; + cout << "\n\nNumbers added\n"; + cout << "\n" << v15 << "\n" << v20; + cout << "\nSum:\n" << v95 << endl; float num = 5.5650; float num1 = -2.32; - cout<< "\n\n\nScalar addition\n"; + cout << "\n\n\nScalar addition\n"; vl = v2 + num; vm = v10 + num1; - cout<< "\nNumber added:" << num; - cout<< "\n\n" << v2; - cout<< "\nResult:\n\n" << vl; - cout<< "\nNumber added:"<< num1; - cout<< "\n\n" << v10; - cout<< "\nResult:\n\n"<< vm; - - cout<< "\n\n\nSubtraction\n"; + cout << "\nNumber added:" << num; + cout << "\n\n" << v2; + cout << "\nResult:\n\n" << vl; + cout << "\nNumber added:" << num1; + cout << "\n\n" << v10; + cout << "\nResult:\n\n" << vm; + + cout << "\n\n\nSubtraction\n"; vp = v10 - v12; - cout<< "\n" << v10 << "\n" << v12; - cout<< "\nDifference:\n" << vp << endl; + cout << "\n" << v10 << "\n" << v12; + cout << "\nDifference:\n" << vp << endl; float x = 4.0; float x1 = -2.5; - cout<< "\n\n\nScalar subtraction\n"; + cout << "\n\n\nScalar subtraction\n"; v13 = v1 - x; vp = v10 - x1; - cout<< "\nNumber Subtracted:" << x; - cout<< "\n\n" << v1; - cout<< "\nResult:\n\n" << v13; - cout<< "\nNumber Subtracted:" << x1; - cout<< "\n\n" << v10; - cout<< "\nResult:\n\n" << vp; + cout << "\nNumber Subtracted:" << x; + cout << "\n\n" << v1; + cout << "\nResult:\n\n" << v13; + cout << "\nNumber Subtracted:" << x1; + cout << "\n\n" << v10; + cout << "\nResult:\n\n" << vp; float xx = 7.2; - cout<<"\n\n\nMultiplication\n"; + cout << "\n\n\nMultiplication\n"; v13 = v2 * xx; - cout<< "\n" << v2 <<"\n"<< xx; - cout<< "\nProduct:\n" << v13 << endl; + cout << "\n" << v2 << "\n" << xx; + cout << "\nProduct:\n" << v13 << endl; - cout<< "\n\n\nMultiplication matrix x vector:\n"; - matrix m102 = m32 * v22; - cout<< "\n" << m32 <<"\n"<< v22; - cout<< "\nProduct:\n"<< m102 << endl; + cout << "\n\n\nMultiplication matrix x vector:\n"; + matrix m102 = m32 * v22; + cout << "\n" << m32 << "\n" << v22; + cout << "\nProduct:\n" << m102 << endl; - cout<< "\n\n\nVector x Multiplication matrix:\n"; - vect v102 = (v22 * m12); - cout<< "\n" << v22 << "\n" << m12; - cout<< "\nProduct:\n" << v102 << endl; + cout << "\n\n\nVector x Multiplication matrix:\n"; + vect v102 = (v22 * m12); + cout << "\n" << v22 << "\n" << m12; + cout << "\nProduct:\n" << v102 << endl; float z = 3.50; float z1 = -5.567; - cout<< "\n\n\nScalar multiplication\n"; + cout << "\n\n\nScalar multiplication\n"; v13 = v1 * z; v61 = v12 * z1; - cout<< "\nNumber Multiplied:" << z; - cout<< "\n\n" << v1; - cout<< "\nResult:\n\n" << v13; - cout<< "\nNumber Multiplied:" << z1; - cout<< "\n\n" << v12; - cout<< "\nResult:\n\n" << v6; + cout << "\nNumber Multiplied:" << z; + cout << "\n\n" << v1; + cout << "\nResult:\n\n" << v13; + cout << "\nNumber Multiplied:" << z1; + cout << "\n\n" << v12; + cout << "\nResult:\n\n" << v6; float num2 = 5.5; - cout<< "\n\n\nDivision\n"; + cout << "\n\n\nDivision\n"; v31 = v1 / num2; - cout<< "\n" << v1 << "\n" << num2; - cout<< "\nResult:\n" << v3 << endl; + cout << "\n" << v1 << "\n" << num2; + cout << "\nResult:\n" << v3 << endl; - cout<< "\n\n\nTranspose:"; + cout << "\n\n\nTranspose:"; cout << "\n\n" << v20; cout << "\nResult:\n\n"; - matrix m101 = transpose(v20); + matrix m101 = transpose(v20); cout << m101; cout << "\n\n" << m101; cout << "\nResult:\n\n"; @@ -164,18 +164,18 @@ int main() cout << "\n\n\nv15 != v15 :"; cout << (v15 != v15); - cout<< "\n\nAssignment\n"; + cout << "\n\nAssignment\n"; v3 = vf; - cout<< "Input \n" << v1; - cout<< "\nOutput:\n" << v3 << endl; + cout << "Input \n" << v1; + cout << "\nOutput:\n" << v3 << endl; - vect v111 = cross(v21, v22); - cout<< "\n\n\nCross Product:"; + vect v111 = cross(v21, v22); + cout << "\n\n\nCross Product:"; cout << "\n\n" << v21 << "\n\n" << v22; cout << "\nResult:\n\n" << v111; float val = dot(v21, v22); - cout<< "\n\n\nDot Product:"; + cout << "\n\n\nDot Product:"; cout << "\n\n" << v21 << "\n\n" << v22; cout << "\nResult:\n\n" << val; diff --git a/src/sensor/sensor_fusion/vector.cpp b/src/sensor/sensor_fusion/vector.cpp index 5174035f..432cb661 100644 --- a/src/sensor/sensor_fusion/vector.cpp +++ b/src/sensor/sensor_fusion/vector.cpp @@ -27,7 +27,6 @@ TYPE_SIZE vect::vect(void) TYPE_SIZE vect::vect(TYPE vec_data[SIZE]) { - for (int j = 0; j < SIZE; j++) m_vec[j] = vec_data[j]; } @@ -109,7 +108,7 @@ T_S_R_C matrix operator *(const matrix m, const vect v) assert(R == S); assert(C == 1); - matrix m1; + matrix m1; for (int i = 0; i < R; i++) for (int j = 0; j < S; j++) @@ -122,7 +121,7 @@ T_S_R_C vect operator *(const vect v, const matrix m) { assert(R == S); assert(C != 1); - vect v1; + vect v1; for (int j = 0; j < C; j++) { @@ -156,7 +155,7 @@ T_S vect operator /(const vect v, const T val) T_S1_S2 bool operator ==(const vect v1, const vect v2) { - if (S1==S2) + if (S1 == S2) { for (int i = 0; i < S1; i++) if (v1.m_vec[i] != v2.m_vec[i]) diff --git a/src/sensor/sensor_fusion/vector.h b/src/sensor/sensor_fusion/vector.h index c976ecc3..47539842 100644 --- a/src/sensor/sensor_fusion/vector.h +++ b/src/sensor/sensor_fusion/vector.h @@ -40,12 +40,12 @@ public: T_S friend ostream& operator << (ostream& dout, vect& v); T_S friend vect operator +(const vect v1, const vect v2); T_S friend vect operator +(const vect v, const T val); - T_S friend vect operator -(const vect v1, const vect v2); - T_S friend vect operator -(const vect v, const T val); + T_S friend vect operator -(const vect v1, const vect v2); + T_S friend vect operator -(const vect v, const T val); T_S_R_C friend matrix operator *(const matrix v1, const vect v2); T_S_R_C friend vect operator *(const vect v, const matrix m); T_S friend vect operator *(const vect v, const T val); - T_S friend vect operator /(const vect v1, const T val); + T_S friend vect operator /(const vect v1, const T val); T_S1_S2 friend bool operator ==(const vect v1, const vect v2); T_S1_S2 friend bool operator !=(const vect v1, const vect v2); diff --git a/src/sensor/tilt/tilt_sensor.cpp b/src/sensor/tilt/tilt_sensor.cpp index d2363508..b60f3378 100644 --- a/src/sensor/tilt/tilt_sensor.cpp +++ b/src/sensor/tilt/tilt_sensor.cpp @@ -50,8 +50,6 @@ using std::vector; #define ELEMENT_PITCH_ROTATION_COMPENSATION "PITCH_ROTATION_COMPENSATION" #define ELEMENT_ROLL_ROTATION_COMPENSATION "ROLL_ROTATION_COMPENSATION" - - tilt_sensor::tilt_sensor() : m_accel_sensor(NULL) , m_fusion_sensor(NULL) @@ -98,7 +96,6 @@ tilt_sensor::tilt_sensor() _I("m_roll_rotation_compensation = %d", m_roll_rotation_compensation); m_interval = m_default_sampling_time * MS_TO_US; - } tilt_sensor::~tilt_sensor() @@ -189,7 +186,6 @@ void tilt_sensor::synthesize(const sensor_event_t &event, vector unsigned long long diff_time; if (event.event_type == FUSION_EVENT) { - diff_time = event.data.timestamp - m_time; if (m_time && (diff_time < m_interval * MIN_DELIVERY_DIFF_FACTOR)) @@ -257,8 +253,7 @@ bool tilt_sensor::get_properties(sensor_type_t sensor_type, sensor_properties_s if(m_raw_data_unit == "DEGREES") { properties.min_range = -180; properties.max_range = 180; - } - else { + } else { properties.min_range = -PI; properties.max_range = PI; } diff --git a/src/server/client_info_manager.cpp b/src/server/client_info_manager.cpp index 536f1640..b61bdf1b 100644 --- a/src/server/client_info_manager.cpp +++ b/src/server/client_info_manager.cpp @@ -28,6 +28,7 @@ using std::string; client_info_manager::client_info_manager() { } + client_info_manager::~client_info_manager() { m_clients.clear(); @@ -56,7 +57,6 @@ bool client_info_manager::get_registered_events(int client_id, sensor_id_t senso return true; } - bool client_info_manager::register_event(int client_id, sensor_id_t sensor_id, unsigned int event_type) { AUTOLOCK(m_mutex); @@ -136,7 +136,6 @@ bool client_info_manager::set_option(int client_id, sensor_id_t sensor_id, int o return true; } - bool client_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool start) { AUTOLOCK(m_mutex); @@ -152,7 +151,6 @@ bool client_info_manager::set_start(int client_id, sensor_id_t sensor_id, bool s return false; return true; - } bool client_info_manager::is_started(int client_id, sensor_id_t sensor_id) @@ -187,12 +185,11 @@ int client_info_manager::create_client_record(void) client_record.set_client_id(client_id); - m_clients.insert(pair (client_id, client_record)); + m_clients.insert(pair (client_id, client_record)); return client_id; } - bool client_info_manager::remove_client_record(int client_id) { AUTOLOCK(m_mutex); @@ -211,7 +208,6 @@ bool client_info_manager::remove_client_record(int client_id) return true; } - bool client_info_manager::has_client_record(int client_id) { AUTOLOCK(m_mutex); @@ -221,7 +217,6 @@ bool client_info_manager::has_client_record(int client_id) return (it_record != m_clients.end()); } - void client_info_manager::set_client_info(int client_id, pid_t pid, const string &name) { AUTOLOCK(m_mutex); @@ -318,7 +313,6 @@ bool client_info_manager::remove_sensor_record(int client_id, sensor_id_t sensor return true; } - bool client_info_manager::has_sensor_record(int client_id, sensor_id_t sensor_id) { AUTOLOCK(m_mutex); @@ -387,7 +381,6 @@ bool client_info_manager::get_event_socket(int client_id, csocket &socket) bool client_info_manager::set_event_socket(int client_id, const csocket &socket) { - AUTOLOCK(m_mutex); auto it_record = m_clients.find(client_id); diff --git a/src/server/client_info_manager.h b/src/server/client_info_manager.h index e7905340..bed44717 100644 --- a/src/server/client_info_manager.h +++ b/src/server/client_info_manager.h @@ -26,7 +26,7 @@ #include #include -typedef std::unordered_map client_id_sensor_record_map; +typedef std::unordered_map client_id_sensor_record_map; typedef std::vector client_id_vec; class client_info_manager { diff --git a/src/server/client_sensor_record.cpp b/src/server/client_sensor_record.cpp index 95001bbf..e2e647e8 100644 --- a/src/server/client_sensor_record.cpp +++ b/src/server/client_sensor_record.cpp @@ -28,7 +28,6 @@ client_sensor_record::client_sensor_record() , m_pid(-1) , m_permission(SENSOR_PERMISSION_NONE) { - } client_sensor_record::~client_sensor_record() @@ -44,7 +43,7 @@ bool client_sensor_record::register_event(sensor_id_t sensor_id, unsigned int ev if (it_usage == m_sensor_usages.end()) { sensor_usage usage; usage.register_event(event_type); - m_sensor_usages.insert(pair(sensor_id, usage)); + m_sensor_usages.insert(pair(sensor_id, usage)); return true; } @@ -88,7 +87,6 @@ bool client_sensor_record::set_option(sensor_id_t sensor_id, int option) return true; } - bool client_sensor_record::set_start(sensor_id_t sensor_id, bool start) { auto it_usage = m_sensor_usages.find(sensor_id); @@ -169,7 +167,7 @@ bool client_sensor_record::add_sensor_usage(sensor_id_t sensor_id) } sensor_usage usage; - m_sensor_usages.insert(pair (sensor_id, usage)); + m_sensor_usages.insert(pair(sensor_id, usage)); return true; } @@ -193,7 +191,6 @@ bool client_sensor_record::has_sensor_usage(void) return true; } - bool client_sensor_record::has_sensor_usage(sensor_id_t sensor_id) { auto it_usage = m_sensor_usages.find(sensor_id); @@ -206,7 +203,6 @@ bool client_sensor_record::has_sensor_usage(sensor_id_t sensor_id) return true; } - 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); @@ -219,7 +215,6 @@ bool client_sensor_record::get_registered_events(sensor_id_t sensor_id, event_ty copy(it_usage->second.m_reg_events.begin(), it_usage->second.m_reg_events.end(), back_inserter(event_vec)); return true; - } void client_sensor_record::set_client_id(int client_id) @@ -251,7 +246,6 @@ int client_sensor_record::get_permission(void) return m_permission; } - void client_sensor_record::set_event_socket(const csocket &socket) { m_event_socket = socket; @@ -262,7 +256,6 @@ void client_sensor_record::get_event_socket(csocket &socket) socket = m_event_socket; } - bool client_sensor_record::close_event_socket(void) { return m_event_socket.close(); diff --git a/src/server/command_worker.cpp b/src/server/command_worker.cpp index 83c3f8b3..89b569ed 100644 --- a/src/server/command_worker.cpp +++ b/src/server/command_worker.cpp @@ -67,7 +67,6 @@ command_worker::~command_worker() m_socket.close(); } - bool command_worker::start(void) { return m_worker.start(); @@ -181,7 +180,6 @@ bool command_worker::working(void *ctx) } if (header.size > 0) { - payload = new(std::nothrow) char[header.size]; retvm_if(!payload, false, "Failed to allocate memory"); @@ -204,7 +202,6 @@ bool command_worker::working(void *ctx) return ret; } - bool command_worker::stopped(void *ctx) { string info; @@ -269,10 +266,8 @@ bool command_worker::send_cmd_done(long value) delete ret_packet; return true; - } - bool command_worker::send_cmd_get_id_done(int client_id) { cpacket* ret_packet; @@ -324,7 +319,6 @@ bool command_worker::send_cmd_get_data_done(int state, sensor_data_t *data) return true; } - bool command_worker::send_cmd_get_sensor_list_done(void) { cpacket sensor_list; @@ -373,7 +367,6 @@ bool command_worker::cmd_get_id(void *payload) return true; } - bool command_worker::cmd_get_sensor_list(void *payload) { _D("CMD_GET_SENSOR_LIST Handler invoked\n"); @@ -860,7 +853,6 @@ bool command_worker::is_permission_allowed(void) return false; } - client_info_manager& command_worker::get_client_info_manager(void) { return client_info_manager::get_instance(); diff --git a/src/server/command_worker.h b/src/server/command_worker.h index cd5c3369..78661ad9 100644 --- a/src/server/command_worker.h +++ b/src/server/command_worker.h @@ -91,7 +91,6 @@ public: virtual ~command_worker(); bool start(void); - }; #endif /* _COMMAND_WORKER_H_ */ diff --git a/src/server/device_config.cpp b/src/server/device_config.cpp index ac7a7bd0..082b6d61 100644 --- a/src/server/device_config.cpp +++ b/src/server/device_config.cpp @@ -27,12 +27,10 @@ using std::istringstream; device_config::device_config(void) { - } device_config::~device_config(void) { - } bool device_config::get_device_id(void) diff --git a/src/server/physical_sensor.cpp b/src/server/physical_sensor.cpp index f7135eef..689ffed7 100644 --- a/src/server/physical_sensor.cpp +++ b/src/server/physical_sensor.cpp @@ -215,4 +215,3 @@ bool physical_sensor::get_sensor_info(sensor_info &info) return true; } - diff --git a/src/server/sensor_event_dispatcher.cpp b/src/server/sensor_event_dispatcher.cpp index 52c65d9e..a8247fca 100644 --- a/src/server/sensor_event_dispatcher.cpp +++ b/src/server/sensor_event_dispatcher.cpp @@ -33,8 +33,9 @@ sensor_event_dispatcher::sensor_event_dispatcher() { } -sensor_event_dispatcher::~sensor_event_dispatcher() { } - +sensor_event_dispatcher::~sensor_event_dispatcher() +{ +} sensor_event_dispatcher& sensor_event_dispatcher::get_instance() { @@ -139,7 +140,6 @@ void sensor_event_dispatcher::dispatch_event(void) } } - void sensor_event_dispatcher::send_sensor_events(vector &events) { sensor_event_t *sensor_event = NULL; @@ -222,7 +222,6 @@ bool sensor_event_dispatcher::has_active_virtual_sensor(virtual_sensor *sensor) return (it_v_sensor != m_active_virtual_sensors.end()); } - virtual_sensors sensor_event_dispatcher::get_active_virtual_sensors(void) { AUTOLOCK(m_active_virtual_sensors_mutex); diff --git a/src/server/sensor_event_queue.cpp b/src/server/sensor_event_queue.cpp index 300808ee..b49880d7 100644 --- a/src/server/sensor_event_queue.cpp +++ b/src/server/sensor_event_queue.cpp @@ -34,8 +34,9 @@ void sensor_event_queue::push_internal(void *event) if (m_queue.size() >= QUEUE_FULL_SIZE) { _E("Queue is full, drop it!"); free(event); - } else + } else { m_queue.push(event); + } if (wake) m_cond_var.notify_one(); diff --git a/src/server/sensor_fusion.cpp b/src/server/sensor_fusion.cpp index b6379f1f..c82e152f 100644 --- a/src/server/sensor_fusion.cpp +++ b/src/server/sensor_fusion.cpp @@ -21,12 +21,10 @@ sensor_fusion::sensor_fusion() { - } sensor_fusion::~sensor_fusion() { - } bool sensor_fusion::is_fusion(void) diff --git a/src/server/sensor_fusion.h b/src/server/sensor_fusion.h index ec9701d9..c8a8a11b 100644 --- a/src/server/sensor_fusion.h +++ b/src/server/sensor_fusion.h @@ -29,7 +29,7 @@ enum fusion_event_type { FUSION_EVENT_AGM = (FUSION_SENSOR << 16) | 0x0004, }; -typedef std::array ,3> arr33_t; +typedef std::array, 3> arr33_t; class sensor_fusion : public sensor_base { public: @@ -56,4 +56,4 @@ public: virtual bool get_orientation(float &azimuth, float &pitch, float &roll, int &accuracy); }; -#endif +#endif /* _SENSOR_FUSION_H_ */ diff --git a/src/server/sensor_info_list.h b/src/server/sensor_info_list.h index 0edb0fa7..7e907430 100644 --- a/src/server/sensor_info_list.h +++ b/src/server/sensor_info_list.h @@ -63,4 +63,5 @@ private: std::list m_interval_info_list; std::list m_batch_info_list; }; + #endif /* _SENSOR_INFO_LIST_H_ */ diff --git a/src/server/sensor_loader.h b/src/server/sensor_loader.h index b303301b..ef659e3c 100644 --- a/src/server/sensor_loader.h +++ b/src/server/sensor_loader.h @@ -67,4 +67,5 @@ public: std::vector get_sensors(sensor_type_t type); std::vector get_virtual_sensors(void); }; + #endif /* _SENSOR_LOADER_H_ */ diff --git a/src/server/sensor_usage.cpp b/src/server/sensor_usage.cpp index 77d2cceb..142ec4b9 100644 --- a/src/server/sensor_usage.cpp +++ b/src/server/sensor_usage.cpp @@ -28,8 +28,8 @@ sensor_usage::sensor_usage() , m_option(SENSOR_OPTION_DEFAULT) , m_start(false) { - } + sensor_usage::~sensor_usage() { m_reg_events.clear(); @@ -53,7 +53,7 @@ bool sensor_usage::unregister_event(unsigned int event_type) auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type); if (it_event == m_reg_events.end()) { - _E("Event[%#x] is not found",event_type); + _E("Event[%#x] is not found", event_type); return false; } @@ -64,10 +64,10 @@ bool sensor_usage::unregister_event(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); + auto it_event = find(m_reg_events.begin(), m_reg_events.end(), event_type); if (it_event == m_reg_events.end()){ - _D("Event[%#x] is not registered",event_type); + _D("Event[%#x] is not registered", event_type); return false; } diff --git a/src/server/server.cpp b/src/server/server.cpp index 5e902bb4..7a5e416f 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -33,7 +33,6 @@ using std::thread; server::server() : m_mainloop(NULL) { - } server::~server() diff --git a/src/server/virtual_sensor.cpp b/src/server/virtual_sensor.cpp index 67016428..0d297b3c 100644 --- a/src/server/virtual_sensor.cpp +++ b/src/server/virtual_sensor.cpp @@ -20,15 +20,12 @@ #include #include - virtual_sensor::virtual_sensor() { - } virtual_sensor::~virtual_sensor() { - } bool virtual_sensor::init(void) diff --git a/src/server/virtual_sensor_config.cpp b/src/server/virtual_sensor_config.cpp index bc59fb76..46562a52 100644 --- a/src/server/virtual_sensor_config.cpp +++ b/src/server/virtual_sensor_config.cpp @@ -64,24 +64,24 @@ bool virtual_sensor_config::load_config(const string& config_path) xmlDocPtr doc; xmlNodePtr cur; - _D("virtual_sensor_config::load_config(\"%s\") is called!\n",config_path.c_str()); + _D("virtual_sensor_config::load_config(\"%s\") is called!\n", config_path.c_str()); doc = xmlParseFile(config_path.c_str()); if (doc == NULL) { - _E("There is no %s\n",config_path.c_str()); + _E("There is no %s\n", config_path.c_str()); return false; } cur = xmlDocGetRootElement(doc); if(cur == NULL) { - _E("There is no root element in %s\n",config_path.c_str()); + _E("There is no root element in %s\n", config_path.c_str()); xmlFreeDoc(doc); return false; } if(xmlStrcmp(cur->name, (const xmlChar *)ROOT_ELEMENT)) { - _E("Wrong type document: there is no [%s] root element in %s\n",ROOT_ELEMENT,config_path.c_str()); + _E("Wrong type document: there is no [%s] root element in %s\n", ROOT_ELEMENT, config_path.c_str()); xmlFreeDoc(doc); return false; } @@ -95,57 +95,55 @@ bool virtual_sensor_config::load_config(const string& config_path) device_node_ptr = cur->xmlChildrenNode; while (device_node_ptr != NULL){ //skip garbage element, [text] - if (!xmlStrcmp(device_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) { + if (!xmlStrcmp(device_node_ptr->name, (const xmlChar *)TEXT_ELEMENT)) { device_node_ptr = device_node_ptr->next; continue; } - string device_type; - prop = (char*)xmlGetProp(device_node_ptr,(const xmlChar*)DEVICE_TYPE_ATTR); + prop = (char*)xmlGetProp(device_node_ptr, (const xmlChar*)DEVICE_TYPE_ATTR); device_type = prop; free(prop); //insert device to device_list m_virtual_sensor_configs[device_type]; - _D("\n",device_type.c_str()); + _D("\n", device_type.c_str()); virtual_sensor_node_ptr = device_node_ptr->xmlChildrenNode; while (virtual_sensor_node_ptr != NULL) { //skip garbage element, [text] - if (!xmlStrcmp(virtual_sensor_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) { + if (!xmlStrcmp(virtual_sensor_node_ptr->name, (const xmlChar *)TEXT_ELEMENT)) { virtual_sensor_node_ptr = virtual_sensor_node_ptr->next; continue; } m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name]; - _D("<%s>\n",device_type.c_str(),(const char*)virtual_sensor_node_ptr->name); + _D("<%s>\n", device_type.c_str(), (const char*)virtual_sensor_node_ptr->name); element_node_ptr = virtual_sensor_node_ptr->xmlChildrenNode; while (element_node_ptr != NULL) { //skip garbage element, [text] - if (!xmlStrcmp(element_node_ptr->name,(const xmlChar *)TEXT_ELEMENT)) { + if (!xmlStrcmp(element_node_ptr->name, (const xmlChar *)TEXT_ELEMENT)) { element_node_ptr = element_node_ptr->next; continue; } //insert Element to Model m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name]; - _D("<%s><%s>\n",device_type.c_str(),(const char*)virtual_sensor_node_ptr->name,(const char*)element_node_ptr->name); + _D("<%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; while (attr_ptr != NULL) { - - string key,value; + string key, value; key = (char*)attr_ptr->name; - prop = (char*)xmlGetProp(element_node_ptr,attr_ptr->name); + prop = (char*)xmlGetProp(element_node_ptr, attr_ptr->name); value = prop; free(prop); //insert attribute to Element - m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name][key]=value; - _D("<%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()); + m_virtual_sensor_configs[device_type][(const char*)virtual_sensor_node_ptr->name][(const char*)element_node_ptr->name][key] = value; + _D("<%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; } @@ -168,7 +166,7 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element auto it_device_list = m_virtual_sensor_configs.find(m_device_id); if (it_device_list == m_virtual_sensor_configs.end()) { - _E("There is no <%s> device\n",m_device_id.c_str()); + _E("There is no <%s> device\n", m_device_id.c_str()); m_device_id = DEFAULT_DEVICE; it_device_list = m_virtual_sensor_configs.find(m_device_id); @@ -184,21 +182,21 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element auto it_virtual_sensor_list = it_device_list->second.find(sensor_type); if (it_virtual_sensor_list == it_device_list->second.end()) { - _E("There is no <%s> sensor\n",sensor_type.c_str()); + _E("There is no <%s> sensor\n", sensor_type.c_str()); return false; } auto it_element = it_virtual_sensor_list->second.find(element); if (it_element == it_virtual_sensor_list->second.end()) { - _E("There is no <%s><%s> element\n",sensor_type.c_str(),element.c_str()); + _E("There is no <%s><%s> element\n", sensor_type.c_str(), element.c_str()); return false; } auto it_attr = it_element->second.find(attr); if (it_attr == it_element->second.end()) { - _D("There is no <%s><%s \"%s\">\n",sensor_type.c_str(),element.c_str(),attr.c_str()); + _D("There is no <%s><%s \"%s\">\n", sensor_type.c_str(), element.c_str(), attr.c_str()); return false; } @@ -211,7 +209,7 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element { string str_value; - if (get(sensor_type,element,attr,str_value) == false) + if (get(sensor_type, element, attr, str_value) == false) return false; stringstream str_stream(str_value); @@ -225,7 +223,7 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element { string str_value; - if (get(sensor_type,element,attr,str_value) == false) + if (get(sensor_type, element, attr, str_value) == false) return false; stringstream str_stream(str_value); @@ -245,13 +243,12 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element bool virtual_sensor_config::get(const string& sensor_type, const string& element, float *value, int count) { - if (count == 1) - { + if (count == 1) { if (get(sensor_type, element, DEFAULT_ATTR, value)) return true; } - else if (count == 3) - { + + if (count == 3) { if (!get(sensor_type, element, DEFAULT_ATTR1, value)) return false; @@ -267,23 +264,20 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element return true; } - else - { - _D("Count value not supported.\n"); - } + + _D("Count value not supported.\n"); return false; } bool virtual_sensor_config::get(const string& sensor_type, const string& element, int *value, int count) { - if (count == 1) - { + if (count == 1) { if (get(sensor_type, element, DEFAULT_ATTR, value)) return true; } - else if (count == 3) - { + + if (count == 3) { if (!get(sensor_type, element, DEFAULT_ATTR1, value)) return false; @@ -299,10 +293,8 @@ bool virtual_sensor_config::get(const string& sensor_type, const string& element return true; } - else - { - _D("Count value not supported.\n"); - } + + _D("Count value not supported.\n"); return false; } @@ -321,4 +313,3 @@ bool virtual_sensor_config::is_supported(const string& sensor_type) return true; } - diff --git a/src/server/virtual_sensor_config.h b/src/server/virtual_sensor_config.h index 37d9fd75..949d8406 100644 --- a/src/server/virtual_sensor_config.h +++ b/src/server/virtual_sensor_config.h @@ -24,14 +24,14 @@ #define VIRTUAL_SENSOR_CONFIG_FILE_PATH "/usr/etc/virtual_sensors.xml" -typedef std::unordered_map Element; +typedef std::unordered_map Element; /* * an Element is a group of attributes * * */ -typedef std::unordered_map Virtual_sensor; +typedef std::unordered_map Virtual_sensor; /* * a Virtual_sensor is a group of elements to consist of one virtual sensor's configuration * @@ -40,7 +40,7 @@ typedef std::unordered_map Virtual_sensor; * ... */ -typedef std::unordered_map virtual_sensor_configs; +typedef std::unordered_map virtual_sensor_configs; /* * a Virtual_sensor_config represents virtual_sensors.xml * @@ -49,7 +49,7 @@ typedef std::unordered_map virtual_sensor_configs; * */ -typedef std::unordered_map virtual_sensor_device_configs; +typedef std::unordered_map virtual_sensor_device_configs; /* * a virtual_sensor_device_config represents virtual_sensors.xml * @@ -60,7 +60,6 @@ typedef std::unordered_map virtual_sensor_de class virtual_sensor_config : public device_config { private: 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); @@ -75,7 +74,7 @@ public: bool get(const std::string& sensor_type, const std::string& element, const std::string& attr, int *value); bool get(const std::string& sensor_type, const std::string& element, std::string& value); - bool get(const std::string& sensor_type, const std::string& element, float *value, int count =1); + bool get(const std::string& sensor_type, const std::string& element, float *value, int count = 1); bool get(const std::string& sensor_type, const std::string& element, int *value, int count = 1); bool is_supported(const std::string &sensor_type); diff --git a/src/server/worker_thread.cpp b/src/server/worker_thread.cpp index bf3320c6..23cd6ffe 100644 --- a/src/server/worker_thread.cpp +++ b/src/server/worker_thread.cpp @@ -55,7 +55,6 @@ worker_thread::worker_state_t worker_thread::get_state(void) return m_state; } - bool worker_thread::start(void) { lock l(m_mutex); @@ -73,7 +72,9 @@ bool worker_thread::start(void) th.detach(); } return true; - } else if (m_state == WORKER_STATE_PAUSED) { + } + + if (m_state == WORKER_STATE_PAUSED) { m_state = WORKER_STATE_WORKING; m_cond_working.notify_one(); return true; @@ -94,7 +95,6 @@ bool worker_thread::stop(void) } if ((m_state == WORKER_STATE_WORKING) || (m_state == WORKER_STATE_PAUSED)) { - if (m_state == WORKER_STATE_PAUSED) m_cond_working.notify_one(); @@ -123,7 +123,6 @@ bool worker_thread::pause(void) _E("Failed to pause, because current state(%d) is not for PAUSE", m_state); return false; - } bool worker_thread::resume(void) @@ -145,7 +144,6 @@ bool worker_thread::resume(void) return false; } - /* * After state changed to STOPPED, it should not access member fields, because some transition funciton of STOPPED delete this pointer diff --git a/src/server/worker_thread.h b/src/server/worker_thread.h index 2f5acabc..0aeff295 100644 --- a/src/server/worker_thread.h +++ b/src/server/worker_thread.h @@ -17,7 +17,6 @@ * */ - #ifndef _WORKER_THREAD_H_ #define _WORKER_THREAD_H_ diff --git a/src/shared/cbase_lock.cpp b/src/shared/cbase_lock.cpp index e7bcc95e..38f2f842 100644 --- a/src/shared/cbase_lock.cpp +++ b/src/shared/cbase_lock.cpp @@ -43,7 +43,6 @@ void cbase_lock::lock(lock_type type, const char* expr, const char *module, cons unsigned long long lock_acquired_time = 0; unsigned long long waiting_time = 0; - snprintf(m_curent_info, OWNER_INFO_LEN, "%s:%s(%d)", module, func, line); if (type == LOCK_TYPE_MUTEX) @@ -68,7 +67,6 @@ void cbase_lock::lock(lock_type type, const char* expr, const char *module, cons m_curent_info, expr, this, m_owner_info); pthread_mutex_unlock(&m_history_mutex); - if (type == LOCK_TYPE_MUTEX) lock_impl(); else if (type == LOCK_TYPE_READ) @@ -88,7 +86,6 @@ void cbase_lock::lock(lock_type type, const char* expr, const char *module, cons pthread_mutex_unlock(&m_history_mutex); } - void cbase_lock::lock(lock_type type) { if (type == LOCK_TYPE_MUTEX) @@ -104,7 +101,6 @@ void cbase_lock::unlock(void) unlock_impl(); } - int cbase_lock::lock_impl(void) { return 0; diff --git a/src/shared/cbase_lock.h b/src/shared/cbase_lock.h index 5a6b5e53..ad575626 100644 --- a/src/shared/cbase_lock.h +++ b/src/shared/cbase_lock.h @@ -29,24 +29,23 @@ enum lock_type { }; #ifdef _LOCK_DEBUG -#define AUTOLOCK(x) Autolock x##_autolock((x),LOCK_TYPE_MUTEX, #x, __MODULE__, __func__, __LINE__) -#define AUTOLOCK_R(x) Autolock x##_autolock_r((x),LOCK_TYPE_READ, #x, __MODULE__, __func__, __LINE__) -#define AUTOLOCK_W(x) Autolock x##_autolock_w((x),LOCK_TYPE_WRITE, #x, __MODULE__, __func__, __LINE__) +#define AUTOLOCK(x) Autolock x##_autolock((x), LOCK_TYPE_MUTEX, #x, __MODULE__, __func__, __LINE__) +#define AUTOLOCK_R(x) Autolock x##_autolock_r((x), LOCK_TYPE_READ, #x, __MODULE__, __func__, __LINE__) +#define AUTOLOCK_W(x) Autolock x##_autolock_w((x), LOCK_TYPE_WRITE, #x, __MODULE__, __func__, __LINE__) #define LOCK(x) (x).lock(#x, __MODULE__, __func__, __LINE__) #define LOCK_R(x) (x).lock(LOCK_TYPE_READ, #x, __MODULE__, __func__, __LINE__) #define LOCK_W(x) (x).lock(LOCK_TYPE_WRITE, #x, __MODULE__, __func__, __LINE__) #define UNLOCK(x) (x).unlock() #else -#define AUTOLOCK(x) Autolock x##_autolock((x),LOCK_TYPE_MUTEX) -#define AUTOLOCK_R(x) Autolock x##_autolock_r((x),LOCK_TYPE_READ) -#define AUTOLOCK_W(x) Autolock x##_autolock_w((x),LOCK_TYPE_WRITE) +#define AUTOLOCK(x) Autolock x##_autolock((x), LOCK_TYPE_MUTEX) +#define AUTOLOCK_R(x) Autolock x##_autolock_r((x), LOCK_TYPE_READ) +#define AUTOLOCK_W(x) Autolock x##_autolock_w((x), LOCK_TYPE_WRITE) #define LOCK(x) (x).lock() #define LOCK_R(x) (x).lock(LOCK_TYPE_READ) #define LOCK_W(x) (x).lock(LOCK_TYPE_WRITE) #define UNLOCK(x) (x).unlock() #endif - class cbase_lock { public: cbase_lock(); diff --git a/src/shared/cmutex.cpp b/src/shared/cmutex.cpp index a0330612..7f46633a 100644 --- a/src/shared/cmutex.cpp +++ b/src/shared/cmutex.cpp @@ -56,7 +56,6 @@ int cmutex::lock_impl(void) int cmutex::try_lock_impl(void) { return pthread_mutex_trylock(&m_mutex); - } int cmutex::unlock_impl() diff --git a/src/shared/command_common.h b/src/shared/command_common.h index 4a73f1df..3346654c 100644 --- a/src/shared/command_common.h +++ b/src/shared/command_common.h @@ -65,7 +65,6 @@ typedef struct { typedef struct { } cmd_byebye_t; - typedef struct { unsigned int type; } cmd_get_data_t; @@ -74,7 +73,6 @@ typedef struct { long value; } cmd_done_t; - typedef struct { int client_id; } cmd_get_id_done_t; @@ -115,7 +113,6 @@ typedef struct { int option; } cmd_set_option_t; - typedef struct { int attribute; int value; diff --git a/src/shared/cpacket.cpp b/src/shared/cpacket.cpp index fc908a41..a2ce0e06 100644 --- a/src/shared/cpacket.cpp +++ b/src/shared/cpacket.cpp @@ -96,7 +96,7 @@ void cpacket::set_payload_size(size_t size) } m_packet = (packet_header*) new(std::nothrow) char[size + sizeof(packet_header)]; - retm_if (!m_packet, "Failed to allocate memory"); + retm_if(!m_packet, "Failed to allocate memory"); m_packet->size = size; if (prev_cmd != CMD_NONE) diff --git a/src/shared/csocket.cpp b/src/shared/csocket.cpp index 6aa33b6f..0dc07ce8 100644 --- a/src/shared/csocket.cpp +++ b/src/shared/csocket.cpp @@ -32,7 +32,6 @@ csocket::csocket() memset(&m_addr, 0, sizeof(m_addr)); } - csocket::csocket(int sock_fd) : m_sock_fd(-1) , m_sock_type(SOCK_STREAM) @@ -44,7 +43,6 @@ csocket::csocket(int sock_fd) memset(&m_addr, 0, sizeof(m_addr)); } - csocket::csocket(const csocket &sock) : m_sock_fd(-1) , m_sock_type(SOCK_STREAM) @@ -78,7 +76,7 @@ bool csocket::create(int sock_type) return true; } -bool csocket::bind (const char *sock_path) +bool csocket::bind(const char *sock_path) { int length; mode_t socket_mode; @@ -104,7 +102,7 @@ bool csocket::bind (const char *sock_path) return false; } - socket_mode = ( S_IRWXU | S_IRWXG | S_IRWXO ); + socket_mode = (S_IRWXU | S_IRWXG | S_IRWXO); if (chmod(sock_path, socket_mode) < 0) { _ERRNO(errno, _E, "Failed to chmod for socket[%d]", m_sock_fd); close(); @@ -198,7 +196,6 @@ ssize_t csocket::recv_for_seqpacket(void* buffer, size_t size) const return err == 0 ? len : -err; } - ssize_t csocket::send_for_stream(const void *buffer, size_t size) const { ssize_t len; @@ -277,7 +274,6 @@ ssize_t csocket::recv_for_stream(void* buffer, size_t size) const return err == 0 ? total_recv_size : -err; } - ssize_t csocket::send(const void *buffer, size_t size) const { if (!is_valid()) { @@ -327,7 +323,7 @@ bool csocket::connect(const char *sock_path) addr_len = strlen(m_addr.sun_path) + sizeof(m_addr.sun_family); - if (::connect(m_sock_fd,(sockaddr *) &m_addr, addr_len) < 0) { + if (::connect(m_sock_fd, (sockaddr *) &m_addr, addr_len) < 0) { _ERRNO(errno, _E, "Failed to connect sock_fd: %d for %s", m_sock_fd, get_client_name()); return false; @@ -408,7 +404,6 @@ bool csocket::set_blocking_mode(bool blocking) return true; } - bool csocket::set_sock_type(void) { socklen_t opt_len; @@ -487,7 +482,6 @@ bool csocket::is_blocking_mode(void) return !(flags & O_NONBLOCK); } - bool csocket::is_valid(void) const { return (m_sock_fd >= 0); diff --git a/src/shared/csocket.h b/src/shared/csocket.h index 474c38d5..55582cf1 100644 --- a/src/shared/csocket.h +++ b/src/shared/csocket.h @@ -37,7 +37,7 @@ public: //Server bool create(int sock_type); - bool bind (const char *sock_path); + bool bind(const char *sock_path); bool listen(const int max_connections); bool accept(csocket& client_socket) const; diff --git a/src/shared/poller.cpp b/src/shared/poller.cpp index 45e59369..b1a3ded9 100644 --- a/src/shared/poller.cpp +++ b/src/shared/poller.cpp @@ -88,7 +88,6 @@ bool poller::fill_event_queue(void) return true; } - bool poller::poll(struct epoll_event &event) { while (true) { diff --git a/src/shared/sensor_info.cpp b/src/shared/sensor_info.cpp index f7c241ae..2a2ca831 100644 --- a/src/shared/sensor_info.cpp +++ b/src/shared/sensor_info.cpp @@ -225,7 +225,6 @@ void sensor_info::show(void) _I("Wakeup_supported = %d", m_wakeup_supported); } - void sensor_info::clear(void) { m_type = UNKNOWN_SENSOR; @@ -243,7 +242,6 @@ void sensor_info::clear(void) m_wakeup_supported = false; } - void sensor_info::put(raw_data_t &data, int value) { char buffer[sizeof(value)]; diff --git a/src/shared/sensor_log.h b/src/shared/sensor_log.h index bcbe9216..236eb1de 100644 --- a/src/shared/sensor_log.h +++ b/src/shared/sensor_log.h @@ -33,12 +33,12 @@ #endif #define LOG_TAG "SENSOR" -#define LOG_DUMP(fp, fmt, arg...) do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while(0) +#define LOG_DUMP(fp, fmt, arg...) do { if (fp) fprintf(fp, fmt, ##arg); else _E(fmt, ##arg); } while (0) #ifdef _DEBUG #define DBG SLOGD #else -#define DBG(...) do{} while(0) +#define DBG(...) do {} while (0) #endif #define ERR SLOGE diff --git a/src/test/src/check-sensor.c b/src/test/src/check-sensor.c index d9cd3ba0..406008a6 100644 --- a/src/test/src/check-sensor.c +++ b/src/test/src/check-sensor.c @@ -27,8 +27,6 @@ #include #include "check-sensor.h" - - void printpollinglogs(sensor_type_t type,sensor_data_t data) { switch(type) { @@ -299,7 +297,6 @@ int polling_sensor(sensor_type_t sensor_type, unsigned int event) handle = sensord_connect(sensor); result = sensord_start(handle, 1); - if (!result) { printf("Can't start the sensor\n"); printf("Error\n\n\n\n"); @@ -308,7 +305,7 @@ int polling_sensor(sensor_type_t sensor_type, unsigned int event) sensor_data_t data; - while(1) { + while (1) { result = sensord_get_data(handle, event, &data); printpollinglogs(sensor_type, data); usleep(100000); diff --git a/src/test/src/multi-thread-performance-test.c b/src/test/src/multi-thread-performance-test.c index 7b0bb1b9..9130d472 100644 --- a/src/test/src/multi-thread-performance-test.c +++ b/src/test/src/multi-thread-performance-test.c @@ -27,7 +27,6 @@ #include #include "check-sensor.h" - void usage() { printf("Usage : ./multi-sensor (optional)\n\n"); @@ -84,7 +83,6 @@ int main(int argc, char **argv) } } - int MAX = 6, j = 0, k = 0; struct pthread_arguments arg[MAX]; int t = 0; @@ -102,17 +100,13 @@ int main(int argc, char **argv) arg[5].sensor_type = LIGHT_SENSOR; arg[5].event = LIGHT_LUX_DATA_EVENT; - for(t = 0; t < MAX; t++) - { + for (t = 0; t < MAX; t++) arg[t].interval = interval; - } pthread_t thread_id[MAX]; - for(j = 0; j < MAX; j++) - { + for (j = 0; j < MAX; j++) pthread_create(&thread_id[j], NULL, check_sensor, (void*)&arg[j]); - } sleep(TIMEOUT); return 0;