clang-tidy: add a subset of cppcoreguidelines and other style checks
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry-channel.hpp
1 /*
2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef LTTNG_UST_REGISTRY_CHANNEL_H
9 #define LTTNG_UST_REGISTRY_CHANNEL_H
10
11 #include "stream-class.hpp"
12 #include "trace-class.hpp"
13
14 #include <common/hashtable/hashtable.hpp>
15
16 #include <lttng/lttng.h>
17
18 #include <urcu.h>
19 #include <functional>
20
21 struct ust_app;
22
23 namespace lttng {
24 namespace sessiond {
25 namespace ust {
26
27 class registry_event;
28
29 class registry_channel : public lttng::sessiond::trace::stream_class {
30 public:
31 using registered_listener_fn = std::function<void(const registry_channel&)>;
32 using event_added_listener_fn = std::function<void(const registry_channel&, const registry_event &)>;
33
34 registry_channel(uint32_t channel_id,
35 const lttng::sessiond::trace::abi& trace_abi,
36 std::string default_clock_class_name,
37 registered_listener_fn channel_registered_listener,
38 event_added_listener_fn new_event_listener);
39 void add_event(int session_objd,
40 int channel_objd,
41 std::string name,
42 std::string signature,
43 std::vector<lttng::sessiond::trace::field::cuptr> event_fields,
44 int loglevel_value,
45 nonstd::optional<std::string> model_emf_uri,
46 lttng_buffer_type buffer_type,
47 const ust_app& app,
48 uint32_t& out_event_id);
49 ~registry_channel() override;
50 registry_channel(const registry_channel&) = delete;
51 registry_channel(registry_channel&&) = delete;
52 registry_channel& operator=(registry_channel&&) = delete;
53 registry_channel& operator=(const registry_channel&) = delete;
54
55 const lttng::sessiond::trace::type *event_context() const final;
56 void event_context(lttng::sessiond::trace::type::cuptr context);
57
58 /* Channel was registered to at least one application. */
59 bool is_registered() const;
60 void set_as_registered();
61
62 uint64_t _key;
63 uint64_t _consumer_key;
64
65 /*
66 * Hash table containing events sent by the UST tracer. MUST be accessed
67 * with a RCU read side lock acquired.
68 */
69 struct lttng_ht *_events;
70 struct lttng_ht_node_u64 _node;
71 /* For delayed reclaim */
72 struct rcu_head _rcu_head;
73 /* Once this value reaches UINT32_MAX, no more id can be allocated. */
74 uint32_t _next_event_id;
75
76 private:
77 void _accept_on_event_classes(
78 lttng::sessiond::trace::trace_class_visitor& trace_class_visitor) const final;
79
80 registered_listener_fn _is_registered_listener;
81 event_added_listener_fn _event_added_listener;
82 /* Indicates if this channel registry has already been registered. */
83 bool _is_registered;
84 };
85
86 } /* namespace ust */
87 } /* namespace sessiond */
88 } /* namespace lttng */
89
90 #endif /* LTTNG_UST_REGISTRY_CHANNEL_H */
This page took 0.03022 seconds and 4 git commands to generate.