Add a basic .clang-tidy file and fix typedef warnings
[lttng-tools.git] / include / lttng / action / action-internal.hpp
CommitLineData
a58c490f 1/*
ab5be9fa 2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
a58c490f 3 *
ab5be9fa 4 * SPDX-License-Identifier: LGPL-2.1-only
a58c490f 5 *
a58c490f
JG
6 */
7
8#ifndef LTTNG_ACTION_INTERNAL_H
9#define LTTNG_ACTION_INTERNAL_H
10
c9e313bc
SM
11#include <common/buffer-view.hpp>
12#include <common/dynamic-buffer.hpp>
13#include <common/macros.hpp>
14#include <common/payload-view.hpp>
15#include <common/payload.hpp>
588c4b0d
JG
16#include <lttng/lttng.h>
17#include <pthread.h>
a58c490f 18#include <stdbool.h>
72756a3f 19#include <sys/types.h>
c852ce4e 20#include <urcu/ref.h>
a58c490f 21
7f4d5b07 22struct lttng_rate_policy;
6a751b95
JR
23struct mi_writer;
24struct mi_lttng_error_query_callbacks;
25struct lttng_trigger;
2d57482c 26
e665dfbc
JG
27using action_validate_cb = bool (*)(struct lttng_action *);
28using action_destroy_cb = void (*)(struct lttng_action *);
29using action_serialize_cb = int (*)(struct lttng_action *, struct lttng_payload *);
30using action_equal_cb = bool (*)(const struct lttng_action *, const struct lttng_action *);
31using action_create_from_payload_cb = ssize_t (*)(struct lttng_payload_view *,
32 struct lttng_action **);
33using action_get_rate_policy_cb = const struct lttng_rate_policy *(*) (const struct lttng_action *);
34using action_add_error_query_results_cb = enum lttng_action_status (*)(
35 const struct lttng_action *, struct lttng_error_query_results *);
36using action_mi_serialize_cb = enum lttng_error_code (*)(const struct lttng_action *,
37 struct mi_writer *);
a58c490f
JG
38
39struct lttng_action {
c852ce4e 40 struct urcu_ref ref;
a58c490f
JG
41 enum lttng_action_type type;
42 action_validate_cb validate;
43 action_serialize_cb serialize;
3dd04a6a 44 action_equal_cb equal;
a58c490f 45 action_destroy_cb destroy;
7f4d5b07 46 action_get_rate_policy_cb get_rate_policy;
588c4b0d 47 action_add_error_query_results_cb add_error_query_results;
6a751b95 48 action_mi_serialize_cb mi_serialize;
2d57482c
JR
49
50 /* Internal use only. */
51
52 /* The number of time the actions was enqueued for execution. */
53 uint64_t execution_request_counter;
54 /*
55 * The number of time the action was actually executed.
7f4d5b07 56 * Action rate policy can impact on this number.
2d57482c
JR
57 * */
58 uint64_t execution_counter;
59 /*
60 * The number of time the action execution failed.
588c4b0d
JG
61 * An unsigned long is used to use a type which makes atomic
62 * operations possible.
2d57482c 63 */
588c4b0d 64 unsigned long execution_failure_counter;
a58c490f
JG
65};
66
67struct lttng_action_comm {
68 /* enum lttng_action_type */
69 int8_t action_type;
70} LTTNG_PACKED;
71
6acb3f46
SM
72void lttng_action_init(struct lttng_action *action,
73 enum lttng_action_type type,
74 action_validate_cb validate,
75 action_serialize_cb serialize,
3dd04a6a 76 action_equal_cb equal,
2d57482c 77 action_destroy_cb destroy,
588c4b0d 78 action_get_rate_policy_cb get_rate_policy,
6a751b95
JR
79 action_add_error_query_results_cb add_error_query_results,
80 action_mi_serialize_cb mi);
6acb3f46 81
a58c490f
JG
82bool lttng_action_validate(struct lttng_action *action);
83
3647288f 84int lttng_action_serialize(struct lttng_action *action,
c0a66c84 85 struct lttng_payload *buf);
a58c490f 86
c0a66c84 87ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
a58c490f
JG
88 struct lttng_action **action);
89
3dd04a6a
JR
90bool lttng_action_is_equal(const struct lttng_action *a,
91 const struct lttng_action *b);
92
c852ce4e
JG
93void lttng_action_get(struct lttng_action *action);
94
c852ce4e
JG
95void lttng_action_put(struct lttng_action *action);
96
10615eee
JR
97const char* lttng_action_type_string(enum lttng_action_type action_type);
98
2d57482c
JR
99void lttng_action_increase_execution_request_count(struct lttng_action *action);
100
2d57482c
JR
101void lttng_action_increase_execution_count(struct lttng_action *action);
102
2d57482c
JR
103void lttng_action_increase_execution_failure_count(struct lttng_action *action);
104
2d57482c
JR
105bool lttng_action_should_execute(const struct lttng_action *action);
106
588c4b0d
JG
107enum lttng_action_status lttng_action_add_error_query_results(
108 const struct lttng_action *action,
109 struct lttng_error_query_results *results);
110
111/*
112 * For use by the various lttng_action implementation. Implements the default
113 * behavior to the generic error "execution failure counter" that all actions
a8940c5e 114 * (except list, which passes-through) provide.
588c4b0d 115 */
588c4b0d
JG
116enum lttng_action_status lttng_action_generic_add_error_query_results(
117 const struct lttng_action *action,
118 struct lttng_error_query_results *results);
6a751b95
JR
119enum lttng_error_code lttng_action_mi_serialize(const struct lttng_trigger *trigger,
120 const struct lttng_action *action,
121 struct mi_writer *writer,
122 const struct mi_lttng_error_query_callbacks
123 *error_query_callbacks,
124 struct lttng_dynamic_array *action_path_indexes);
588c4b0d 125
a58c490f 126#endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.047123 seconds and 4 git commands to generate.