actions: Make lttng_action reference countable
[lttng-tools.git] / include / lttng / action / action-internal.h
1 /*
2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_ACTION_INTERNAL_H
9 #define LTTNG_ACTION_INTERNAL_H
10
11 #include <lttng/action/action.h>
12 #include <common/macros.h>
13 #include <common/buffer-view.h>
14 #include <common/dynamic-buffer.h>
15 #include <common/sessiond-comm/payload-view.h>
16 #include <common/sessiond-comm/payload.h>
17 #include <stdbool.h>
18 #include <sys/types.h>
19 #include <urcu/ref.h>
20
21 typedef bool (*action_validate_cb)(struct lttng_action *action);
22 typedef void (*action_destroy_cb)(struct lttng_action *action);
23 typedef int (*action_serialize_cb)(struct lttng_action *action,
24 struct lttng_payload *payload);
25 typedef bool (*action_equal_cb)(const struct lttng_action *a,
26 const struct lttng_action *b);
27 typedef ssize_t (*action_create_from_payload_cb)(
28 struct lttng_payload_view *view,
29 struct lttng_action **action);
30
31 struct lttng_action {
32 struct urcu_ref ref;
33 enum lttng_action_type type;
34 action_validate_cb validate;
35 action_serialize_cb serialize;
36 action_equal_cb equal;
37 action_destroy_cb destroy;
38 };
39
40 struct lttng_action_comm {
41 /* enum lttng_action_type */
42 int8_t action_type;
43 } LTTNG_PACKED;
44
45 LTTNG_HIDDEN
46 void lttng_action_init(struct lttng_action *action,
47 enum lttng_action_type type,
48 action_validate_cb validate,
49 action_serialize_cb serialize,
50 action_equal_cb equal,
51 action_destroy_cb destroy);
52
53 LTTNG_HIDDEN
54 bool lttng_action_validate(struct lttng_action *action);
55
56 LTTNG_HIDDEN
57 int lttng_action_serialize(struct lttng_action *action,
58 struct lttng_payload *buf);
59
60 LTTNG_HIDDEN
61 ssize_t lttng_action_create_from_payload(struct lttng_payload_view *view,
62 struct lttng_action **action);
63
64 LTTNG_HIDDEN
65 enum lttng_action_type lttng_action_get_type_const(
66 const struct lttng_action *action);
67
68 LTTNG_HIDDEN
69 bool lttng_action_is_equal(const struct lttng_action *a,
70 const struct lttng_action *b);
71
72 LTTNG_HIDDEN
73 void lttng_action_get(struct lttng_action *action);
74
75 LTTNG_HIDDEN
76 void lttng_action_put(struct lttng_action *action);
77
78 #endif /* LTTNG_ACTION_INTERNAL_H */
This page took 0.031085 seconds and 5 git commands to generate.