2 * Copyright (C) 2022 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef LTTNG_TRACE_CLASS_H
9 #define LTTNG_TRACE_CLASS_H
13 #include <common/uuid.hpp>
22 class trace_class_visitor;
23 class trace_class_environment_visitor;
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;
35 template <class ValueType>
36 class environment_field {
38 environment_field(const char *in_name, const ValueType& in_value) :
39 name(in_name), value(in_value)
43 const char* const name;
44 const ValueType& value;
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;
56 * Derived classes must implement the _accept_on_*()
57 * to continue the traversal to the trace class' children.
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;
64 const lttng_uuid uuid;
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;
72 class trace_class_environment_visitor {
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;
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);
86 class trace_class_visitor {
88 using cuptr = std::unique_ptr<trace_class_visitor>;
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;
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;
103 } /* namespace trace */
104 } /* namespace sessiond */
105 } /* namespace lttng */
107 #endif /* LTTNG_TRACE_CLASS_H */