Implement bt_ctf_trace_get_byte_order()
[babeltrace.git] / include / babeltrace / ctf-ir / trace.h
index 1be85cfdeb4d197246ce6fe7324c56b20fa0f2ab..c5a05147ab61deaa338c0bd9942f8c0b91b36706 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include <babeltrace/ctf-ir/event-types.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -41,10 +42,22 @@ struct bt_ctf_stream;
 struct bt_ctf_stream_class;
 struct bt_ctf_clock;
 
+enum bt_environment_field_type {
+       BT_ENVIRONMENT_FIELD_TYPE_UNKNOWN = -1,
+       BT_ENVIRONMENT_FIELD_TYPE_STRING = 0,
+       BT_ENVIRONMENT_FIELD_TYPE_INTEGER = 1,
+};
+
 /*
  * bt_ctf_trace_create: create a trace instance.
  *
- * Allocate a new trace
+ * Allocate a new trace.
+ *
+ * A trace's default packet header is a structure initialized with the following
+ * fields:
+ *     - uint32_t magic
+ *     - uint8_t  uuid[16]
+ *     - uint32_t stream_id
  *
  * Returns a new trace on success, NULL on error.
  */
@@ -66,10 +79,11 @@ extern struct bt_ctf_stream *bt_ctf_trace_create_stream(
                struct bt_ctf_stream_class *stream_class);
 
 /*
- * bt_ctf_trace_add_environment_field: add an environment field to the trace.
+ * bt_ctf_trace_add_environment_field: add a string environment field to the
+ *     trace.
  *
- * Add an environment field to the trace. The name and value parameters are
- * copied.
+ * Add a string environment field to the trace. The name and value parameters
+ * are copied.
  *
  * @param trace Trace instance.
  * @param name Name of the environment field (will be copied).
@@ -81,6 +95,95 @@ extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace,
                const char *name,
                const char *value);
 
+/*
+ * bt_ctf_trace_add_environment_field_integer: add an integer environment
+ *     field to the trace.
+ *
+ * Add an integer environment field to the trace. The name parameter is
+ * copied.
+ *
+ * @param trace Trace instance.
+ * @param name Name of the environment field (will be copied).
+ * @param value Value of the environment field.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_trace_add_environment_field_integer(
+               struct bt_ctf_trace *trace, const char *name,
+               int64_t value);
+
+/*
+ * bt_ctf_trace_get_environment_field_count: get environment field count.
+ *
+ * Get the trace's environment field count.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the environment field count, a negative value on error.
+ */
+extern int bt_ctf_trace_get_environment_field_count(
+               struct bt_ctf_trace *trace);
+
+/*
+ * bt_ctf_trace_get_environment_field_type: get environment field type.
+ *
+ * Get an environment field's type.
+ *
+ * @param trace Trace instance.
+ * @param index Index of the environment field.
+ *
+ * Returns the environment field count, a negative value on error.
+ */
+extern enum bt_environment_field_type
+bt_ctf_trace_get_environment_field_type(struct bt_ctf_trace *trace,
+               int index);
+
+/*
+ * bt_ctf_trace_get_environment_field_name: get environment field name.
+ *
+ * Get an environment field's name. The string's ownership is not
+ * transferred to the caller.
+ *
+ * @param trace Trace instance.
+ * @param index Index of the environment field.
+ *
+ * Returns the environment field's name, NULL on error.
+ */
+extern const char *
+bt_ctf_trace_get_environment_field_name(struct bt_ctf_trace *trace,
+               int index);
+
+/*
+ * bt_ctf_trace_get_environment_field_value_string: get environment field
+ *     string value.
+ *
+ * Get an environment field's string value. The string's ownership is not
+ * transferred to the caller.
+ *
+ * @param trace Trace instance.
+ * @param index Index of the environment field.
+ *
+ * Returns the environment field's string value, NULL on error.
+ */
+extern const char *
+bt_ctf_trace_get_environment_field_value_string(struct bt_ctf_trace *trace,
+               int index);
+
+/*
+ * bt_ctf_trace_get_environment_field_value_integer: get environment field
+ *      integer value.
+ *
+ * Get an environment field's integer value.
+ *
+ * @param trace Trace instance.
+ * @param index Index of the environment field.
+ *
+ * Returns the environment field's integer value, a negative value on error.
+ */
+extern int
+bt_ctf_trace_get_environment_field_value_integer(struct bt_ctf_trace *trace,
+               int index, int64_t *value);
+
 /*
  * bt_ctf_trace_add_clock: add a clock to the trace.
  *
@@ -95,6 +198,27 @@ extern int bt_ctf_trace_add_environment_field(struct bt_ctf_trace *trace,
 extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
                struct bt_ctf_clock *clock);
 
+/*
+ * bt_ctf_trace_get_clock_count: get the number of clocks
+ *     associated to the trace.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the clock count on success, a negative value on error.
+ */
+extern int bt_ctf_trace_get_clock_count(struct bt_ctf_trace *trace);
+
+/*
+ * bt_ctf_trace_get_clock: get a trace's clock at index.
+ *
+ * @param trace Trace instance.
+ * @param index Index of the clock in the given trace.
+ *
+ * Return a clock instance on success, NULL on error.
+ */
+extern struct bt_ctf_clock *bt_ctf_trace_get_clock(
+               struct bt_ctf_trace *trace, int index);
+
 /*
  * bt_ctf_trace_get_metadata_string: get metadata string.
  *
@@ -108,19 +232,60 @@ extern int bt_ctf_trace_add_clock(struct bt_ctf_trace *trace,
 extern char *bt_ctf_trace_get_metadata_string(struct bt_ctf_trace *trace);
 
 /*
- * bt_ctf_trace_set_byte_order: set a field type's byte order.
+ * bt_ctf_trace_get_byte_order: get a trace's byte order.
  *
- * Set the trace's byte order. Defaults to BT_CTF_BYTE_ORDER_NATIVE,
- * the host machine's endianness.
+ * Get the trace's byte order.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the trace's endianness, BT_CTF_BYTE_ORDER_UNKNOWN on error.
+ */
+extern enum bt_ctf_byte_order bt_ctf_trace_get_byte_order(
+               struct bt_ctf_trace *trace);
+
+/*
+ * bt_ctf_trace_set_byte_order: set a trace's byte order.
+ *
+ * Set the trace's byte order. Defaults to the current host's endianness.
  *
  * @param trace Trace instance.
  * @param byte_order Trace's byte order.
  *
  * Returns 0 on success, a negative value on error.
+ *
+ * Note: byte_order must not be BT_CTF_BYTE_ORDER_NATIVE since, according
+ * to the CTF specification, is defined as "the byte order described in the
+ * trace description".
  */
 extern int bt_ctf_trace_set_byte_order(struct bt_ctf_trace *trace,
                enum bt_ctf_byte_order byte_order);
 
+/*
+ * bt_ctf_trace_get_packet_header_type: get a trace's packet header type.
+ *
+ * Get the trace's packet header type.
+ *
+ * @param trace Trace instance.
+ *
+ * Returns the trace's packet header type (a structure) on success, NULL on
+ *     error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_trace_get_packet_header_type(
+               struct bt_ctf_trace *trace);
+
+/*
+ * bt_ctf_trace_set_packet_header_type: set a trace's packet header type.
+ *
+ * Set the trace's packet header type.
+ *
+ * @param trace Trace instance.
+ * @param packet_header_type Packet header field type (must be a structure).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_trace_set_packet_header_type(struct bt_ctf_trace *trace,
+               struct bt_ctf_field_type *packet_header_type);
+
 /*
  * bt_ctf_trace_get and bt_ctf_trace_put: increment and decrement the
  * trace's reference count.
This page took 0.037881 seconds and 4 git commands to generate.