src.ctf.lttng-live: add lttng_live_session destructor
[babeltrace.git] / src / plugins / ctf / lttng-live / lttng-live.hpp
index 2ed6448102d01f172470f15c90b86d509f3c3722..3bbcd0ef4ff11748d0e791856c79f1676bb8c2c0 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <babeltrace2/babeltrace.h>
 
+#include "cpp-common/bt2/message.hpp"
 #include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */
 
 #include "../common/src/metadata/tsdl/decoder.hpp"
@@ -67,11 +68,15 @@ inline const char *format_as(const lttng_live_stream_state state) noexcept
 /* Iterator over a live stream. */
 struct lttng_live_stream_iterator
 {
+    using UP = std::unique_ptr<lttng_live_stream_iterator>;
+
     explicit lttng_live_stream_iterator(const bt2c::Logger& parentLogger) :
         logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/STREAM-ITER"}
     {
     }
 
+    ~lttng_live_stream_iterator();
+
     bt2c::Logger logger;
 
     bt2::Stream::Shared stream;
@@ -83,7 +88,7 @@ struct lttng_live_stream_iterator
      * Since only a single iterator per viewer connection, we have
      * only a single message iterator per stream.
      */
-    struct ctf_msg_iter *msg_iter = nullptr;
+    ctf_msg_iter_up msg_iter;
 
     uint64_t viewer_stream_id = 0;
 
@@ -118,21 +123,15 @@ struct lttng_live_stream_iterator
 
     enum lttng_live_stream_state state = LTTNG_LIVE_STREAM_QUIESCENT;
 
-    /*
-     * The current message produced by this live stream iterator. Owned by
-     * this.
-     */
-    const bt_message *current_msg = nullptr;
+    /* The current message produced by this live stream iterator. */
+    bt2::ConstMessage::Shared current_msg;
 
     /* Timestamp in nanoseconds of the current message (current_msg). */
     int64_t current_msg_ts_ns = 0;
 
-    /* Owned by this. */
-    uint8_t *buf = nullptr;
-    size_t buflen = 0;
+    std::vector<uint8_t> buf;
 
-    /* Owned by this. */
-    GString *name = nullptr;
+    std::string name;
 
     bool has_stream_hung_up = false;
 };
@@ -178,6 +177,8 @@ enum lttng_live_metadata_stream_state
 
 struct lttng_live_trace
 {
+    using UP = std::unique_ptr<lttng_live_trace>;
+
     explicit lttng_live_trace(const bt2c::Logger& parentLogger) :
         logger {parentLogger, "PLUGIN/SRC.CTF.LTTNG-LIVE/TRACE"}
     {
@@ -199,9 +200,7 @@ struct lttng_live_trace
 
     const bt_clock_class *clock_class = nullptr;
 
-    /* Array of pointers to struct lttng_live_stream_iterator. */
-    /* Owned by this. */
-    GPtrArray *stream_iterators = nullptr;
+    std::vector<lttng_live_stream_iterator::UP> stream_iterators;
 
     enum lttng_live_metadata_stream_state metadata_stream_state =
         LTTNG_LIVE_METADATA_STREAM_STATE_NEEDED;
@@ -214,6 +213,8 @@ struct lttng_live_session
     {
     }
 
+    ~lttng_live_session();
+
     bt2c::Logger logger;
 
     bt_self_component *self_comp = nullptr;
@@ -221,16 +222,13 @@ struct lttng_live_session
     /* Weak reference. */
     struct lttng_live_msg_iter *lttng_live_msg_iter = nullptr;
 
-    /* Owned by this. */
-    GString *hostname = nullptr;
+    std::string hostname;
 
-    /* Owned by this. */
-    GString *session_name = nullptr;
+    std::string session_name;
 
     uint64_t id = 0;
 
-    /* Array of pointers to struct lttng_live_trace. */
-    GPtrArray *traces = nullptr;
+    std::vector<lttng_live_trace::UP> traces;
 
     bool attached = false;
     bool new_streams_needed = false;
This page took 0.025122 seconds and 4 git commands to generate.