event.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef BABELTRACE_CTF_IR_EVENT_H
  2. #define BABELTRACE_CTF_IR_EVENT_H
  3. /*
  4. * BabelTrace - CTF IR: Event
  5. *
  6. * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  7. *
  8. * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11. * of this software and associated documentation files (the "Software"), to deal
  12. * in the Software without restriction, including without limitation the rights
  13. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. * copies of the Software, and to permit persons to whom the Software is
  15. * furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in
  18. * all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. * SOFTWARE.
  27. *
  28. * The Common Trace Format (CTF) Specification is available at
  29. * http://www.efficios.com/ctf
  30. */
  31. #include <stdint.h>
  32. #include <stddef.h>
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. struct bt_ctf_event_class;
  37. struct bt_ctf_event;
  38. struct bt_ctf_field;
  39. struct bt_ctf_field_type;
  40. struct bt_ctf_stream_class;
  41. /*
  42. * bt_ctf_event_create: instanciate an event.
  43. *
  44. * Allocate a new event of the given event class. The creation of an event
  45. * sets its reference count to 1. Each instance shares the ownership of the
  46. * event class using its reference count.
  47. *
  48. * An event class must be associated with a stream class before events
  49. * may be instanciated.
  50. *
  51. * @param event_class Event class.
  52. *
  53. * Returns an allocated field type on success, NULL on error.
  54. */
  55. extern struct bt_ctf_event *bt_ctf_event_create(
  56. struct bt_ctf_event_class *event_class);
  57. /*
  58. * bt_ctf_event_get_payload: get an event's field.
  59. *
  60. * Returns the field matching "name". bt_ctf_field_put() must be called on the
  61. * returned value.
  62. *
  63. * @param event Event instance.
  64. * @param name Event field name, see notes.
  65. *
  66. * Returns a field instance on success, NULL on error.
  67. *
  68. * Note: Passing a name will cause the function to perform a look-up by
  69. * name assuming the event's payload is a structure. This will return
  70. * the raw payload instance if name is NULL.
  71. */
  72. extern struct bt_ctf_field *bt_ctf_event_get_payload(struct bt_ctf_event *event,
  73. const char *name);
  74. /*
  75. * bt_ctf_event_set_payload: set an event's field.
  76. *
  77. * Set a manually allocated field as an event's payload. The event will share
  78. * the field's ownership by using its reference count.
  79. * bt_ctf_field_put() must be called on the returned value.
  80. *
  81. * @param event Event instance.
  82. * @param name Event field name, see notes.
  83. * @param value Instance of a field whose type corresponds to the event's field.
  84. *
  85. * Returns 0 on success, a negative value on error.
  86. *
  87. * Note: The function will return an error if a name is provided and the payload
  88. * type is not a structure. If name is NULL, the payload field will be set
  89. * directly and must match the event class' payload's type.
  90. */
  91. extern int bt_ctf_event_set_payload(struct bt_ctf_event *event,
  92. const char *name,
  93. struct bt_ctf_field *value);
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif /* BABELTRACE_CTF_IR_EVENT_H */