2 * Copyright (C) 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_CONDITION_INTERNAL_H
9 #define LTTNG_CONDITION_INTERNAL_H
11 #include <common/macros.h>
12 #include <common/payload-view.h>
13 #include <common/payload.h>
14 #include <lttng/condition/condition.h>
15 #include <lttng/lttng-error.h>
18 #include <sys/types.h>
19 #include <urcu/list.h>
23 struct mi_lttng_error_query_callbacks
;
26 typedef void (*condition_destroy_cb
)(struct lttng_condition
*condition
);
27 typedef bool (*condition_validate_cb
)(const struct lttng_condition
*condition
);
28 typedef int (*condition_serialize_cb
)(
29 const struct lttng_condition
*condition
,
30 struct lttng_payload
*payload
);
31 typedef bool (*condition_equal_cb
)(const struct lttng_condition
*a
,
32 const struct lttng_condition
*b
);
33 typedef ssize_t (*condition_create_from_payload_cb
)(
34 struct lttng_payload_view
*view
,
35 struct lttng_condition
**condition
);
36 typedef enum lttng_error_code (*condition_mi_serialize_cb
)(
37 const struct lttng_condition
*condition
,
38 struct mi_writer
*writer
);
40 struct lttng_condition
{
41 /* Reference counting is only exposed to internal users. */
43 enum lttng_condition_type type
;
44 condition_validate_cb validate
;
45 condition_serialize_cb serialize
;
46 condition_equal_cb equal
;
47 condition_destroy_cb destroy
;
48 condition_mi_serialize_cb mi_serialize
;
51 struct lttng_condition_comm
{
52 /* enum lttng_condition_type */
53 int8_t condition_type
;
57 void lttng_condition_get(struct lttng_condition
*condition
);
59 void lttng_condition_put(struct lttng_condition
*condition
);
61 void lttng_condition_init(struct lttng_condition
*condition
,
62 enum lttng_condition_type type
);
64 bool lttng_condition_validate(const struct lttng_condition
*condition
);
66 ssize_t
lttng_condition_create_from_payload(
67 struct lttng_payload_view
*view
,
68 struct lttng_condition
**condition
);
70 int lttng_condition_serialize(const struct lttng_condition
*condition
,
71 struct lttng_payload
*payload
);
73 bool lttng_condition_is_equal(const struct lttng_condition
*a
,
74 const struct lttng_condition
*b
);
76 enum lttng_error_code
lttng_condition_mi_serialize(
77 const struct lttng_trigger
*trigger
,
78 const struct lttng_condition
*condition
,
79 struct mi_writer
*writer
,
80 const struct mi_lttng_error_query_callbacks
81 *error_query_callbacks
);
83 const char *lttng_condition_type_str(enum lttng_condition_type type
);
85 #endif /* LTTNG_CONDITION_INTERNAL_H */