Fix: file-descriptor: missing include guards
[lttng-tools.git] / src / bin / lttng-sessiond / trace-class.hpp
CommitLineData
0220be14
JG
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
24ed18f2
JG
11#include "field.hpp"
12
0220be14
JG
13#include <common/uuid.hpp>
14
15namespace lttng {
16namespace sessiond {
17namespace trace {
18
19class clock_class;
20class stream_class;
21class event_class;
22class trace_class_visitor;
da9dd521 23class trace_class_environment_visitor;
0220be14 24
0220be14
JG
25struct 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
35template <class ValueType>
36class environment_field {
37public:
38 environment_field(const char *in_name, const ValueType& in_value) :
39 name(in_name), value(in_value)
40 {
41 }
42
da9dd521 43 const char* const name;
0220be14
JG
44 const ValueType& value;
45};
46
47class trace_class {
48public:
da9dd521 49 virtual ~trace_class() = default;
9d89db29
JG
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;
da9dd521 54
0220be14
JG
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;
da9dd521 60 virtual void accept(trace_class_environment_visitor& environment_visitor) const = 0;
4bcf2294 61 virtual const lttng::sessiond::trace::type *packet_header() const noexcept = 0;
0220be14 62
0220be14
JG
63 const struct abi abi;
64 const lttng_uuid uuid;
65
66protected:
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;
0220be14
JG
69 virtual void _accept_on_stream_classes(trace_class_visitor& trace_class_visitor) const = 0;
70};
71
da9dd521
JG
72class trace_class_environment_visitor {
73public:
9d89db29 74 trace_class_environment_visitor() = default;
da9dd521 75 virtual ~trace_class_environment_visitor() = default;
9d89db29
JG
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;
da9dd521
JG
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
0220be14
JG
86class trace_class_visitor {
87public:
88 using cuptr = std::unique_ptr<trace_class_visitor>;
89
9d89db29 90 trace_class_visitor() = default;
0220be14 91 virtual ~trace_class_visitor() = default;
9d89db29
JG
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;
0220be14 96
0220be14 97 virtual void visit(const lttng::sessiond::trace::trace_class& trace_class) = 0;
0220be14 98 virtual void visit(const lttng::sessiond::trace::clock_class& clock_class) = 0;
0220be14 99 virtual void visit(const lttng::sessiond::trace::stream_class& stream_class) = 0;
0220be14
JG
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.032545 seconds and 4 git commands to generate.