[CodeClean/Handle] internal struct for handle
authorJaeyun <jy1210.jung@samsung.com>
Mon, 5 Dec 2022 11:21:39 +0000 (20:21 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Wed, 7 Dec 2022 05:03:56 +0000 (14:03 +0900)
Code clean, move definition for internal data struct and cleanup headers.

Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
12 files changed:
src/libnnstreamer-edge/nnstreamer-edge-aitt.c
src/libnnstreamer-edge/nnstreamer-edge-data.c
src/libnnstreamer-edge/nnstreamer-edge-data.h
src/libnnstreamer-edge/nnstreamer-edge-event.c
src/libnnstreamer-edge/nnstreamer-edge-internal.c
src/libnnstreamer-edge/nnstreamer-edge-internal.h [deleted file]
src/libnnstreamer-edge/nnstreamer-edge-mqtt-mosquitto.c
src/libnnstreamer-edge/nnstreamer-edge-mqtt-paho.c
src/libnnstreamer-edge/nnstreamer-edge-queue.c
src/libnnstreamer-edge/nnstreamer-edge-util.h
tests/unittest_nnstreamer-edge-aitt.cc
tests/unittest_nnstreamer-edge.cc

index 36ac30f6ad3a38bb7fd21bed21a535a0b1ac2d6b..5f1f69baebc09fd233286950b53746d9763bc21b 100644 (file)
@@ -17,9 +17,9 @@
 #include <stdbool.h>
 #include <aitt_c.h>
 
+#include "nnstreamer-edge-aitt.h"
 #include "nnstreamer-edge-data.h"
 #include "nnstreamer-edge-event.h"
-#include "nnstreamer-edge-internal.h"
 #include "nnstreamer-edge-util.h"
 #include "nnstreamer-edge-log.h"
 
index 848f4c93bab71cf34fae7f95f99f7327d1a65521..874ab302c972f26372ba67b377b5535526cd5145 100644 (file)
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 
+/**
+ * @brief Internal data structure for the header of the serialzied edge data.
+ */
+typedef struct
+{
+  uint32_t num_mem;
+  nns_size_t data_len[NNS_EDGE_DATA_LIMIT];
+  nns_size_t meta_len;
+} nns_edge_data_header_s;
+
+/**
+ * @brief Internal data structure for edge data.
+ */
+typedef struct
+{
+  uint32_t magic;
+  pthread_mutex_t lock;
+  uint32_t num;
+  nns_edge_raw_data_s data[NNS_EDGE_DATA_LIMIT];
+  nns_edge_metadata_h metadata;
+} nns_edge_data_s;
+
 /**
  * @brief Create nnstreamer edge data.
  */
index d75ded7a343311dea5c86102fa6488a92b5ce2ed..fea984cba3225b8cd94cdc960e2de4268b23ad68 100644 (file)
 #define __NNSTREAMER_EDGE_DATA_H__
 
 #include "nnstreamer-edge.h"
-#include "nnstreamer-edge-internal.h"
 #include "nnstreamer-edge-metadata.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif /* __cplusplus */
 
-/**
- * @brief Internal data structure for edge data.
- */
-typedef struct {
-  uint32_t magic;
-  pthread_mutex_t lock;
-  uint32_t num;
-  nns_edge_raw_data_s data[NNS_EDGE_DATA_LIMIT];
-  nns_edge_metadata_h metadata;
-} nns_edge_data_s;
-
-/**
- * @brief Internal data structure for the header of the serialzied edge data.
- */
-typedef struct {
-  uint32_t num_mem;
-  nns_size_t data_len[NNS_EDGE_DATA_LIMIT];
-  nns_size_t meta_len;
-} nns_edge_data_header_s;
-
 /**
  * @brief Internal wrapper function of the nns_edge_data_destory() to avoid build warning of the incompatibe type casting. (See nns_edge_data_destroy_cb())
  */
index 8712772bc0c1dc04c9e0aa25fad495f0d08d9cfd..569ea4b1987cf71428a96adddaee47d876e2d36f 100644 (file)
 
 #include "nnstreamer-edge-data.h"
 #include "nnstreamer-edge-event.h"
-#include "nnstreamer-edge-internal.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 
+/**
+ * @brief Internal data structure for edge event.
+ */
+typedef struct
+{
+  uint32_t magic;
+  nns_edge_event_e event;
+  nns_edge_raw_data_s data;
+} nns_edge_event_s;
+
 /**
  * @brief Internal util function to invoke event callback.
  */
index 1a8b2dc45d13fe4640d3cba9ea379158fcd251e0..29e490dfad778e30d7a922336fdb8552a0b0e5d5 100644 (file)
@@ -18,7 +18,9 @@
 #include "nnstreamer-edge-event.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
-#include "nnstreamer-edge-internal.h"
+#include "nnstreamer-edge-queue.h"
+#include "nnstreamer-edge-aitt.h"
+#include "nnstreamer-edge-mqtt.h"
 
 #ifndef PTHREAD_CREATE_JOINABLE
 #define PTHREAD_CREATE_JOINABLE 0
 #define N_BACKLOG 10
 #define DEFAULT_TIMEOUT_SEC 10
 
+/**
+ * @brief Data structure for edge handle.
+ */
+typedef struct
+{
+  uint32_t magic;
+  pthread_mutex_t lock;
+  char *id;
+  char *topic;
+  nns_edge_connect_type_e connect_type;
+  char *host; /**< host name or IP address */
+  int port; /**< port number (0~65535, default 0 to get available port.) */
+  char *dest_host; /**< destination IP address (broker or target device) */
+  int dest_port; /**< destination port number (broker or target device) */
+  nns_edge_node_type_e node_type;
+  nns_edge_metadata_h metadata;
+
+  /* Edge event callback and user data */
+  nns_edge_event_cb event_cb;
+  void *user_data;
+
+  int64_t client_id;
+  char *caps_str;
+
+  /* list of connection data */
+  void *connections;
+
+  /* socket listener */
+  bool listening;
+  int listener_fd;
+  pthread_t listener_thread;
+
+  /* thread and queue to send data */
+  nns_edge_queue_h send_queue;
+  pthread_t send_thread;
+
+  /* MQTT or AITT handle */
+  void *broker_h;
+} nns_edge_handle_s;
+
 /**
  * @brief enum for nnstreamer edge query commands.
  */
diff --git a/src/libnnstreamer-edge/nnstreamer-edge-internal.h b/src/libnnstreamer-edge/nnstreamer-edge-internal.h
deleted file mode 100644 (file)
index a900b23..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/* SPDX-License-Identifier: Apache-2.0 */
-/**
- * Copyright (C) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
- *
- * @file   nnstreamer-edge-internal.h
- * @date   11 May 2022
- * @brief  Internal functions and definition to support communication among devices.
- * @see    https://github.com/nnstreamer/nnstreamer
- * @author Gichan Jang <gichan2.jang@samsung.com>
- * @bug    No known bugs except for NYI items
- * @note   This file is internal header for nnstreamer edge. DO NOT export this file.
- */
-
-#ifndef __NNSTREAMER_EDGE_INTERNAL_H__
-#define __NNSTREAMER_EDGE_INTERNAL_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#include "nnstreamer-edge.h"
-#include "nnstreamer-edge-metadata.h"
-#include "nnstreamer-edge-aitt.h"
-#include "nnstreamer-edge-mqtt.h"
-#include "nnstreamer-edge-queue.h"
-
-/**
- * @brief Internal data structure for raw data.
- */
-typedef struct {
-  void *data;
-  nns_size_t data_len;
-  nns_edge_data_destroy_cb destroy_cb;
-} nns_edge_raw_data_s;
-
-/**
- * @brief Internal data structure for edge event.
- */
-typedef struct {
-  uint32_t magic;
-  nns_edge_event_e event;
-  nns_edge_raw_data_s data;
-} nns_edge_event_s;
-
-/**
- * @brief Data structure for edge handle.
- */
-typedef struct {
-  uint32_t magic;
-  pthread_mutex_t lock;
-  char *id;
-  char *topic;
-  nns_edge_connect_type_e connect_type;
-  char *host; /**< host name or IP address */
-  int port; /**< port number (0~65535, default 0 to get available port.) */
-  char *dest_host; /**< destination IP address (broker or target device) */
-  int dest_port; /**< destination port number (broker or target device) */
-  nns_edge_node_type_e node_type;
-  nns_edge_metadata_h metadata;
-
-  /* Edge event callback and user data */
-  nns_edge_event_cb event_cb;
-  void *user_data;
-
-  int64_t client_id;
-  char *caps_str;
-
-  /* list of connection data */
-  void *connections;
-
-  /* socket listener */
-  bool listening;
-  int listener_fd;
-  pthread_t listener_thread;
-
-  /* thread and queue to send data */
-  nns_edge_queue_h send_queue;
-  pthread_t send_thread;
-
-  /* MQTT or AITT handle */
-  void *broker_h;
-} nns_edge_handle_s;
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* __NNSTREAMER_EDGE_INTERNAL_H__ */
index 14c838c302a296d399a641c9b1920db22575acfb..9fc3e0075985991bfc5a4a8dedf3062a468f9b4c 100644 (file)
@@ -15,7 +15,7 @@
 #endif
 
 #include <mosquitto.h>
-#include "nnstreamer-edge-internal.h"
+#include "nnstreamer-edge-mqtt.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 #include "nnstreamer-edge-queue.h"
index d5ea8f61af22b556e91d9f2b99f4573f3962f453..c8778929c6535952f073e0afb6fd653bbcc160fb 100644 (file)
@@ -15,7 +15,7 @@
 #endif
 
 #include <MQTTAsync.h>
-#include "nnstreamer-edge-internal.h"
+#include "nnstreamer-edge-mqtt.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 #include "nnstreamer-edge-queue.h"
index 0078e88aad5164ad527963fb63c99e4afc25d57b..ea806c123f849b1803e3dd4bd363c9a37b43c427 100644 (file)
@@ -10,7 +10,6 @@
  * @bug    No known bugs except for NYI items.
  */
 
-#include "nnstreamer-edge-internal.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-queue.h"
 #include "nnstreamer-edge-util.h"
index f6a5123d04c13c7a80afdd8e3a78553f8d7ba5d3..0238e7fa189b973425c2fa91762fe68d86edf193 100644 (file)
@@ -69,6 +69,15 @@ extern "C" {
 #define nns_edge_cond_timedwait(h,t) do { pthread_cond_timedwait (&(h)->cond, &(h)->lock, (t)); } while (0)
 #define nns_edge_cond_signal(h) do { pthread_cond_signal (&(h)->cond); } while (0)
 
+/**
+ * @brief Internal data structure for raw data.
+ */
+typedef struct {
+  void *data;
+  nns_size_t data_len;
+  nns_edge_data_destroy_cb destroy_cb;
+} nns_edge_raw_data_s;
+
 /**
  * @brief Generate client ID.
  */
index bbc0a177d8577b7cc7846510c3f1f5f11099325a..153a7008eba849e86544ed1c00f3f01de2a9aeda 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <gtest/gtest.h>
 #include "nnstreamer-edge.h"
-#include "nnstreamer-edge-internal.h"
+#include "nnstreamer-edge-aitt.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 
index 55e23e0aa6d0dbaf883a45a5bc73f0355e325e32..cb850412cdde4135dc05101242f57da245986fd9 100644 (file)
@@ -12,7 +12,7 @@
 #include "nnstreamer-edge-data.h"
 #include "nnstreamer-edge-event.h"
 #include "nnstreamer-edge-metadata.h"
-#include "nnstreamer-edge-internal.h"
+#include "nnstreamer-edge-mqtt.h"
 #include "nnstreamer-edge-log.h"
 #include "nnstreamer-edge-util.h"
 #include "nnstreamer-edge-queue.h"