X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fctf-writer%2Fevent.h;h=c4e8965b8f1a487ba6c4d16c6a152ac167c10398;hb=63976d98f349c661f825bdcdd5a2f61d14280a03;hp=d8ef9d92776d2c4f908c46e140020ecf7787c56c;hpb=46bd0f2b6f3056aa85ac827a85fd8c878f261313;p=babeltrace.git diff --git a/include/babeltrace/ctf-writer/event.h b/include/babeltrace/ctf-writer/event.h index d8ef9d92..c4e8965b 100644 --- a/include/babeltrace/ctf-writer/event.h +++ b/include/babeltrace/ctf-writer/event.h @@ -2,9 +2,7 @@ #define BABELTRACE_CTF_WRITER_EVENT_H /* - * BabelTrace - CTF Writer: Event - * - * Copyright 2013 EfficiOS Inc. + * Copyright 2013, 2014 Jérémie Galarneau * * Author: Jérémie Galarneau * @@ -30,122 +28,186 @@ * http://www.efficios.com/ctf */ +#include + #ifdef __cplusplus extern "C" { #endif -struct bt_ctf_event_class; struct bt_ctf_event; +struct bt_ctf_event_class; +struct bt_ctf_stream; struct bt_ctf_field; struct bt_ctf_field_type; -/* - * bt_ctf_event_class_create: create an event class. - * - * Allocate a new event class of the given name. The creation of an event class - * sets its reference count to 1. - * - * @param name Event class name (will be copied). - * - * Returns an allocated event class on success, NULL on error. - */ -extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name); +enum bt_ctf_event_class_log_level { + /// Unknown, used for errors. + BT_CTF_EVENT_CLASS_LOG_LEVEL_UNKNOWN = -1, -/* - * bt_ctf_event_class_add_field: add a field to an event class. - * - * Add a field of type "type" to the event class. The event class will share - * type's ownership by increasing its reference count. The "name" will be - * copied. - * - * @param event_class Event class. - * @param type Field type to add to the event class. - * @param name Name of the new field. - * - * Returns 0 on success, a negative value on error. - */ -extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, - struct bt_ctf_field_type *type, - const char *name); + /// Unspecified log level. + BT_CTF_EVENT_CLASS_LOG_LEVEL_UNSPECIFIED = 255, -/* - * bt_ctf_event_class__get and bt_ctf_event_class_put: increment and decrement - * the event class' reference count. - * - * These functions ensure that the event class won't be destroyed while it - * is in use. The same number of get and put (plus one extra put to - * release the initial reference done at creation) have to be done to - * destroy an event class. - * - * When the event class' reference count is decremented to 0 by a - * bt_ctf_event_class_put, the event class is freed. - * - * @param event_class Event class. - */ -extern void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class); -extern void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class); + /// System is unusable. + BT_CTF_EVENT_CLASS_LOG_LEVEL_EMERGENCY = 0, + + /// Action must be taken immediately. + BT_CTF_EVENT_CLASS_LOG_LEVEL_ALERT = 1, + + /// Critical conditions. + BT_CTF_EVENT_CLASS_LOG_LEVEL_CRITICAL = 2, + + /// Error conditions. + BT_CTF_EVENT_CLASS_LOG_LEVEL_ERROR = 3, + + /// Warning conditions. + BT_CTF_EVENT_CLASS_LOG_LEVEL_WARNING = 4, + + /// Normal, but significant, condition. + BT_CTF_EVENT_CLASS_LOG_LEVEL_NOTICE = 5, + + /// Informational message. + BT_CTF_EVENT_CLASS_LOG_LEVEL_INFO = 6, + + /// Debug information with system-level scope (set of programs). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_SYSTEM = 7, + + /// Debug information with program-level scope (set of processes). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROGRAM = 8, + + /// Debug information with process-level scope (set of modules). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_PROCESS = 9, + + /// Debug information with module (executable/library) scope (set of units). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_MODULE = 10, + + /// Debug information with compilation unit scope (set of functions). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_UNIT = 11, + + /// Debug information with function-level scope. + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_FUNCTION = 12, + + /// Debug information with line-level scope (default log level). + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG_LINE = 13, + + /// Debug-level message. + BT_CTF_EVENT_CLASS_LOG_LEVEL_DEBUG = 14, +}; -/* - * bt_ctf_event_create: instanciate an event. - * - * Allocate a new event of the given event class. The creation of an event - * sets its reference count to 1. Each instance shares the ownership of the - * event class using its reference count. - * - * @param event_class Event class. - * - * Returns an allocated field type on success, NULL on error. - */ extern struct bt_ctf_event *bt_ctf_event_create( struct bt_ctf_event_class *event_class); -/* - * bt_ctf_event_set_payload: set an event's field. - * - * Set a manually allocated field as an event's payload. The event will share - * the field's ownership by using its reference count. - * bt_ctf_field_put() must be called on the returned value. - * - * @param event Event instance. - * @param name Event field name. - * @param value Instance of a field whose type corresponds to the event's field. - * - * Returns 0 on success, a negative value on error. - */ +extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, + const char *name); + extern int bt_ctf_event_set_payload(struct bt_ctf_event *event, - const char *name, - struct bt_ctf_field *value); + const char *name, struct bt_ctf_field *field); -/* - * bt_ctf_event_get_payload: get an event's field. - * - * Returns the field matching "name". bt_ctf_field_put() must be called on the - * returned value. - * - * @param event Event instance. - * @param name Event field name. - * - * Returns a field instance on success, NULL on error. - */ -extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event, +extern struct bt_ctf_field *bt_ctf_event_get_payload_field( + struct bt_ctf_event *event); + +extern int bt_ctf_event_set_payload_field(struct bt_ctf_event *event, + struct bt_ctf_field *field); + +extern int bt_ctf_event_set_context(struct bt_ctf_event *event, + struct bt_ctf_field *field); + +extern struct bt_ctf_field *bt_ctf_event_get_context( + struct bt_ctf_event *event); + +extern int bt_ctf_event_set_stream_event_context(struct bt_ctf_event *event, + struct bt_ctf_field *field); + +extern struct bt_ctf_field *bt_ctf_event_get_stream_event_context( + struct bt_ctf_event *event); + +extern int bt_ctf_event_set_header(struct bt_ctf_event *event, + struct bt_ctf_field *field); + +extern struct bt_ctf_field *bt_ctf_event_get_header( + struct bt_ctf_event *event); + +extern struct bt_ctf_stream *bt_ctf_event_get_stream( + struct bt_ctf_event *event); + +extern struct bt_ctf_event_class *bt_ctf_event_get_class( + struct bt_ctf_event *event); + +/* Pre-2.0 CTF writer compatibility */ +static inline +void bt_ctf_event_get(struct bt_ctf_event *event) +{ + bt_ctf_object_get_ref(event); +} + +/* Pre-2.0 CTF writer compatibility */ +static inline +void bt_ctf_event_put(struct bt_ctf_event *event) +{ + bt_ctf_object_put_ref(event); +} + +extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name); + +extern struct bt_ctf_stream_class *bt_ctf_event_class_get_stream_class( + struct bt_ctf_event_class *event_class); + +extern const char *bt_ctf_event_class_get_name( + struct bt_ctf_event_class *event_class); + +extern int64_t bt_ctf_event_class_get_id( + struct bt_ctf_event_class *event_class); + +extern int bt_ctf_event_class_set_id( + struct bt_ctf_event_class *event_class, uint64_t id); + +extern enum bt_ctf_event_class_log_level bt_ctf_event_class_get_log_level( + struct bt_ctf_event_class *event_class); + +extern int bt_ctf_event_class_set_log_level( + struct bt_ctf_event_class *event_class, + enum bt_ctf_event_class_log_level log_level); + +extern const char *bt_ctf_event_class_get_emf_uri( + struct bt_ctf_event_class *event_class); + +extern int bt_ctf_event_class_set_emf_uri( + struct bt_ctf_event_class *event_class, + const char *emf_uri); + +extern struct bt_ctf_field_type *bt_ctf_event_class_get_context_field_type( + struct bt_ctf_event_class *event_class); + +extern int bt_ctf_event_class_set_context_field_type( + struct bt_ctf_event_class *event_class, + struct bt_ctf_field_type *context_type); + +extern struct bt_ctf_field_type *bt_ctf_event_class_get_payload_field_type( + struct bt_ctf_event_class *event_class); + +extern int bt_ctf_event_class_set_payload_field_type( + struct bt_ctf_event_class *event_class, + struct bt_ctf_field_type *payload_type); + +extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class, + struct bt_ctf_field_type *field_type, const char *name); -/* - * bt_ctf_event_get and bt_ctf_event_put: increment and decrement - * the event's reference count. - * - * These functions ensure that the event won't be destroyed while it - * is in use. The same number of get and put (plus one extra put to - * release the initial reference done at creation) have to be done to - * destroy an event. - * - * When the event's reference count is decremented to 0 by a - * bt_ctf_event_put, the event is freed. - * - * @param event Event instance. - */ -extern void bt_ctf_event_get(struct bt_ctf_event *event); -extern void bt_ctf_event_put(struct bt_ctf_event *event); +extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name( + struct bt_ctf_event_class *event_class, const char *name); + +/* Pre-2.0 CTF writer compatibility */ +static inline +void bt_ctf_event_class_get(struct bt_ctf_event_class *event_class) +{ + bt_ctf_object_get_ref(event_class); +} + +/* Pre-2.0 CTF writer compatibility */ +static inline +void bt_ctf_event_class_put(struct bt_ctf_event_class *event_class) +{ + bt_ctf_object_put_ref(event_class); +} #ifdef __cplusplus }