From 36a3e1780142612aca7d75e9feffd2b82cc010cd Mon Sep 17 00:00:00 2001 From: "sung.goo.kim" Date: Thu, 19 Nov 2015 17:51:02 +0900 Subject: [PATCH] Remove iotcon_representation_del_state, Rename iotcon_representation_append_child Change-Id: Ie803b4b8879e647837e39af0ea86e0fca67501a8 --- lib/icl-representation.c | 27 +++++++++------------------ lib/include/iotcon-representation.h | 17 ++--------------- test/iotcon-test-iface-server.c | 8 ++++---- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/lib/icl-representation.c b/lib/icl-representation.c index eeba7ee..0325ea3 100644 --- a/lib/icl-representation.c +++ b/lib/icl-representation.c @@ -174,19 +174,22 @@ API int iotcon_representation_set_resource_interfaces(iotcon_representation_h re return IOTCON_ERROR_NONE; } - API int iotcon_representation_set_state(iotcon_representation_h repr, iotcon_state_h state) { RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == state, IOTCON_ERROR_INVALID_PARAMETER); + + if (state == repr->state) + return IOTCON_ERROR_NONE; if (repr->state) { - ERR("state already set. Remove first !"); - return IOTCON_ERROR_ALREADY; + iotcon_state_destroy(repr->state); + repr->state = NULL; } - icl_state_inc_ref_count(state); + if (state) + icl_state_inc_ref_count(state); + repr->state = state; return IOTCON_ERROR_NONE; @@ -204,19 +207,7 @@ API int iotcon_representation_get_state(iotcon_representation_h repr, return IOTCON_ERROR_NONE; } - -API int iotcon_representation_del_state(iotcon_representation_h repr) -{ - RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER); - - if (repr->state) - iotcon_state_destroy(repr->state); - - return IOTCON_ERROR_NONE; -} - - -API int iotcon_representation_append_child(iotcon_representation_h parent, +API int iotcon_representation_add_child(iotcon_representation_h parent, iotcon_representation_h child) { RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER); diff --git a/lib/include/iotcon-representation.h b/lib/include/iotcon-representation.h index db83bc7..e4c9a90 100644 --- a/lib/include/iotcon-representation.h +++ b/lib/include/iotcon-representation.h @@ -368,20 +368,7 @@ int iotcon_representation_set_state(iotcon_representation_h repr, iotcon_state_h int iotcon_representation_get_state(iotcon_representation_h repr, iotcon_state_h *state); /** - * @brief Deletes state handle in the representation. - * - * @since_tizen 3.0 - * - * @param[in] repr The representation handle - * - * @return 0 on success, otherwise a negative error value. - * @retval #IOTCON_ERROR_NONE Successful - * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter - */ -int iotcon_representation_del_state(iotcon_representation_h repr); - -/** - * @brief Appends a new child representation on to the end of the parent representation + * @brief Adds a new child representation on to the end of the parent representation * @details Duplicated child representation is allowed to append. * * @since_tizen 3.0 @@ -393,7 +380,7 @@ int iotcon_representation_del_state(iotcon_representation_h repr); * @retval #IOTCON_ERROR_NONE Successful * @retval #IOTCON_ERROR_INVALID_PARAMETER Invalid parameter */ -int iotcon_representation_append_child(iotcon_representation_h parent, +int iotcon_representation_add_child(iotcon_representation_h parent, iotcon_representation_h child); /** diff --git a/test/iotcon-test-iface-server.c b/test/iotcon-test-iface-server.c index 1ecec08..130a7b8 100644 --- a/test/iotcon-test-iface-server.c +++ b/test/iotcon-test-iface-server.c @@ -513,9 +513,9 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) return NULL; } - ret = iotcon_representation_append_child(repr, light_repr); + ret = iotcon_representation_add_child(repr, light_repr); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_append_child() Fail(%d)", ret); + ERR("iotcon_representation_add_child() Fail(%d)", ret); iotcon_representation_destroy(light_repr); iotcon_representation_destroy(repr); return NULL; @@ -530,9 +530,9 @@ static iotcon_representation_h _get_room_representation(room_resource_s *room) return NULL; } - ret = iotcon_representation_append_child(repr, fan_repr); + ret = iotcon_representation_add_child(repr, fan_repr); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_append_child() Fail(%d)", ret); + ERR("iotcon_representation_add_child() Fail(%d)", ret); iotcon_representation_destroy(fan_repr); iotcon_representation_destroy(repr); return NULL; -- 2.34.1