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;
50 virtual ~trace_class() = default;
53 * Derived classes must implement the _accept_on_*()
54 * to continue the traversal to the trace class' children.
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;
61 const lttng_uuid uuid;
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;
69 class trace_class_environment_visitor {
71 virtual ~trace_class_environment_visitor() = default;
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);
78 class trace_class_visitor {
80 using cuptr = std::unique_ptr<trace_class_visitor>;
82 virtual ~trace_class_visitor() = default;
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;
90 } /* namespace trace */
91 } /* namespace sessiond */
92 } /* namespace lttng */
94 #endif /* LTTNG_TRACE_CLASS_H */