Add an implementation of dpm_foreach_zone API 45/67945/4
authorSungbae Yoo <sungbae.yoo@samsung.com>
Fri, 29 Apr 2016 09:29:52 +0000 (18:29 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Tue, 3 May 2016 06:59:21 +0000 (23:59 -0700)
Change-Id: I01c52611557e6cbd8819aa391227f71314a101d7
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
libs/dpm/zone.cpp
libs/dpm/zone.h

index 27d2c99..83888a9 100644 (file)
@@ -87,6 +87,22 @@ void dpm_zone_free_iterator(dpm_zone_iterator_h iter)
     delete reinterpret_cast<dpm_zone_iterator*>(iter);
 }
 
+int dpm_zone_foreach_name(dpm_zone_policy_h handle,
+                          dpm_zone_foreach_cb callback, void* user_data)
+{
+    RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
+    RET_ON_FAILURE(callback, DPM_ERROR_INVALID_PARAMETER);
+
+    ZonePolicy& zone = GetPolicyInterface<ZonePolicy>(handle);
+    std::vector<std::string> list = zone.getZoneList();
+    for (std::vector<std::string>::iterator it = list.begin();
+         it != list.end(); it++) {
+        callback((*it).c_str(), user_data);
+    }
+
+    return 0;
+}
+
 int dpm_zone_get_state(dpm_zone_policy_h handle, const char* name, dpm_zone_state_e *state)
 {
     RET_ON_FAILURE(handle, DPM_ERROR_INVALID_PARAMETER);
index bb3f87b..12d4809 100644 (file)
@@ -199,7 +199,7 @@ DPM_API int dpm_zone_destroy_iterator(dpm_zone_iterator_h iter);
  * @param[in]   user_data The user data passed from dpm_zone_foreach_name
  * @see         dpm_zone_foreach_name()
  */
-typedef void(*dpm_zone_foreach_cb)(const char* name, const char *user_data);
+typedef void(*dpm_zone_foreach_cb)(const char* name, void *user_data);
 
 /**
  * @brief       Retrieves all the name of created zones