Commit | Line | Data |
---|---|---|
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 | ||
11 | #include <common/uuid.hpp> | |
12 | ||
13 | namespace lttng { | |
14 | namespace sessiond { | |
15 | namespace trace { | |
16 | ||
17 | class clock_class; | |
18 | class stream_class; | |
19 | class event_class; | |
20 | class trace_class_visitor; | |
21 | ||
22 | enum class byte_order { | |
23 | BIG_ENDIAN_, | |
24 | LITTLE_ENDIAN_, | |
25 | }; | |
26 | ||
27 | struct abi { | |
28 | unsigned int bits_per_long; | |
29 | unsigned int long_alignment; | |
30 | unsigned int uint8_t_alignment; | |
31 | unsigned int uint16_t_alignment; | |
32 | unsigned int uint32_t_alignment; | |
33 | unsigned int uint64_t_alignment; | |
34 | enum byte_order byte_order; | |
35 | }; | |
36 | ||
37 | template <class ValueType> | |
38 | class environment_field { | |
39 | public: | |
40 | environment_field(const char *in_name, const ValueType& in_value) : | |
41 | name(in_name), value(in_value) | |
42 | { | |
43 | } | |
44 | ||
45 | const char * const name; | |
46 | const ValueType& value; | |
47 | }; | |
48 | ||
49 | class trace_class { | |
50 | public: | |
51 | /* | |
52 | * Derived classes must implement the _accept_on_*() | |
53 | * to continue the traversal to the trace class' children. | |
54 | */ | |
55 | virtual void accept(trace_class_visitor& trace_class_visitor) const; | |
56 | ||
57 | virtual ~trace_class() = default; | |
58 | ||
59 | const struct abi abi; | |
60 | const lttng_uuid uuid; | |
61 | ||
62 | protected: | |
63 | trace_class(const struct abi& abi, const lttng_uuid& trace_uuid); | |
64 | virtual void _accept_on_clock_classes(trace_class_visitor& trace_class_visitor) const = 0; | |
65 | virtual void _visit_environment(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_visitor { | |
70 | public: | |
71 | using cuptr = std::unique_ptr<trace_class_visitor>; | |
72 | ||
73 | virtual ~trace_class_visitor() = default; | |
74 | ||
75 | /* trace class visitor interface. */ | |
76 | virtual void visit(const lttng::sessiond::trace::trace_class& trace_class) = 0; | |
77 | ||
78 | /* clock class visitor interface. */ | |
79 | virtual void visit(const lttng::sessiond::trace::clock_class& clock_class) = 0; | |
80 | ||
81 | /* environment visitor interface. */ | |
82 | virtual void environment_begin() = 0; | |
83 | virtual void visit(const environment_field<int64_t>& field) = 0; | |
84 | virtual void visit(const environment_field<const char *>& field) = 0; | |
85 | void visit(const environment_field<std::string>& field); | |
86 | virtual void environment_end() = 0; | |
87 | ||
88 | /* stream class visitor interface. */ | |
89 | virtual void visit(const lttng::sessiond::trace::stream_class& stream_class) = 0; | |
90 | ||
91 | /* event class visitor interface. */ | |
92 | virtual void visit(const lttng::sessiond::trace::event_class& event_class) = 0; | |
93 | }; | |
94 | ||
95 | } /* namespace trace */ | |
96 | } /* namespace sessiond */ | |
97 | } /* namespace lttng */ | |
98 | ||
99 | #endif /* LTTNG_TRACE_CLASS_H */ |