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;
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);
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
* @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);
/**
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;
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;