72ba7559dde480a8b7e15a3e66f38746a75e1708
[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
50 virtual ~trace_class() = default;
51
52 /*
53 * Derived classes must implement the _accept_on_*()
54 * to continue the traversal to the trace class' children.
55 */
56 virtual void accept(trace_class_visitor& trace_class_visitor) const;
57 virtual void accept(trace_class_environment_visitor& environment_visitor) const = 0;
58 virtual const lttng::sessiond::trace::type *packet_header() const noexcept = 0;
59
60 const struct abi abi;
61 const lttng_uuid uuid;
62
63 protected:
64 trace_class(const struct abi& abi, const lttng_uuid& trace_uuid);
65 virtual void _accept_on_clock_classes(trace_class_visitor& trace_class_visitor) const = 0;
66 virtual void _accept_on_stream_classes(trace_class_visitor& trace_class_visitor) const = 0;
67 };
68
69 class trace_class_environment_visitor {
70 public:
71 virtual ~trace_class_environment_visitor() = default;
72
73 virtual void visit(const environment_field<int64_t>& field) = 0;
74 virtual void visit(const environment_field<const char *>& field) = 0;
75 virtual void visit(const environment_field<std::string>& field);
76 };
77
78 class trace_class_visitor {
79 public:
80 using cuptr = std::unique_ptr<trace_class_visitor>;
81
82 virtual ~trace_class_visitor() = default;
83
84 virtual void visit(const lttng::sessiond::trace::trace_class& trace_class) = 0;
85 virtual void visit(const lttng::sessiond::trace::clock_class& clock_class) = 0;
86 virtual void visit(const lttng::sessiond::trace::stream_class& stream_class) = 0;
87 virtual void visit(const lttng::sessiond::trace::event_class& event_class) = 0;
88 };
89
90 } /* namespace trace */
91 } /* namespace sessiond */
92 } /* namespace lttng */
93
94 #endif /* LTTNG_TRACE_CLASS_H */
This page took 0.030955 seconds and 4 git commands to generate.