Adding a new function for priority list insertion 34/33434/3
authorVibhor Gaur <vibhor.gaur@samsung.com>
Fri, 9 Jan 2015 09:48:47 +0000 (15:18 +0530)
committerVibhor Gaur <vibhor.gaur@samsung.com>
Fri, 9 Jan 2015 13:11:31 +0000 (18:41 +0530)
-Adding seperate function for insertion into priority list for virtual sensors.
-Initially insertion was done inside the same function as event registration.
-Adds modularity to the code.

Change-Id: Ifed2b6f690de70f103b389e24dc2d254398eaf66

src/server/command_worker.cpp
src/server/command_worker.h

index 1c40395..cd3edc9 100755 (executable)
@@ -535,12 +535,8 @@ bool command_worker::cmd_register_event(void *payload)
                ret_value = OP_ERROR;
                goto out;
        }
-               if (cmd->event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME || cmd->event_type ==  LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME || cmd->event_type == ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME) {
-                       priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
-                       priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
-                       priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
-       }
 
+       insert_priority_list(cmd->event_type);
        m_module->add_client(cmd->event_type);
 
        ret_value = OP_SUCCESS;
@@ -849,3 +845,23 @@ csensor_event_dispatcher& command_worker::get_event_dispathcher(void)
        return csensor_event_dispatcher::get_instance();
 }
 
+void insert_priority_list(unsigned int event_type)
+{
+       if (event_type == ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME) {
+               priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
+        }
+
+       if (event_type == LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME) {
+               priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
+        }
+
+       if (event_type == GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME) {
+               priority_list.insert(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME);
+               priority_list.insert(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME);
+        }
+}
index cdd08e8..33f1b0a 100755 (executable)
@@ -29,6 +29,7 @@
 using std::multimap;
 
 typedef multimap<int, raw_data_t> sensor_raw_data_map;
+void insert_priority_list(unsigned int);
 
 class command_worker {
 private: