Fix: file-descriptor: missing include guards
[lttng-tools.git] / src / bin / lttng-sessiond / trace-class.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_TRACE_CLASS_H
9 #define LTTNG_TRACE_CLASS_H
10
11 #include "field.hpp"
12
13 #include <common/uuid.hpp>
14
15 namespace lttng {
16 namespace sessiond {
17 namespace trace {
18
19 class clock_class;
20 class stream_class;
21 class event_class;
22 class trace_class_visitor;
23 class trace_class_environment_visitor;
24
25 struct abi {
26 unsigned int bits_per_long;
27 unsigned int long_alignment;
28 unsigned int uint8_t_alignment;
29 unsigned int uint16_t_alignment;
30 unsigned int uint32_t_alignment;
31 unsigned int uint64_t_alignment;
32 enum byte_order byte_order;
33 };
34
35 template <class ValueType>
36 class environment_field {
37 public:
38 environment_field(const char *in_name, const ValueType& in_value) :
39 name(in_name), value(in_value)
40 {
41 }
42
43 const char* const name;
44 const ValueType& value;
45 };
46
47 class trace_class {
48 public:
49 virtual ~trace_class() = default;
50 trace_class(const trace_class&) = delete;
51 trace_class(trace_class&&) = delete;
52 trace_class& operator=(trace_class&&) = delete;
53 trace_class& operator=(const trace_class&) = delete;
54
55 /*
56 * Derived classes must implement the _accept_on_*()
57 * to continue the traversal to the trace class' children.
58 */
59 virtual void accept(trace_class_visitor& trace_class_visitor) const;
60 virtual void accept(trace_class_environment_visitor& environment_visitor) const = 0;
61 virtual const lttng::sessiond::trace::type *packet_header() const noexcept = 0;
62
63 const struct abi abi;
64 const lttng_uuid uuid;
65
66 protected:
67 trace_class(const struct abi& abi, const lttng_uuid& trace_uuid);
68 virtual void _accept_on_clock_classes(trace_class_visitor& trace_class_visitor) const = 0;
69 virtual void _accept_on_stream_classes(trace_class_visitor& trace_class_visitor) const = 0;
70 };
71
72 class trace_class_environment_visitor {
73 public:
74 trace_class_environment_visitor() = default;
75 virtual ~trace_class_environment_visitor() = default;
76 trace_class_environment_visitor(const trace_class_environment_visitor&) = delete;
77 trace_class_environment_visitor(trace_class_environment_visitor&&) = delete;
78 trace_class_environment_visitor& operator=(trace_class_environment_visitor&&) = delete;
79 trace_class_environment_visitor& operator=(const trace_class_environment_visitor&) = delete;
80
81 virtual void visit(const environment_field<int64_t>& field) = 0;
82 virtual void visit(const environment_field<const char *>& field) = 0;
83 virtual void visit(const environment_field<std::string>& field);
84 };
85
86 class trace_class_visitor {
87 public:
88 using cuptr = std::unique_ptr<trace_class_visitor>;
89
90 trace_class_visitor() = default;
91 virtual ~trace_class_visitor() = default;
92 trace_class_visitor(const trace_class_visitor&) = delete;
93 trace_class_visitor(trace_class_visitor&&) = delete;
94 trace_class_visitor& operator=(trace_class_visitor&&) = delete;
95 trace_class_visitor& operator=(const trace_class_visitor&) = delete;
96
97 virtual void visit(const lttng::sessiond::trace::trace_class& trace_class) = 0;
98 virtual void visit(const lttng::sessiond::trace::clock_class& clock_class) = 0;
99 virtual void visit(const lttng::sessiond::trace::stream_class& stream_class) = 0;
100 virtual void visit(const lttng::sessiond::trace::event_class& event_class) = 0;
101 };
102
103 } /* namespace trace */
104 } /* namespace sessiond */
105 } /* namespace lttng */
106
107 #endif /* LTTNG_TRACE_CLASS_H */
This page took 0.032471 seconds and 4 git commands to generate.