event-class.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef BABELTRACE_CTF_IR_EVENT_CLASS_H
  2. #define BABELTRACE_CTF_IR_EVENT_CLASS_H
  3. /*
  4. * BabelTrace - CTF IR: Event class
  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_field;
  38. struct bt_ctf_field_type;
  39. struct bt_ctf_stream_class;
  40. /*
  41. * bt_ctf_event_class_create: create an event class.
  42. *
  43. * Allocate a new event class of the given name. The creation of an event class
  44. * sets its reference count to 1. A unique event id is automatically assigned
  45. * to the event class.
  46. *
  47. * @param name Event class name (will be copied).
  48. *
  49. * Returns an allocated event class on success, NULL on error.
  50. */
  51. extern struct bt_ctf_event_class *bt_ctf_event_class_create(const char *name);
  52. /*
  53. * bt_ctf_event_class_add_field: add a field to an event class.
  54. *
  55. * Add a field of type "type" to the event class. The event class will share
  56. * type's ownership by increasing its reference count. The "name" will be
  57. * copied.
  58. *
  59. * @param event_class Event class.
  60. * @param type Field type to add to the event class.
  61. * @param name Name of the new field.
  62. *
  63. * Returns 0 on success, a negative value on error.
  64. *
  65. * Note: Returns an error if the payload is not a structure.
  66. */
  67. extern int bt_ctf_event_class_add_field(struct bt_ctf_event_class *event_class,
  68. struct bt_ctf_field_type *type,
  69. const char *name);
  70. /*
  71. * bt_ctf_event_class_get_field_by_name: Get an event class's field by name
  72. *
  73. * @param event_class Event class.
  74. * @param name Name of the field.
  75. *
  76. * Returns a field type on success, NULL on error.
  77. *
  78. * Note: Returns an error if the payload is not a structure.
  79. */
  80. extern struct bt_ctf_field_type *bt_ctf_event_class_get_field_by_name(
  81. struct bt_ctf_event_class *event_class, const char *name);
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif /* BABELTRACE_CTF_IR_EVENT_CLASS_H */