stream-class.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef BABELTRACE_CTF_IR_STREAM_CLASS_H
  2. #define BABELTRACE_CTF_IR_STREAM_CLASS_H
  3. /*
  4. * BabelTrace - CTF IR: Stream Class
  5. *
  6. * Copyright 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. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. struct bt_ctf_event_class;
  36. struct bt_ctf_stream_class;
  37. struct bt_ctf_clock;
  38. /*
  39. * bt_ctf_stream_class_create: create a stream class.
  40. *
  41. * Allocate a new stream class of the given name. The creation of an event class
  42. * sets its reference count to 1.
  43. *
  44. * A stream class' packet context is a structure initialized with the following
  45. * fields:
  46. * - uint64_t timestamp_begin
  47. * - uint64_t timestamp_end
  48. * - uint64_t content_size
  49. * - uint64_t packet_size
  50. * - uint64_t events_discarded
  51. *
  52. * A stream class's event header is a structure initialized the following
  53. * fields:
  54. * - uint32_t id
  55. * - uint64_t timestamp
  56. *
  57. * @param name Stream name, NULL to create an unnamed stream class.
  58. *
  59. * Returns an allocated stream class on success, NULL on error.
  60. */
  61. extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
  62. /*
  63. * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
  64. *
  65. * Add an event class to a stream class. New events can be added even after a
  66. * stream has beem instanciated and events have been appended. However, a stream
  67. * will not accept events of a class that has not been registered beforehand.
  68. * The stream class will share the ownership of "event_class" by incrementing
  69. * its reference count.
  70. *
  71. * Note that an event class may only be added to one stream class. It
  72. * also becomes immutable.
  73. *
  74. * @param stream_class Stream class.
  75. * @param event_class Event class to add to the provided stream class.
  76. *
  77. * Returns 0 on success, a negative value on error.
  78. */
  79. extern int bt_ctf_stream_class_add_event_class(
  80. struct bt_ctf_stream_class *stream_class,
  81. struct bt_ctf_event_class *event_class);
  82. /*
  83. * bt_ctf_stream_class_get_packet_context_type: get the stream class' packet
  84. * context type.
  85. *
  86. * @param stream_class Stream class.
  87. *
  88. * Returns the packet context's type (a structure), NULL on error.
  89. */
  90. extern struct bt_ctf_field_type *bt_ctf_stream_class_get_packet_context_type(
  91. struct bt_ctf_stream_class *stream_class);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95. #endif /* BABELTRACE_CTF_IR_STREAM_CLASS_H */