2 * Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_ACTION_LIST_INTERNAL_H
9 #define LTTNG_ACTION_LIST_INTERNAL_H
11 #include <common/container-wrapper.hpp>
12 #include <common/exception.hpp>
13 #include <common/format.hpp>
14 #include <common/macros.hpp>
16 #include <lttng/lttng.h>
19 #include <sys/types.h>
22 struct lttng_payload_view;
24 struct mi_lttng_error_query_callbacks;
25 struct lttng_dynamic_array;
29 * Create an action list from a payload view.
31 * On success, return the number of bytes consumed from `view`, and the created
32 * list in `*list`. On failure, return -1.
34 extern ssize_t lttng_action_list_create_from_payload(struct lttng_payload_view *view,
35 struct lttng_action **list);
37 extern struct lttng_action *
38 lttng_action_list_borrow_mutable_at_index(const struct lttng_action *list, unsigned int index);
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);
50 class action_list_operations {
52 static lttng_action *get(const lttng_action *list, std::size_t index) noexcept
54 return lttng_action_list_borrow_mutable_at_index(list, index);
57 static std::size_t size(const lttng_action *list)
60 const auto status = lttng_action_list_get_count(list, &count);
62 if (status != LTTNG_ACTION_STATUS_OK) {
63 LTTNG_THROW_INVALID_ARGUMENT_ERROR(
64 "Failed to get action list element count");
71 class const_action_list_operations {
73 static const lttng_action *get(const lttng_action *list, std::size_t index) noexcept
75 return lttng_action_list_get_at_index(list, index);
78 static std::size_t size(const lttng_action *list)
80 return action_list_operations::size(list);
83 } /* namespace details */
85 using action_list_view = utils::random_access_container_wrapper<const lttng_action *,
87 details::action_list_operations>;
89 using const_action_list_view =
90 utils::random_access_container_wrapper<const lttng_action *,
92 details::const_action_list_operations>;
95 } /* namespace lttng */
97 #endif /* LTTNG_ACTION_LIST_INTERNAL_H */