sensord: cplugin_info_list implementation 75/49875/1
authorHongkuk, Son <hongkuk.son@samsung.com>
Wed, 21 Oct 2015 06:08:54 +0000 (15:08 +0900)
committerHongkuk, Son <hongkuk.son@samsung.com>
Wed, 21 Oct 2015 06:09:47 +0000 (15:09 +0900)
Signed-off-by: Hongkuk, Son <hongkuk.son@samsung.com>
Change-Id: I8180880b26021462398c94761206b84fd2c3dfbe

13 files changed:
src/shared/CMakeLists.txt
src/shared/batch_info_list.cpp [deleted file]
src/shared/batch_info_list.h [deleted file]
src/shared/cbatch_info_list.cpp [deleted file]
src/shared/cbatch_info_list.h [deleted file]
src/shared/cinterval_info_list.cpp [deleted file]
src/shared/cinterval_info_list.h [deleted file]
src/shared/cplugin_info_list.cpp [new file with mode: 0644]
src/shared/cplugin_info_list.h [new file with mode: 0644]
src/shared/cwakeup_info_list.cpp [deleted file]
src/shared/cwakeup_info_list.h [deleted file]
src/shared/sensor_base.cpp
src/shared/sensor_base.h

index b5d589c..45b6af6 100644 (file)
@@ -28,9 +28,7 @@ add_library(sensord-server SHARED
        csensor_usage.cpp
        cclient_info_manager.cpp
        cclient_sensor_record.cpp
-       cinterval_info_list.cpp
-       cwakeup_info_list.cpp
-       cbatch_info_list.cpp
+       cplugin_info_list.cpp
        sensor_plugin_loader.cpp
        sensor_hal.cpp
        sensor_base.cpp
@@ -64,9 +62,7 @@ install(FILES
        csensor_config.h
        cvirtual_sensor_config.h
        csensor_event_queue.h
-       cinterval_info_list.h
-       cwakeup_info_list.h
-       cbatch_info_list.h
+       cplugin_info_list.h
        sensor_plugin_loader.h
        sensor_hal.h
        sensor_base.h
diff --git a/src/shared/batch_info_list.cpp b/src/shared/batch_info_list.cpp
deleted file mode 100644 (file)
index 0fd84b1..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <batch_info_list.h>
-#include <algorithm>
-
-using std::pair;
-using std::shared_ptr;
-
-batch_info::batch_info(unsigned int interval, unsigned int latency)
-{
-       this->interval = interval;
-       this->latency = latency;
-}
-
-bool batch_info_list::add_batch(int id, unsigned int interval, unsigned int latency)
-{
-       auto it_batch_info = m_batch_infos.find(id);
-
-       if (it_batch_info != m_batch_infos.end()) {
-               it_batch_info->second->interval = interval;
-               it_batch_info->second->latency = latency;
-               return true;
-       }
-
-       m_batch_infos.insert(pair<int, shared_ptr<batch_info>> (id, std::make_shared<batch_info> (interval, latency)));
-       return true;
-}
-
-bool batch_info_list::delete_batch(int id)
-{
-       auto it_batch_info = m_batch_infos.find(id);
-
-       if (it_batch_info == m_batch_infos.end())
-               return false;
-
-       m_batch_infos.erase(it_batch_info);
-       return true;
-}
-
-bool batch_info_list::get_batch(int id, unsigned int &interval, unsigned int &latency)
-{
-       auto it_batch_info = m_batch_infos.find(id);
-
-       if (it_batch_info == m_batch_infos.end())
-               return false;
-
-       interval = it_batch_info->second->interval;
-       latency = it_batch_info->second->latency;
-
-       return true;
-}
-
-bool batch_info_list::get_best_batch(unsigned int &interval, unsigned int &latency)
-{
-       if (m_batch_infos.empty())
-               return false;
-
-       auto get_min_interval = [](pair<const int, shared_ptr<batch_info>> &a, pair<const int, shared_ptr<batch_info>> &b){
-               return (a.second->interval < b.second->interval);
-       };
-
-       auto get_min_latency = [](pair<const int, shared_ptr<batch_info>> &a, pair<const int, shared_ptr<batch_info>> &b){
-               return (a.second->latency < b.second->latency);
-       };
-
-       auto it_interval_min = std::min_element(m_batch_infos.begin(), m_batch_infos.end(), get_min_interval);
-       auto it_latency_min = std::min_element(m_batch_infos.begin(), m_batch_infos.end(), get_min_latency);
-
-       interval = it_interval_min->second->interval;
-       latency = it_latency_min->second->latency;
-
-       return true;
-}
diff --git a/src/shared/batch_info_list.h b/src/shared/batch_info_list.h
deleted file mode 100644 (file)
index d6c22f0..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _BATCH_INFO_LIST_CLASS_H_
-#define _BATCH_INFO_LIST_CLASS_H_
-
-#include <unordered_map>
-#include <memory>
-
-class batch_info
-{
-public:
-       batch_info(unsigned int interval, unsigned int latency);
-       unsigned int interval;
-       unsigned int latency;
-};
-
-class batch_info_list
-{
-private:
-       std::unordered_map<int, std::shared_ptr<batch_info>> m_batch_infos;
-
-public:
-       bool add_batch(int id, unsigned int interval, unsigned int latency);
-       bool delete_batch(int id);
-       bool get_batch(int id, unsigned int &interval, unsigned int &latency);
-       bool get_best_batch(unsigned int &interval, unsigned int &latency);
-};
-#endif
diff --git a/src/shared/cbatch_info_list.cpp b/src/shared/cbatch_info_list.cpp
deleted file mode 100644 (file)
index 3c2681c..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <cbatch_info_list.h>
-#include <algorithm>
-
-cbatch_info::cbatch_info(int client_id, unsigned int latency)
-{
-       this->client_id = client_id;
-       this->latency = latency;
-}
-
-bool cbatch_info_list::comp_batch_info(cbatch_info a, cbatch_info b)
-{
-       return a.latency < b.latency;
-}
-
-cbatch_info_iterator cbatch_info_list::find_if(int client_id)
-{
-       auto iter = m_list.begin();
-
-       while (iter != m_list.end()) {
-               if ((iter->client_id == client_id))
-                       break;
-
-               ++iter;
-       }
-
-       return iter;
-}
-
-bool cbatch_info_list::add_batch(int client_id, unsigned int latency)
-{
-       auto iter = find_if(client_id);
-
-       if (iter != m_list.end())
-               *iter = cbatch_info(client_id, latency);
-       else
-               m_list.push_back(cbatch_info(client_id, latency));
-
-       return true;
-}
-
-bool cbatch_info_list::delete_batch(int client_id)
-{
-       auto iter = find_if(client_id);
-
-       if (iter == m_list.end())
-               return false;
-
-       m_list.erase(iter);
-
-       return true;
-}
-
-unsigned int cbatch_info_list::get_batch(int client_id)
-{
-       auto iter = find_if(client_id);
-
-       if (iter == m_list.end())
-               return 0;
-
-       return iter->latency;
-}
-
-unsigned int cbatch_info_list::get_max(void)
-{
-       if (m_list.empty())
-               return 0;
-
-       auto iter = max_element(m_list.begin(), m_list.end(), comp_batch_info);
-
-       return iter->latency;
-}
-
diff --git a/src/shared/cbatch_info_list.h b/src/shared/cbatch_info_list.h
deleted file mode 100644 (file)
index 390c39d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _CBATCH_INFO_LIST_CLASS_H_
-#define _CBATCH_INFO_LIST_CLASS_H_
-
-#include <list>
-
-class cbatch_info
-{
-public:
-       cbatch_info(int client_id, unsigned int latency);
-       int client_id;
-       unsigned int latency;
-};
-
-typedef std::list<cbatch_info>::iterator cbatch_info_iterator;
-
-class cbatch_info_list
-{
-private:
-       static bool comp_batch_info(cbatch_info a, cbatch_info b);
-       cbatch_info_iterator find_if(int client_id);
-
-       std::list<cbatch_info> m_list;
-
-public:
-       bool add_batch(int client_id, unsigned int latency);
-       bool delete_batch(int client_id);
-       unsigned int get_batch(int client_id);
-       unsigned int get_max(void);
-};
-#endif
diff --git a/src/shared/cinterval_info_list.cpp b/src/shared/cinterval_info_list.cpp
deleted file mode 100755 (executable)
index 5adf0b5..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <cinterval_info_list.h>
-#include <algorithm>
-
-
-cinterval_info::cinterval_info(int client_id, bool is_processor, unsigned int interval)
-{
-       this->client_id = client_id;
-       this->is_processor = is_processor;
-       this->interval = interval;
-}
-
-bool cinterval_info_list::comp_interval_info(cinterval_info a, cinterval_info b)
-{
-       return a.interval < b.interval;
-}
-
-cinterval_info_iterator cinterval_info_list::find_if(int client_id, bool is_processor)
-{
-       auto iter = m_list.begin();
-
-       while (iter != m_list.end()) {
-               if ((iter->client_id == client_id) && (iter->is_processor == is_processor))
-                       break;
-
-               ++iter;
-       }
-
-       return iter;
-}
-
-
-bool cinterval_info_list::add_interval(int client_id, unsigned int interval, bool is_processor)
-{
-       auto iter = find_if(client_id, is_processor);
-
-       if (iter != m_list.end())
-               *iter = cinterval_info(client_id, is_processor, interval);
-       else
-               m_list.push_back(cinterval_info(client_id, is_processor, interval));
-
-       return true;
-}
-
-bool cinterval_info_list::delete_interval(int client_id, bool is_processor)
-{
-       auto iter = find_if(client_id, is_processor);
-
-       if (iter == m_list.end())
-               return false;
-
-       m_list.erase(iter);
-
-       return true;
-}
-
-unsigned int cinterval_info_list::get_interval(int client_id, bool is_processor)
-{
-       auto iter = find_if(client_id, is_processor);
-
-       if (iter == m_list.end())
-               return 0;
-
-       return iter->interval;
-}
-
-unsigned int cinterval_info_list::get_min(void)
-{
-       if (m_list.empty())
-               return 0;
-
-       auto iter = min_element(m_list.begin(), m_list.end(), comp_interval_info);
-
-       return iter->interval;
-}
diff --git a/src/shared/cinterval_info_list.h b/src/shared/cinterval_info_list.h
deleted file mode 100755 (executable)
index 3c28c95..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#if !defined(_CINTERVAL_INFO_LIST_CLASS_H_)
-#define _CINTERVAL_INFO_LIST_CLASS_H_
-
-#include <list>
-
-class cinterval_info
-{
-public:
-       cinterval_info(int client_id, bool is_processor, unsigned int interval);
-       int client_id;
-       bool is_processor;
-       unsigned int interval;
-};
-
-typedef std::list<cinterval_info>::iterator cinterval_info_iterator;
-
-class cinterval_info_list
-{
-private:
-       static bool comp_interval_info(cinterval_info a, cinterval_info b);
-       cinterval_info_iterator find_if(int client_id, bool is_processor);
-
-       std::list<cinterval_info> m_list;
-
-public:
-       bool add_interval(int client_id, unsigned int interval, bool is_processor);
-       bool delete_interval(int client_id, bool is_processor);
-       unsigned int get_interval(int client_id, bool is_processor);
-       unsigned int get_min(void);
-};
-#endif
diff --git a/src/shared/cplugin_info_list.cpp b/src/shared/cplugin_info_list.cpp
new file mode 100644 (file)
index 0000000..db9714d
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * libsensord-share
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <cplugin_info_list.h>
+#include <algorithm>
+
+
+cinterval_info::cinterval_info(int client_id, bool is_processor, unsigned int interval)
+{
+       this->client_id = client_id;
+       this->is_processor = is_processor;
+       this->interval = interval;
+}
+
+cbatch_info::cbatch_info(int client_id, unsigned int latency)
+{
+       this->client_id = client_id;
+       this->latency = latency;
+}
+
+cwakeup_info::cwakeup_info(int client_id, int wakeup)
+{
+       this->client_id = client_id;
+       this->wakeup = wakeup;
+}
+
+bool cplugin_info_list::comp_interval_info(cinterval_info a, cinterval_info b)
+{
+       return a.interval < b.interval;
+}
+
+bool cplugin_info_list::comp_batch_info(cbatch_info a, cbatch_info b)
+{
+       return a.latency < b.latency;
+}
+
+cinterval_info_iterator cplugin_info_list::find_if_interval_info(int client_id, bool is_processor)
+{
+       auto iter = m_interval_info_list.begin();
+
+       while (iter != m_interval_info_list.end()) {
+               if ((iter->client_id == client_id) && (iter->is_processor == is_processor))
+                       break;
+
+               ++iter;
+       }
+
+       return iter;
+}
+
+cbatch_info_iterator cplugin_info_list::find_if_batch_info(int client_id)
+{
+       auto iter = m_batch_info_list.begin();
+
+       while (iter != m_batch_info_list.end()) {
+               if ((iter->client_id == client_id))
+                       break;
+
+               ++iter;
+       }
+
+       return iter;
+}
+
+cwakeup_info_iterator cplugin_info_list::find_if_wakeup_info(int client_id)
+{
+       auto iter = m_wakeup_info_list.begin();
+
+       while (iter != m_wakeup_info_list.end()) {
+               if (iter->client_id == client_id)
+                       break;
+
+               ++iter;
+       }
+
+       return iter;
+}
+
+bool cplugin_info_list::add_interval(int client_id, unsigned int interval, bool is_processor)
+{
+       auto iter = find_if_interval_info(client_id, is_processor);
+
+       if (iter != m_interval_info_list.end())
+               *iter = cinterval_info(client_id, is_processor, interval);
+       else
+               m_interval_info_list.push_back(cinterval_info(client_id, is_processor, interval));
+
+       return true;
+}
+
+bool cplugin_info_list::delete_interval(int client_id, bool is_processor)
+{
+       auto iter = find_if_interval_info(client_id, is_processor);
+
+       if (iter == m_interval_info_list.end())
+               return false;
+
+       m_interval_info_list.erase(iter);
+
+       return true;
+}
+
+unsigned int cplugin_info_list::get_interval(int client_id, bool is_processor)
+{
+       auto iter = find_if_interval_info(client_id, is_processor);
+
+       if (iter == m_interval_info_list.end())
+               return 0;
+
+       return iter->interval;
+}
+
+unsigned int cplugin_info_list::get_min_interval(void)
+{
+       if (m_interval_info_list.empty())
+               return 0;
+
+       auto iter = min_element(m_interval_info_list.begin(), m_interval_info_list.end(), comp_interval_info);
+
+       return iter->interval;
+}
+
+bool cplugin_info_list::add_batch(int client_id, unsigned int latency)
+{
+       auto iter = find_if_batch_info(client_id);
+
+       if (iter != m_batch_info_list.end())
+               *iter = cbatch_info(client_id, latency);
+       else
+               m_batch_info_list.push_back(cbatch_info(client_id, latency));
+
+       return true;
+}
+
+bool cplugin_info_list::delete_batch(int client_id)
+{
+       auto iter = find_if_batch_info(client_id);
+
+       if (iter == m_batch_info_list.end())
+               return false;
+
+       m_batch_info_list.erase(iter);
+
+       return true;
+}
+
+unsigned int cplugin_info_list::get_batch(int client_id)
+{
+       auto iter = find_if_batch_info(client_id);
+
+       if (iter == m_batch_info_list.end())
+               return 0;
+
+       return iter->latency;
+}
+
+unsigned int cplugin_info_list::get_max_batch(void)
+{
+       if (m_batch_info_list.empty())
+               return 0;
+
+       auto iter = max_element(m_batch_info_list.begin(), m_batch_info_list.end(), comp_batch_info);
+
+       return iter->latency;
+}
+
+bool cplugin_info_list::add_wakeup(int client_id, int wakeup)
+{
+       auto iter = find_if_wakeup_info(client_id);
+
+       if (iter != m_wakeup_info_list.end())
+               *iter = cwakeup_info(client_id, wakeup);
+       else
+               m_wakeup_info_list.push_back(cwakeup_info(client_id, wakeup));
+
+       return true;
+}
+
+bool cplugin_info_list::delete_wakeup(int client_id)
+{
+       auto iter = find_if_wakeup_info(client_id);
+
+       if (iter == m_wakeup_info_list.end())
+               return false;
+
+       m_wakeup_info_list.erase(iter);
+
+       return true;
+}
+
+int cplugin_info_list::get_wakeup(int client_id)
+{
+       auto iter = find_if_wakeup_info(client_id);
+
+       if (iter == m_wakeup_info_list.end())
+               return -1;
+
+       return iter->wakeup;
+}
+
+int cplugin_info_list::is_wakeup_on(void)
+{
+       if (m_wakeup_info_list.empty())
+               return -1;
+
+       auto iter = m_wakeup_info_list.begin();
+
+       while (iter != m_wakeup_info_list.end()) {
+               if (iter->wakeup == true)
+                       break;
+
+               ++iter;
+       }
+
+       return iter->wakeup;
+}
+
diff --git a/src/shared/cplugin_info_list.h b/src/shared/cplugin_info_list.h
new file mode 100644 (file)
index 0000000..6ea149e
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * libsensord-share
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _CPLUGIN_INFO_LIST_CLASS_H_
+#define _CPLUGIN_INFO_LIST_CLASS_H_
+
+#include <list>
+
+class cinterval_info
+{
+public:
+       cinterval_info(int client_id, bool is_processor, unsigned int interval);
+       int client_id;
+       bool is_processor;
+       unsigned int interval;
+};
+
+typedef std::list<cinterval_info>::iterator cinterval_info_iterator;
+
+class cbatch_info
+{
+public:
+       cbatch_info(int client_id, unsigned int latency);
+       int client_id;
+       unsigned int latency;
+};
+
+typedef std::list<cbatch_info>::iterator cbatch_info_iterator;
+
+class cwakeup_info
+{
+public:
+       cwakeup_info(int client_id, int wakeup);
+       int client_id;
+       int wakeup;
+};
+
+typedef std::list<cwakeup_info>::iterator cwakeup_info_iterator;
+
+class cplugin_info_list
+{
+private:
+       static bool comp_interval_info(cinterval_info a, cinterval_info b);
+       cinterval_info_iterator find_if_interval_info(int client_id, bool is_processor);
+
+       static bool comp_batch_info(cbatch_info a, cbatch_info b);
+       cbatch_info_iterator find_if_batch_info(int client_id);
+
+       cwakeup_info_iterator find_if_wakeup_info(int client_id);
+
+       std::list<cinterval_info> m_interval_info_list;
+       std::list<cbatch_info> m_batch_info_list;
+       std::list<cwakeup_info> m_wakeup_info_list;
+
+public:
+       bool add_interval(int client_id, unsigned int interval, bool is_processor);
+       bool delete_interval(int client_id, bool is_processor);
+       unsigned int get_interval(int client_id, bool is_processor);
+       unsigned int get_min_interval(void);
+
+       bool add_batch(int client_id, unsigned int latency);
+       bool delete_batch(int client_id);
+       unsigned int get_batch(int client_id);
+       unsigned int get_max_batch(void);
+
+       bool add_wakeup(int client_id, int wakeup);
+       bool delete_wakeup(int client_id);
+       int get_wakeup(int client_id);
+       int is_wakeup_on(void);
+};
+#endif
diff --git a/src/shared/cwakeup_info_list.cpp b/src/shared/cwakeup_info_list.cpp
deleted file mode 100644 (file)
index c695d4c..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <cwakeup_info_list.h>
-#include <algorithm>
-
-
-cwakeup_info::cwakeup_info(int client_id, int wakeup)
-{
-       this->client_id = client_id;
-       this->wakeup = wakeup;
-}
-
-cwakeup_info_iterator cwakeup_info_list::find_if(int client_id)
-{
-       auto iter = m_list.begin();
-
-       while (iter != m_list.end()) {
-               if (iter->client_id == client_id)
-                       break;
-
-               ++iter;
-       }
-
-       return iter;
-}
-
-
-bool cwakeup_info_list::add_wakeup(int client_id, int wakeup)
-{
-       auto iter = find_if(client_id);
-
-       if (iter != m_list.end())
-               *iter = cwakeup_info(client_id, wakeup);
-       else
-               m_list.push_back(cwakeup_info(client_id, wakeup));
-
-       return true;
-}
-
-bool cwakeup_info_list::delete_wakeup(int client_id)
-{
-       auto iter = find_if(client_id);
-
-       if (iter == m_list.end())
-               return false;
-
-       m_list.erase(iter);
-
-       return true;
-}
-
-int cwakeup_info_list::get_wakeup(int client_id)
-{
-       auto iter = find_if(client_id);
-
-       if (iter == m_list.end())
-               return -1;
-
-       return iter->wakeup;
-}
-
-int cwakeup_info_list::is_wakeup_on(void)
-{
-       if (m_list.empty())
-               return -1;
-
-       auto iter = m_list.begin();
-
-       while (iter != m_list.end()) {
-               if (iter->wakeup == true)
-                       break;
-
-               ++iter;
-       }
-
-       return iter->wakeup;
-}
-
diff --git a/src/shared/cwakeup_info_list.h b/src/shared/cwakeup_info_list.h
deleted file mode 100644 (file)
index f11e7e8..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * libsensord-share
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#ifndef _CWAKEUP_INFO_LIST_CLASS_H_
-#define _CWAKEUP_INFO_LIST_CLASS_H_
-
-#include <list>
-
-class cwakeup_info
-{
-public:
-       cwakeup_info(int client_id, int wakeup);
-       int client_id;
-       int wakeup;
-};
-
-typedef std::list<cwakeup_info>::iterator cwakeup_info_iterator;
-
-class cwakeup_info_list
-{
-private:
-       cwakeup_info_iterator find_if(int client_id);
-
-       std::list<cwakeup_info> m_list;
-
-public:
-       bool add_wakeup(int client_id, int wakeup);
-       bool delete_wakeup(int client_id);
-       int get_wakeup(int client_id);
-       int is_wakeup_on(void);
-};
-#endif
index 83815a9..4a7ce4d 100644 (file)
@@ -206,14 +206,14 @@ bool sensor_base::add_interval(int client_id, unsigned int interval, bool is_pro
 {
        unsigned int prev_min, cur_min;
 
-       AUTOLOCK(m_interval_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_min = m_interval_info_list.get_min();
+       prev_min = m_plugin_info_list.get_min_interval();
 
-       if (!m_interval_info_list.add_interval(client_id, interval, is_processor))
+       if (!m_plugin_info_list.add_interval(client_id, interval, is_processor))
                return false;
 
-       cur_min = m_interval_info_list.get_min();
+       cur_min = m_plugin_info_list.get_min_interval();
 
        if (cur_min != prev_min) {
                INFO("Min interval for sensor[0x%x] is changed from %dms to %dms"
@@ -229,14 +229,14 @@ bool sensor_base::add_interval(int client_id, unsigned int interval, bool is_pro
 bool sensor_base::delete_interval(int client_id, bool is_processor)
 {
        unsigned int prev_min, cur_min;
-       AUTOLOCK(m_interval_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_min = m_interval_info_list.get_min();
+       prev_min = m_plugin_info_list.get_min_interval();
 
-       if (!m_interval_info_list.delete_interval(client_id, is_processor))
+       if (!m_plugin_info_list.delete_interval(client_id, is_processor))
                return false;
 
-       cur_min = m_interval_info_list.get_min();
+       cur_min = m_plugin_info_list.get_min_interval();
 
        if (!cur_min) {
                INFO("No interval for sensor[0x%x] by%sclient[%d] deleting interval, "
@@ -259,23 +259,23 @@ bool sensor_base::delete_interval(int client_id, bool is_processor)
 
 unsigned int sensor_base::get_interval(int client_id, bool is_processor)
 {
-       AUTOLOCK(m_interval_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       return m_interval_info_list.get_interval(client_id, is_processor);
+       return m_plugin_info_list.get_interval(client_id, is_processor);
 }
 
 bool sensor_base::add_wakeup(int client_id, int wakeup)
 {
        int prev_wakeup, cur_wakeup;
 
-       AUTOLOCK(m_wakeup_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_wakeup = m_wakeup_info_list.is_wakeup_on();
+       prev_wakeup = m_plugin_info_list.is_wakeup_on();
 
-       if (!m_wakeup_info_list.add_wakeup(client_id, wakeup))
+       if (!m_plugin_info_list.add_wakeup(client_id, wakeup))
                return false;
 
-       cur_wakeup = m_wakeup_info_list.is_wakeup_on();
+       cur_wakeup = m_plugin_info_list.is_wakeup_on();
 
        if ((cur_wakeup == SENSOR_WAKEUP_ON) && (prev_wakeup < SENSOR_WAKEUP_ON)) {
                INFO("Wakeup for sensor[0x%x] is changed from %d to %d by client[%d] adding wakeup",
@@ -289,14 +289,14 @@ bool sensor_base::add_wakeup(int client_id, int wakeup)
 bool sensor_base::delete_wakeup(int client_id)
 {
        int prev_wakeup, cur_wakeup;
-       AUTOLOCK(m_wakeup_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_wakeup = m_wakeup_info_list.is_wakeup_on();
+       prev_wakeup = m_plugin_info_list.is_wakeup_on();
 
-       if (!m_wakeup_info_list.delete_wakeup(client_id))
+       if (!m_plugin_info_list.delete_wakeup(client_id))
                return false;
 
-       cur_wakeup = m_wakeup_info_list.is_wakeup_on();
+       cur_wakeup = m_plugin_info_list.is_wakeup_on();
 
        if ((cur_wakeup < SENSOR_WAKEUP_ON) && (prev_wakeup == SENSOR_WAKEUP_ON)) {
                INFO("Wakeup for sensor[0x%x] is changed from %d to %d by client[%d] deleting wakeup",
@@ -309,23 +309,23 @@ bool sensor_base::delete_wakeup(int client_id)
 
 int sensor_base::get_wakeup(int client_id)
 {
-       AUTOLOCK(m_wakeup_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       return m_wakeup_info_list.is_wakeup_on();
+       return m_plugin_info_list.is_wakeup_on();
 }
 
 bool sensor_base::add_batch(int client_id, unsigned int latency)
 {
        unsigned int prev_max, cur_max;
 
-       AUTOLOCK(m_batch_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_max = m_batch_info_list.get_max();
+       prev_max = m_plugin_info_list.get_max_batch();
 
-       if (!m_batch_info_list.add_batch(client_id, latency))
+       if (!m_plugin_info_list.add_batch(client_id, latency))
                return false;
 
-       cur_max = m_batch_info_list.get_max();
+       cur_max = m_plugin_info_list.get_max_batch();
 
        if (cur_max != prev_max) {
                INFO("Max latency for sensor[0x%x] is changed from %dms to %dms by client[%d] adding latency",
@@ -339,14 +339,14 @@ bool sensor_base::add_batch(int client_id, unsigned int latency)
 bool sensor_base::delete_batch(int client_id)
 {
        unsigned int prev_max, cur_max;
-       AUTOLOCK(m_batch_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       prev_max = m_batch_info_list.get_max();
+       prev_max = m_plugin_info_list.get_max_batch();
 
-       if (!m_batch_info_list.delete_batch(client_id))
+       if (!m_plugin_info_list.delete_batch(client_id))
                return false;
 
-       cur_max = m_batch_info_list.get_max();
+       cur_max = m_plugin_info_list.get_max_batch();
 
        if (!cur_max) {
                INFO("No latency for sensor[0x%x] by client[%d] deleting latency, so set to default 0 ms",
@@ -365,9 +365,9 @@ bool sensor_base::delete_batch(int client_id)
 
 unsigned int sensor_base::get_batch(int client_id)
 {
-       AUTOLOCK(m_batch_info_list_mutex);
+       AUTOLOCK(m_plugin_info_list_mutex);
 
-       return m_batch_info_list.get_batch(client_id);
+       return m_plugin_info_list.get_batch(client_id);
 }
 
 void sensor_base::get_sensor_info(sensor_type_t sensor_type, sensor_info &info)
index 2f726f9..6eaf01d 100644 (file)
@@ -28,9 +28,7 @@
 #include <condition_variable>
 #include <string>
 
-#include <cinterval_info_list.h>
-#include <cwakeup_info_list.h>
-#include <cbatch_info_list.h>
+#include <cplugin_info_list.h>
 #include <cmutex.h>
 
 #include <common.h>
@@ -100,12 +98,8 @@ protected:
        sensor_privilege_t m_privilege;
        int m_permission;
 
-       cinterval_info_list m_interval_info_list;
-       cwakeup_info_list m_wakeup_info_list;
-       cbatch_info_list m_batch_info_list;
-       cmutex m_interval_info_list_mutex;
-       cmutex m_wakeup_info_list_mutex;
-       cmutex m_batch_info_list_mutex;
+       cplugin_info_list m_plugin_info_list;
+       cmutex m_plugin_info_list_mutex;
 
        cmutex m_mutex;