SoW-2020-0003: Trace Hit Counters
[lttng-tools.git] / include / lttng / map-key-internal.h
CommitLineData
ebdb334b
JR
1/*
2 * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7#ifndef LTTNG_MAP_KEY_INTERNAL_H
8#define LTTNG_MAP_KEY_INTERNAL_H
9
10#include <common/dynamic-array.h>
11#include <common/macros.h>
12#include <stdbool.h>
13#include <urcu/ref.h>
14
15#include <lttng/map-key.h>
16
17struct lttng_payload;
18struct lttng_payload_view;
19struct lttng_map_key_token;
20
21typedef bool (*map_key_token_equal_cb)(const struct lttng_map_key_token *a,
22 const struct lttng_map_key_token *b);
23
24enum lttng_map_key_token_type {
25 LTTNG_MAP_KEY_TOKEN_TYPE_STRING,
26 LTTNG_MAP_KEY_TOKEN_TYPE_VARIABLE,
27};
28
29struct lttng_map_key_token {
30 enum lttng_map_key_token_type type;
31 map_key_token_equal_cb equal;
32};
33
34struct lttng_map_key_token_comm {
35 uint8_t type;
36};
37
38struct lttng_map_key_token_string {
39 struct lttng_map_key_token parent;
40 char *string;
41};
42
43struct lttng_map_key_token_string_comm {
44 uint8_t parent_type;
45
46 /* Includes null terminator. */
47 uint32_t string_len;
48
49 char payload[];
50};
51
52struct lttng_map_key_token_variable {
53 struct lttng_map_key_token parent;
54 enum lttng_map_key_token_variable_type type;
55};
56
57struct lttng_map_key_token_variable_comm {
58 uint8_t parent_type;
59 uint8_t var_type;
60};
61
62struct lttng_map_key {
63 /* Reference counting is only exposed to internal users*/
64 struct urcu_ref ref;
65 /* Array of `struct lttng_map_key_token` */
66 struct lttng_dynamic_pointer_array tokens;
67};
68
69struct lttng_map_key_comm {
70 uint32_t token_count;
71 /* Array of `struct lttng_map_key_token` */
72 char payload[];
73};
74
75LTTNG_HIDDEN
76void lttng_map_key_get(struct lttng_map_key *key);
77
78LTTNG_HIDDEN
79void lttng_map_key_put(struct lttng_map_key *key);
80
81LTTNG_HIDDEN
82ssize_t lttng_map_key_create_from_payload(struct lttng_payload_view *view,
83 struct lttng_map_key **key);
84
85LTTNG_HIDDEN
86int lttng_map_key_serialize(const struct lttng_map_key *key,
87 struct lttng_payload *payload);
88
89LTTNG_HIDDEN
90enum lttng_map_key_status lttng_map_key_get_token_count(
91 const struct lttng_map_key *key, unsigned int *count);
92
93LTTNG_HIDDEN
94const struct lttng_map_key_token *lttng_map_key_get_token_at_index(
95 const struct lttng_map_key *key, unsigned int index);
96
97LTTNG_HIDDEN
98enum lttng_map_key_token_variable_type lttng_map_key_token_variable_get_type(
99 const struct lttng_map_key_token_variable *token);
100
101LTTNG_HIDDEN
102const char *lttng_map_key_token_string_get_string(
103 const struct lttng_map_key_token_string *token);
104
105LTTNG_HIDDEN
106bool lttng_map_key_is_equal(
107 const struct lttng_map_key *a, const struct lttng_map_key *b);
108
109LTTNG_HIDDEN
110void lttng_map_key_get(struct lttng_map_key *key);
111
112LTTNG_HIDDEN
113void lttng_map_key_put(struct lttng_map_key *key);
114
115LTTNG_HIDDEN
116struct lttng_map_key *lttng_map_key_parse_from_string(const char *key_str);
117
118#endif /* LTTNG_MAP_KEY_INTERNAL_H */
This page took 0.028225 seconds and 5 git commands to generate.