src.ctf.lttng-live: introduce live_viewer_connection::UP and use it
[babeltrace.git] / src / plugins / ctf / lttng-live / viewer-connection.hpp
index 4e17d506ca538173d685a7d444fae157d0c1f438..9f564a39858eac9ab28146c2d80d7ed346cb38ad 100644 (file)
@@ -7,12 +7,16 @@
 #ifndef LTTNG_LIVE_VIEWER_CONNECTION_H
 #define LTTNG_LIVE_VIEWER_CONNECTION_H
 
+#include <string>
+
 #include <glib.h>
 #include <stdint.h>
 
 #include <babeltrace2/babeltrace.h>
 
-#include "compat/socket.h"
+#include "compat/socket.hpp"
+#include "cpp-common/bt2c/glib-up.hpp"
+#include "cpp-common/bt2c/logging.hpp"
 
 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT 5344
 
@@ -46,16 +50,23 @@ enum lttng_live_get_one_metadata_status
 
 struct live_viewer_connection
 {
-    bt_logging_level log_level = (bt_logging_level) 0;
-    bt_self_component *self_comp = nullptr;
-    bt_self_component_class *self_comp_class = nullptr;
+    using UP = std::unique_ptr<live_viewer_connection>;
+
+    explicit live_viewer_connection(const bt2c::Logger& parentLogger) :
+        logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER"}
+    {
+    }
+
+    ~live_viewer_connection();
 
-    GString *url = nullptr;
+    bt2c::Logger logger;
 
-    GString *relay_hostname = nullptr;
-    GString *target_hostname = nullptr;
-    GString *session_name = nullptr;
-    GString *proto = nullptr;
+    std::string url;
+
+    bt2c::GStringUP relay_hostname;
+    bt2c::GStringUP target_hostname;
+    bt2c::GStringUP session_name;
+    bt2c::GStringUP proto;
 
     BT_SOCKET control_sock {};
     int port = 0;
@@ -89,13 +100,9 @@ struct packet_index
 };
 
 enum lttng_live_viewer_status
-live_viewer_connection_create(bt_self_component *self_comp,
-                              bt_self_component_class *self_comp_class, bt_logging_level log_level,
-                              const char *url, bool in_query,
+live_viewer_connection_create(const char *url, bool in_query,
                               struct lttng_live_msg_iter *lttng_live_msg_iter,
-                              struct live_viewer_connection **viewer_connection);
-
-void live_viewer_connection_destroy(struct live_viewer_connection *conn);
+                              const bt2c::Logger& parentLogger, live_viewer_connection::UP& viewer);
 
 enum lttng_live_viewer_status
 lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
This page took 0.031826 seconds and 4 git commands to generate.