Commit | Line | Data |
---|---|---|
b469d2dd JD |
1 | #ifndef _BABELTRACE_CONTEXT_H |
2 | #define _BABELTRACE_CONTEXT_H | |
3 | ||
4 | /* | |
5 | * BabelTrace | |
6 | * | |
7 | * context header | |
8 | * | |
9 | * Copyright 2012 EfficiOS Inc. and Linux Foundation | |
10 | * | |
11 | * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
12 | * Julien Desfossez <julien.desfossez@efficios.com> | |
13 | * | |
6cba487f MD |
14 | * Permission is hereby granted, free of charge, to any person obtaining |
15 | * a copy of this software and associated documentation files (the | |
16 | * "Software"), to deal in the Software without restriction, including | |
17 | * without limitation the rights to use, copy, modify, merge, publish, | |
18 | * distribute, sublicense, and/or sell copies of the Software, and to | |
19 | * permit persons to whom the Software is furnished to do so, subject to | |
20 | * the following conditions: | |
b469d2dd | 21 | * |
6cba487f MD |
22 | * The above copyright notice and this permission notice shall be |
23 | * included in all copies or substantial portions of the Software. | |
b469d2dd JD |
24 | */ |
25 | ||
08c22d05 MD |
26 | /* struct bt_context is opaque to the user */ |
27 | struct bt_context; | |
b469d2dd JD |
28 | |
29 | /* | |
30 | * bt_context_create : create a Babeltrace context | |
31 | * | |
6cba487f MD |
32 | * Allocate a new context. The creation of the context sets the refcount |
33 | * to 1. | |
b469d2dd JD |
34 | * |
35 | * Returns an allocated context on success and NULL on error | |
36 | */ | |
6cba487f | 37 | struct bt_context *bt_context_create(void); |
b469d2dd JD |
38 | |
39 | /* | |
6cba487f | 40 | * bt_context_add_trace : Add a trace by path to the context |
b469d2dd | 41 | * |
6cba487f MD |
42 | * Open a trace |
43 | * | |
e669e45e | 44 | * Return: 0 on success, nonzero on failure. |
6cba487f MD |
45 | */ |
46 | int bt_context_add_trace(struct bt_context *ctx, const char *path, | |
47 | const char *format); | |
48 | ||
6cba487f MD |
49 | /* |
50 | * bt_context_remove_trace: Remove a trace from the context. | |
51 | * | |
52 | * Effectively closing the trace. | |
b469d2dd | 53 | */ |
6cba487f | 54 | void bt_context_remove_trace(struct bt_context *ctx, int trace_id); |
b469d2dd JD |
55 | |
56 | /* | |
6cba487f MD |
57 | * bt_context_get and bt_context_put : increments and decrement the |
58 | * refcount of the context | |
b469d2dd | 59 | * |
6cba487f MD |
60 | * These functions ensures that the context won't be destroyed when it |
61 | * is in use. The same number of get and put (plus one extra put to | |
62 | * release the initial reference done at creation) has to be done to | |
63 | * destroy a context. | |
b469d2dd | 64 | * |
6cba487f MD |
65 | * When the context refcount is decremented to 0 by a bt_context_put, |
66 | * the context is freed. | |
b469d2dd | 67 | */ |
6cba487f MD |
68 | void bt_context_get(struct bt_context *ctx); |
69 | void bt_context_put(struct bt_context *ctx); | |
b469d2dd JD |
70 | |
71 | #endif /* _BABELTRACE_CONTEXT_H */ |