From fb9f73d237102763090c2ad819ca99427b71d057 Mon Sep 17 00:00:00 2001 From: gichan Date: Wed, 24 Aug 2022 16:38:12 +0900 Subject: [PATCH] [Edge] Remove unnecessary functions. Remove unnecessary functions (sub, unsub). @todo: nns_edge_publish will be renamed. Signed-off-by: gichan --- include/nnstreamer-edge.h | 10 --- .../nnstreamer-edge-internal.c | 84 ------------------- tests/unittest_nnstreamer-edge.cc | 72 ---------------- 3 files changed, 166 deletions(-) diff --git a/include/nnstreamer-edge.h b/include/nnstreamer-edge.h index eada0e6..da47188 100644 --- a/include/nnstreamer-edge.h +++ b/include/nnstreamer-edge.h @@ -129,16 +129,6 @@ int nns_edge_disconnect (nns_edge_h edge_h); */ int nns_edge_publish (nns_edge_h edge_h, nns_edge_data_h data_h); -/** - * @brief Subscribe a message from broker. - */ -int nns_edge_subscribe (nns_edge_h edge_h); - -/** - * @brief Unsubscribe a message. - */ -int nns_edge_unsubscribe (nns_edge_h edge_h); - /** * @brief Set nnstreamer edge info. * @note The param key is case-insensitive. If same key string already exists, it will replace the old value. diff --git a/src/libnnstreamer-edge/nnstreamer-edge-internal.c b/src/libnnstreamer-edge/nnstreamer-edge-internal.c index d55639c..bcd34cd 100644 --- a/src/libnnstreamer-edge/nnstreamer-edge-internal.c +++ b/src/libnnstreamer-edge/nnstreamer-edge-internal.c @@ -1423,90 +1423,6 @@ nns_edge_publish (nns_edge_h edge_h, nns_edge_data_h data_h) return ret; } -/** - * @brief Subscribe a message from broker. - */ -int -nns_edge_subscribe (nns_edge_h edge_h) -{ - nns_edge_handle_s *eh; - int ret = NNS_EDGE_ERROR_NONE; - - eh = (nns_edge_handle_s *) edge_h; - if (!eh) { - nns_edge_loge ("Invalid param, given edge handle is null."); - return NNS_EDGE_ERROR_INVALID_PARAMETER; - } - - nns_edge_lock (eh); - - if (!NNS_EDGE_MAGIC_IS_VALID (eh)) { - nns_edge_loge ("Invalid param, given edge handle is invalid."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - if (eh->connect_type != NNS_EDGE_CONNECT_TYPE_MQTT) { - nns_edge_loge ("Invalid connect type, cannot subscribe a message."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - if (!STR_IS_VALID (eh->topic)) { - nns_edge_loge ("Invalid topic, cannot subscribe a message."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - /** @todo update code (subscribe) */ - -done: - nns_edge_unlock (eh); - return ret; -} - -/** - * @brief Unsubscribe a message. - */ -int -nns_edge_unsubscribe (nns_edge_h edge_h) -{ - nns_edge_handle_s *eh; - int ret = NNS_EDGE_ERROR_NONE; - - eh = (nns_edge_handle_s *) edge_h; - if (!eh) { - nns_edge_loge ("Invalid param, given edge handle is null."); - return NNS_EDGE_ERROR_INVALID_PARAMETER; - } - - nns_edge_lock (eh); - - if (!NNS_EDGE_MAGIC_IS_VALID (eh)) { - nns_edge_loge ("Invalid param, given edge handle is invalid."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - if (eh->connect_type != NNS_EDGE_CONNECT_TYPE_MQTT) { - nns_edge_loge ("Invalid connect type, cannot subscribe a message."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - if (!STR_IS_VALID (eh->topic)) { - nns_edge_loge ("Invalid topic, cannot subscribe a message."); - ret = NNS_EDGE_ERROR_INVALID_PARAMETER; - goto done; - } - - /** @todo update code (unsubscribe) */ - -done: - nns_edge_unlock (eh); - return ret; -} - /** * @brief Set nnstreamer edge info. */ diff --git a/tests/unittest_nnstreamer-edge.cc b/tests/unittest_nnstreamer-edge.cc index 04ba730..e49373f 100644 --- a/tests/unittest_nnstreamer-edge.cc +++ b/tests/unittest_nnstreamer-edge.cc @@ -758,78 +758,6 @@ TEST(edge, publishInvalidParam04_n) EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE); } -/** - * @brief Subscribe - invalid param. - */ -TEST(edge, subscribeInvalidParam01_n) -{ - int ret; - - ret = nns_edge_subscribe (NULL); - EXPECT_NE (ret, NNS_EDGE_ERROR_NONE); -} - -/** - * @brief Subscribe - invalid param. - */ -TEST(edge, subscribeInvalidParam02_n) -{ - nns_edge_h edge_h; - nns_edge_handle_s *eh; - int ret; - - ret = nns_edge_create_handle ("temp-id", NNS_EDGE_CONNECT_TYPE_TCP, - (NNS_EDGE_FLAG_RECV | NNS_EDGE_FLAG_SEND), &edge_h); - EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE); - - eh = (nns_edge_handle_s *) edge_h; - eh->magic = NNS_EDGE_MAGIC_DEAD; - - ret = nns_edge_subscribe (edge_h); - EXPECT_NE (ret, NNS_EDGE_ERROR_NONE); - - eh->magic = NNS_EDGE_MAGIC; - - ret = nns_edge_release_handle (edge_h); - EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE); -} - -/** - * @brief Unsubscribe - invalid param. - */ -TEST(edge, unsubscribeInvalidParam01_n) -{ - int ret; - - ret = nns_edge_unsubscribe (NULL); - EXPECT_NE (ret, NNS_EDGE_ERROR_NONE); -} - -/** - * @brief Unsubscribe - invalid param. - */ -TEST(edge, unsubscribeInvalidParam02_n) -{ - nns_edge_h edge_h; - nns_edge_handle_s *eh; - int ret; - - ret = nns_edge_create_handle ("temp-id", NNS_EDGE_CONNECT_TYPE_TCP, - (NNS_EDGE_FLAG_RECV | NNS_EDGE_FLAG_SEND), &edge_h); - EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE); - - eh = (nns_edge_handle_s *) edge_h; - eh->magic = NNS_EDGE_MAGIC_DEAD; - - ret = nns_edge_unsubscribe (edge_h); - EXPECT_NE (ret, NNS_EDGE_ERROR_NONE); - - eh->magic = NNS_EDGE_MAGIC; - - ret = nns_edge_release_handle (edge_h); - EXPECT_EQ (ret, NNS_EDGE_ERROR_NONE); -} - /** * @brief Set info - invalid param. */ -- 2.34.1