Clean-up: consumer.hpp: coding style indentation fix
[lttng-tools.git] / include / lttng / action / list-internal.hpp
1 /*
2 * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_ACTION_LIST_INTERNAL_H
9 #define LTTNG_ACTION_LIST_INTERNAL_H
10
11 #include <common/container-wrapper.hpp>
12 #include <common/exception.hpp>
13 #include <common/format.hpp>
14 #include <common/macros.hpp>
15
16 #include <lttng/lttng.h>
17
18 #include <assert.h>
19 #include <sys/types.h>
20
21 struct lttng_action;
22 struct lttng_payload_view;
23 struct mi_writer;
24 struct mi_lttng_error_query_callbacks;
25 struct lttng_dynamic_array;
26 struct lttng_trigger;
27
28 /*
29 * Create an action list from a payload view.
30 *
31 * On success, return the number of bytes consumed from `view`, and the created
32 * list in `*list`. On failure, return -1.
33 */
34 extern ssize_t lttng_action_list_create_from_payload(struct lttng_payload_view *view,
35 struct lttng_action **list);
36
37 extern struct lttng_action *
38 lttng_action_list_borrow_mutable_at_index(const struct lttng_action *list, unsigned int index);
39
40 enum lttng_error_code
41 lttng_action_list_mi_serialize(const struct lttng_trigger *trigger,
42 const struct lttng_action *action,
43 struct mi_writer *writer,
44 const struct mi_lttng_error_query_callbacks *error_query_callbacks,
45 struct lttng_dynamic_array *action_path_indexes);
46
47 namespace lttng {
48 namespace ctl {
49 namespace details {
50 class action_list_operations {
51 public:
52 static lttng_action *get(const lttng_action *list, std::size_t index) noexcept
53 {
54 return lttng_action_list_borrow_mutable_at_index(list, index);
55 }
56
57 static std::size_t size(const lttng_action *list)
58 {
59 unsigned int count;
60 const auto status = lttng_action_list_get_count(list, &count);
61
62 if (status != LTTNG_ACTION_STATUS_OK) {
63 LTTNG_THROW_INVALID_ARGUMENT_ERROR(
64 "Failed to get action list element count");
65 }
66
67 return count;
68 }
69 };
70
71 class const_action_list_operations {
72 public:
73 static const lttng_action *get(const lttng_action *list, std::size_t index) noexcept
74 {
75 return lttng_action_list_get_at_index(list, index);
76 }
77
78 static std::size_t size(const lttng_action *list)
79 {
80 return action_list_operations::size(list);
81 }
82 };
83 } /* namespace details */
84
85 using action_list_view = utils::random_access_container_wrapper<const lttng_action *,
86 lttng_action *,
87 details::action_list_operations>;
88
89 using const_action_list_view =
90 utils::random_access_container_wrapper<const lttng_action *,
91 const lttng_action *,
92 details::const_action_list_operations>;
93
94 } /* namespace ctl */
95 } /* namespace lttng */
96
97 #endif /* LTTNG_ACTION_LIST_INTERNAL_H */
This page took 0.030523 seconds and 4 git commands to generate.