Split the CTF-Writer API into IR and Writer-specific parts
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 21 Mar 2014 19:05:02 +0000 (15:05 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Jun 2014 20:07:25 +0000 (16:07 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
30 files changed:
bindings/python/python-complements.c
configure.ac
formats/ctf/writer/clock.c
formats/ctf/writer/event-fields.c
formats/ctf/writer/event-types.c
formats/ctf/writer/event.c
formats/ctf/writer/stream.c
formats/ctf/writer/writer.c
include/Makefile.am
include/babeltrace/ctf-ir/clock-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/clock.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event-fields-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event-fields.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event-types-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event-types.h [new file with mode: 0644]
include/babeltrace/ctf-ir/event.h [new file with mode: 0644]
include/babeltrace/ctf-ir/stream-class-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/stream-class.h [new file with mode: 0644]
include/babeltrace/ctf-writer/clock-internal.h [deleted file]
include/babeltrace/ctf-writer/clock.h
include/babeltrace/ctf-writer/event-fields-internal.h [deleted file]
include/babeltrace/ctf-writer/event-fields.h
include/babeltrace/ctf-writer/event-internal.h [deleted file]
include/babeltrace/ctf-writer/event-types-internal.h [deleted file]
include/babeltrace/ctf-writer/event-types.h
include/babeltrace/ctf-writer/event.h
include/babeltrace/ctf-writer/stream-class.h
include/babeltrace/ctf-writer/stream-internal.h
include/babeltrace/ctf-writer/writer.h

index 6f947bd04e331cb3675a3820b8166e6e2af18e5f..3172c74fc07fc2619d1f7d52a3fc0884378ef8c0 100644 (file)
@@ -19,8 +19,8 @@
  */
 
 #include "python-complements.h"
-#include <babeltrace/ctf-writer/event-types-internal.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
 
 /* FILE functions
    ----------------------------------------------------
index faa3f98472a5e7541d77f9c3efa76b23664df880..aefa8a59984e0b847b2cef494aff29c33be90de5 100644 (file)
@@ -161,6 +161,9 @@ AC_SUBST(babeltracectfincludedir)
 babeltracectfwriterincludedir="${includedir}/babeltrace/ctf-writer"
 AC_SUBST(babeltracectfwriterincludedir)
 
+babeltracectfirincludedir="${includedir}/babeltrace/ctf-ir"
+AC_SUBST(babeltracectfirincludedir)
+
 AC_CONFIG_FILES([
        Makefile
        types/Makefile
index 1146e005a3bcb43ea646d0165acece436a658626..d8df956df2ed6a9f84c03690d7f0f39d36aafc1d 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
+#include <babeltrace/ctf-ir/clock-internal.h>
 #include <babeltrace/ctf-writer/writer-internal.h>
 #include <babeltrace/compiler.h>
 #include <inttypes.h>
index c4d1b968587e33f00f24f8efe0c0658c201e6ba6..17616a51be4f21baa3b7faa1d0f6098d8724926a 100644 (file)
@@ -27,8 +27,8 @@
  */
 
 #include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
-#include <babeltrace/ctf-writer/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
 #include <babeltrace/compiler.h>
 
 #define PACKET_LEN_INCREMENT   (getpagesize() * 8 * CHAR_BIT)
index 7f7fa7622247abb3e09288960429722d3f9cf8a1..0c8eddc000fb9d1db9debefd1065334a28ccb366 100644 (file)
@@ -27,7 +27,7 @@
  */
 
 #include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
 #include <babeltrace/ctf-writer/writer-internal.h>
 #include <babeltrace/compiler.h>
 #include <babeltrace/endian.h>
index c7f1b22a14f55d54cf8c1ac36d440fa6880c9804..c62317dccf3b4f61be915eba17d84b70d4c4166d 100644 (file)
@@ -29,9 +29,9 @@
 #include <babeltrace/ctf-writer/event.h>
 #include <babeltrace/ctf-writer/event-types.h>
 #include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
-#include <babeltrace/ctf-writer/event-types-internal.h>
-#include <babeltrace/ctf-writer/event-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-internal.h>
 #include <babeltrace/ctf-writer/writer-internal.h>
 #include <babeltrace/compiler.h>
 
index 4efb369213cbbe7638b5ceaf1a473a38a0c5312f..71a8212eddb2f30839f7ba730de306d4571e9fed 100644 (file)
  */
 
 #include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
+#include <babeltrace/ctf-ir/clock-internal.h>
 #include <babeltrace/ctf-writer/event.h>
-#include <babeltrace/ctf-writer/event-internal.h>
-#include <babeltrace/ctf-writer/event-types-internal.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
 #include <babeltrace/ctf-writer/stream.h>
 #include <babeltrace/ctf-writer/stream-internal.h>
+#include <babeltrace/ctf-ir/stream-class-internal.h>
 #include <babeltrace/ctf-writer/functor-internal.h>
 #include <babeltrace/compiler.h>
 #include <babeltrace/align.h>
index 3630b36b177abb9c253451419b5b10f8a9e90f3a..1f3c3b27b14f38c4b462b4c3f04b00a8f21eef2e 100644 (file)
 
 #include <babeltrace/ctf-writer/writer.h>
 #include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/clock-internal.h>
+#include <babeltrace/ctf-ir/clock-internal.h>
 #include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/ctf-writer/event-types-internal.h>
-#include <babeltrace/ctf-writer/event-fields-internal.h>
+#include <babeltrace/ctf-ir/event-types-internal.h>
+#include <babeltrace/ctf-ir/event-fields-internal.h>
 #include <babeltrace/ctf-writer/functor-internal.h>
+#include <babeltrace/ctf-ir/stream-class-internal.h>
 #include <babeltrace/ctf-writer/stream-internal.h>
 #include <babeltrace/ctf-writer/stream.h>
 #include <babeltrace/compiler.h>
index d9996a7b4cf93b679cb1133e4ba80b106bd611fe..3e322666ed385b6348a65dd9aa99100ea8015ca0 100644 (file)
@@ -18,7 +18,15 @@ babeltracectfwriterinclude_HEADERS = \
        babeltrace/ctf-writer/event-fields.h \
        babeltrace/ctf-writer/event-types.h \
        babeltrace/ctf-writer/event.h \
-       babeltrace/ctf-writer/stream.h
+       babeltrace/ctf-writer/stream.h \
+       babeltrace/ctf-writer/stream-class.h
+
+babeltracectfirinclude_HEADERS = \
+       babeltrace/ctf-ir/clock.h \
+       babeltrace/ctf-ir/event-fields.h \
+       babeltrace/ctf-ir/event-types.h \
+       babeltrace/ctf-ir/event.h \
+       babeltrace/ctf-ir/stream-class.h
 
 noinst_HEADERS = \
        babeltrace/align.h \
@@ -41,10 +49,11 @@ noinst_HEADERS = \
        babeltrace/ctf/ctf-index.h \
        babeltrace/ctf-writer/ref-internal.h \
        babeltrace/ctf-writer/writer-internal.h \
-       babeltrace/ctf-writer/event-types-internal.h \
-       babeltrace/ctf-writer/event-fields-internal.h \
-       babeltrace/ctf-writer/event-internal.h \
-       babeltrace/ctf-writer/clock-internal.h \
+       babeltrace/ctf-ir/event-types-internal.h \
+       babeltrace/ctf-ir/event-fields-internal.h \
+       babeltrace/ctf-ir/event-internal.h \
+       babeltrace/ctf-ir/clock-internal.h \
+       babeltrace/ctf-ir/stream-class-internal.h \
        babeltrace/ctf-writer/stream-internal.h \
        babeltrace/ctf-writer/functor-internal.h \
        babeltrace/trace-handle-internal.h \
diff --git a/include/babeltrace/ctf-ir/clock-internal.h b/include/babeltrace/ctf-ir/clock-internal.h
new file mode 100644 (file)
index 0000000..fe94501
--- /dev/null
@@ -0,0 +1,65 @@
+#ifndef BABELTRACE_CTF_IR_CLOCK_INTERNAL_H
+#define BABELTRACE_CTF_IR_CLOCK_INTERNAL_H
+
+/*
+ * BabelTrace - CTF IR: Clock internal
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/clock.h>
+#include <babeltrace/ctf-writer/writer-internal.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <glib.h>
+#include <uuid/uuid.h>
+
+struct bt_ctf_clock {
+       struct bt_ctf_ref ref_count;
+       GString *name;
+       GString *description;
+       uint64_t frequency;
+       uint64_t precision;
+       uint64_t offset_s;      /* Offset in seconds */
+       uint64_t offset;        /* Offset in ticks */
+       uint64_t time;          /* Current clock value */
+       uuid_t uuid;
+       int absolute;
+       /*
+        * A clock's properties can't be modified once it is added to a stream
+        * class.
+        */
+       int frozen;
+};
+
+BT_HIDDEN
+void bt_ctf_clock_freeze(struct bt_ctf_clock *clock);
+
+BT_HIDDEN
+void bt_ctf_clock_serialize(struct bt_ctf_clock *clock,
+               struct metadata_context *context);
+
+BT_HIDDEN
+uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
+
+#endif /* BABELTRACE_CTF_IR_CLOCK_INTERNAL_H */
diff --git a/include/babeltrace/ctf-ir/clock.h b/include/babeltrace/ctf-ir/clock.h
new file mode 100644 (file)
index 0000000..8558afd
--- /dev/null
@@ -0,0 +1,166 @@
+#ifndef BABELTRACE_CTF_IR_CLOCK_H
+#define BABELTRACE_CTF_IR_CLOCK_H
+
+/*
+ * BabelTrace - CTF IR: Clock
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_clock;
+
+/*
+ * bt_ctf_clock_create: create a clock.
+ *
+ * Allocate a new clock setting its reference count to 1.
+ *
+ * @param name Name of the clock (will be copied).
+ *
+ * Returns an allocated clock on success, NULL on error.
+ */
+extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
+
+/*
+ * bt_ctf_clock_set_description: set a clock's description.
+ *
+ * Set the clock's description. The description appears in the clock's TSDL
+ * meta-data.
+ *
+ * @param clock Clock instance.
+ * @param desc Description of the clock.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
+               const char *desc);
+
+/*
+ * bt_ctf_clock_set_frequency: set a clock's frequency.
+ *
+ * Set the clock's frequency (Hz).
+ *
+ * @param clock Clock instance.
+ * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
+               uint64_t freq);
+
+/*
+ * bt_ctf_clock_set_precision: set a clock's precision.
+ *
+ * Set the clock's precision.
+ *
+ * @param clock Clock instance.
+ * @param precision Clock's precision in clock ticks, defaults to 1.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
+               uint64_t precision);
+
+/*
+ * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
+ *
+ * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
+ * defaults to 0.
+ *
+ * @param clock Clock instance.
+ * @param offset_s Clock's offset in seconds, defaults to 0.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
+               uint64_t offset_s);
+
+
+/*
+ * bt_ctf_clock_set_offset: set a clock's offset in ticks.
+ *
+ * Set the clock's offset in ticks from Epoch + offset_s.
+ *
+ * @param clock Clock instance.
+ * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
+               uint64_t offset);
+
+/*
+ * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
+ *
+ * A clock is absolute if the clock is a global reference across the trace's
+ * other clocks.
+ *
+ * @param clock Clock instance.
+ * @param is_absolute Clock's absolute attribute, defaults to FALSE.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
+               int is_absolute);
+
+/*
+ * bt_ctf_clock_set_time: set a clock's current time value.
+ *
+ * Set the current time in nanoseconds since the clock's origin (offset and
+ * offset_s attributes). The clock's value will be sampled as events are
+ * appended to a stream.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
+
+/*
+ * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
+ * refcount of the clock
+ *
+ * These functions ensure that the clock won't be destroyed when it
+ * is in use. The same number of get and put (plus one extra put to
+ * release the initial reference done at creation) has to be done to
+ * destroy a clock.
+ *
+ * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
+ * the clock is freed.
+ *
+ * @param clock Clock instance.
+ */
+extern void bt_ctf_clock_get(struct bt_ctf_clock *clock);
+extern void bt_ctf_clock_put(struct bt_ctf_clock *clock);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_CLOCK_H */
diff --git a/include/babeltrace/ctf-ir/event-fields-internal.h b/include/babeltrace/ctf-ir/event-fields-internal.h
new file mode 100644 (file)
index 0000000..9f2670d
--- /dev/null
@@ -0,0 +1,100 @@
+#ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H
+#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H
+
+/*
+ * BabelTrace - CTF Writer: Event Fields internal
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/ctf/types.h>
+#include <glib.h>
+
+struct bt_ctf_field {
+       struct bt_ctf_ref ref_count;
+       struct bt_ctf_field_type *type;
+       int payload_set;
+};
+
+struct bt_ctf_field_integer {
+       struct bt_ctf_field parent;
+       struct definition_integer definition;
+};
+
+struct bt_ctf_field_enumeration {
+       struct bt_ctf_field parent;
+       struct bt_ctf_field *payload;
+};
+
+struct bt_ctf_field_floating_point {
+       struct bt_ctf_field parent;
+       struct definition_float definition;
+       struct definition_integer sign, mantissa, exp;
+};
+
+struct bt_ctf_field_structure {
+       struct bt_ctf_field parent;
+       GHashTable *field_name_to_index;
+       GPtrArray *fields; /* Array of pointers to struct bt_ctf_field */
+};
+
+struct bt_ctf_field_variant {
+       struct bt_ctf_field parent;
+       struct bt_ctf_field *tag;
+       struct bt_ctf_field *payload;
+};
+
+struct bt_ctf_field_array {
+       struct bt_ctf_field parent;
+       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
+};
+
+struct bt_ctf_field_sequence {
+       struct bt_ctf_field parent;
+       struct bt_ctf_field *length;
+       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
+};
+
+struct bt_ctf_field_string {
+       struct bt_ctf_field parent;
+       GString *payload;
+};
+
+/*
+ * Set a field's value with an already allocated field instance.
+ */
+BT_HIDDEN
+int bt_ctf_field_structure_set_field(struct bt_ctf_field *structure,
+               const char *name, struct bt_ctf_field *value);
+
+BT_HIDDEN
+int bt_ctf_field_validate(struct bt_ctf_field *field);
+
+BT_HIDDEN
+int bt_ctf_field_serialize(struct bt_ctf_field *field,
+               struct ctf_stream_pos *pos);
+
+#endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H */
diff --git a/include/babeltrace/ctf-ir/event-fields.h b/include/babeltrace/ctf-ir/event-fields.h
new file mode 100644 (file)
index 0000000..1094864
--- /dev/null
@@ -0,0 +1,218 @@
+#ifndef BABELTRACE_CTF_IR_EVENT_FIELDS_H
+#define BABELTRACE_CTF_IR_EVENT_FIELDS_H
+
+/*
+ * BabelTrace - CTF IR: Event Fields
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event_class;
+struct bt_ctf_event;
+struct bt_ctf_field;
+struct bt_ctf_field_type;
+
+/*
+ * bt_ctf_field_create: create an instance of a field.
+ *
+ * Allocate a new field of the type described by the bt_ctf_field_type
+ * structure.The creation of a field sets its reference count to 1.
+ *
+ * @param type Field type to be instanciated.
+ *
+ * Returns an allocated field on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_create(
+               struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_structure_get_field: get a structure's field.
+ *
+ * Get the structure's field corresponding to the provided field name.
+ * bt_ctf_field_put() must be called on the returned value.
+ *
+ * @param structure Structure field instance.
+ * @param name Name of the field in the provided structure.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_structure_get_field(
+               struct bt_ctf_field *structure, const char *name);
+
+/*
+ * bt_ctf_field_array_get_field: get an array's field at position "index".
+ *
+ * Return the array's field at position "index". bt_ctf_field_put() must be
+ * called on the returned value.
+ *
+ * @param array Array field instance.
+ * @param index Position of the array's desired element.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_array_get_field(
+               struct bt_ctf_field *array, uint64_t index);
+
+/*
+ * bt_ctf_field_sequence_set_length: set a sequence's length.
+ *
+ * Set the sequence's length field.
+ *
+ * @param sequence Sequence field instance.
+ * @param length_field Integer field instance indicating the sequence's length.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence,
+               struct bt_ctf_field *length_field);
+
+/*
+ * bt_ctf_field_sequence_get_field: get a sequence's field at position "index".
+ *
+ * Return the sequence's field at position "index". The sequence's length must
+ * have been set prior to calling this function using
+ * bt_ctf_field_sequence_set_length().
+ * bt_ctf_field_put() must be called on the returned value.
+ *
+ * @param array Sequence field instance.
+ * @param index Position of the sequence's desired element.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
+               struct bt_ctf_field *sequence, uint64_t index);
+
+/*
+ * bt_ctf_field_variant_get_field: get a variant's selected field.
+ *
+ * Return the variant's selected field. The "tag" field is the selector enum
+ * field. bt_ctf_field_put() must be called on the returned value.
+ *
+ * @param variant Variant field instance.
+ * @param tag Selector enumeration field.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
+               struct bt_ctf_field *variant, struct bt_ctf_field *tag);
+
+/*
+ * bt_ctf_field_enumeration_get_container: get an enumeration field's container.
+ *
+ * Return the enumeration's underlying container field (an integer).
+ * bt_ctf_field_put() must be called on the returned value.
+ *
+ * @param enumeration Enumeration field instance.
+ *
+ * Returns a field instance on success, NULL on error.
+ */
+extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
+               struct bt_ctf_field *enumeration);
+
+/*
+ * bt_ctf_field_signed_integer_set_value: set a signed integer field's value
+ *
+ * Set a signed integer field's value. The value is checked to make sure it
+ * can be stored in the underlying field.
+ *
+ * @param integer Signed integer field instance.
+ * @param value Signed integer field value.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer,
+               int64_t value);
+
+/*
+ * bt_ctf_field_unsigned_integer_set_value: set unsigned integer field's value
+ *
+ * Set an unsigned integer field's value. The value is checked to make sure it
+ * can be stored in the underlying field.
+ *
+ * @param integer Unsigned integer field instance.
+ * @param value Unsigned integer field value.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer,
+               uint64_t value);
+
+/*
+ * bt_ctf_field_floating_point_set_value: set a floating point field's value
+ *
+ * Set a floating point field's value. The underlying type may not support the
+ * double's full precision.
+ *
+ * @param floating_point Floating point field instance.
+ * @param value Floating point field value.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_floating_point_set_value(
+               struct bt_ctf_field *floating_point,
+               double value);
+
+/*
+ * bt_ctf_field_string_set_value: set a string field's value
+ *
+ * Set a string field's value.
+ *
+ * @param string String field instance.
+ * @param value String field value (will be copied).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string,
+               const char *value);
+
+/*
+ * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
+ * field's reference count.
+ *
+ * These functions ensure that the field won't be destroyed when 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 a field.
+ *
+ * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
+ * the field is freed.
+ *
+ * @param field Field instance.
+ */
+extern void bt_ctf_field_get(struct bt_ctf_field *field);
+extern void bt_ctf_field_put(struct bt_ctf_field *field);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_EVENT_FIELDS_H */
diff --git a/include/babeltrace/ctf-ir/event-internal.h b/include/babeltrace/ctf-ir/event-internal.h
new file mode 100644 (file)
index 0000000..5d02b11
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef BABELTRACE_CTF_IR_EVENT_INTERNAL_H
+#define BABELTRACE_CTF_IR_EVENT_INTERNAL_H
+
+/*
+ * BabelTrace - CTF IR: Event internal
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/event-types.h>
+#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/ctf/types.h>
+#include <glib.h>
+
+struct bt_ctf_event_class {
+       struct bt_ctf_ref ref_count;
+       GQuark name;
+       int id_set;
+       uint32_t id;
+       int stream_id_set;
+       uint32_t stream_id;
+       /* Structure type containing the event's context */
+       struct bt_ctf_field_type *context;
+       /* Structure type containing the event's fields */
+       struct bt_ctf_field_type *fields;
+       int frozen;
+};
+
+struct bt_ctf_event {
+       struct bt_ctf_ref ref_count;
+       uint64_t timestamp;
+       struct bt_ctf_event_class *event_class;
+       struct bt_ctf_field *context_payload;
+       struct bt_ctf_field *fields_payload;
+};
+
+BT_HIDDEN
+void bt_ctf_event_class_freeze(struct bt_ctf_event_class *event_class);
+
+BT_HIDDEN
+int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class,
+               uint32_t id);
+
+BT_HIDDEN
+uint32_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class);
+
+BT_HIDDEN
+int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class,
+               uint32_t id);
+
+BT_HIDDEN
+int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
+               struct metadata_context *context);
+
+BT_HIDDEN
+int bt_ctf_event_validate(struct bt_ctf_event *event);
+
+BT_HIDDEN
+int bt_ctf_event_serialize(struct bt_ctf_event *event,
+               struct ctf_stream_pos *pos);
+
+BT_HIDDEN
+int bt_ctf_event_set_timestamp(struct bt_ctf_event *event, uint64_t timestamp);
+
+BT_HIDDEN
+uint64_t bt_ctf_event_get_timestamp(struct bt_ctf_event *event);
+
+#endif /* BABELTRACE_CTF_IR_EVENT_INTERNAL_H */
diff --git a/include/babeltrace/ctf-ir/event-types-internal.h b/include/babeltrace/ctf-ir/event-types-internal.h
new file mode 100644 (file)
index 0000000..27e4a17
--- /dev/null
@@ -0,0 +1,153 @@
+#ifndef BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H
+#define BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H
+
+/*
+ * BabelTrace - CTF IR: Event types internal
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-writer/event-types.h>
+#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/ctf-writer/writer.h>
+#include <babeltrace/ctf-writer/writer-internal.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/types.h>
+#include <babeltrace/ctf/events.h>
+#include <glib.h>
+
+typedef void(*type_freeze_func)(struct bt_ctf_field_type *);
+typedef int(*type_serialize_func)(struct bt_ctf_field_type *,
+               struct metadata_context *);
+
+struct bt_ctf_field_type {
+       struct bt_ctf_ref ref_count;
+       struct bt_declaration *declaration;
+       type_freeze_func freeze;
+       type_serialize_func serialize;
+       /*
+        * A type can't be modified once it is added to an event or after a
+        * a field has been instanciated from it.
+        */
+       int frozen;
+};
+
+struct bt_ctf_field_type_integer {
+       struct bt_ctf_field_type parent;
+       struct declaration_integer declaration;
+};
+
+struct enumeration_mapping {
+       int64_t range_start;
+       int64_t range_end;
+       GQuark string;
+};
+
+struct bt_ctf_field_type_enumeration {
+       struct bt_ctf_field_type parent;
+       struct bt_ctf_field_type *container;
+       GPtrArray *entries; /* Array of pointers to struct enum_mapping */
+       struct declaration_enum declaration;
+};
+
+struct bt_ctf_field_type_floating_point {
+       struct bt_ctf_field_type parent;
+       struct declaration_float declaration;
+       struct declaration_integer sign;
+       struct declaration_integer mantissa;
+       struct declaration_integer exp;
+};
+
+struct structure_field {
+       GQuark name;
+       struct bt_ctf_field_type *type;
+};
+
+struct bt_ctf_field_type_structure {
+       struct bt_ctf_field_type parent;
+       GHashTable *field_name_to_index;
+       GPtrArray *fields; /* Array of pointers to struct structure_field */
+       struct declaration_enum declaration;
+};
+
+struct bt_ctf_field_type_variant {
+       struct bt_ctf_field_type parent;
+       GString *tag_name;
+       struct bt_ctf_field_type_enumeration *tag;
+       GHashTable *field_name_to_index;
+       GPtrArray *fields; /* Array of pointers to struct structure_field */
+       struct declaration_variant declaration;
+};
+
+struct bt_ctf_field_type_array {
+       struct bt_ctf_field_type parent;
+       struct bt_ctf_field_type *element_type;
+       unsigned int length; /* Number of elements */
+       struct declaration_array declaration;
+};
+
+struct bt_ctf_field_type_sequence {
+       struct bt_ctf_field_type parent;
+       struct bt_ctf_field_type *element_type;
+       GString *length_field_name;
+       struct declaration_sequence declaration;
+};
+
+struct bt_ctf_field_type_string {
+       struct bt_ctf_field_type parent;
+       struct declaration_string declaration;
+};
+
+BT_HIDDEN
+void bt_ctf_field_type_freeze(struct bt_ctf_field_type *type);
+
+BT_HIDDEN
+enum ctf_type_id bt_ctf_field_type_get_type_id(
+               struct bt_ctf_field_type *type);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_structure_get_type(
+               struct bt_ctf_field_type_structure *structure,
+               const char *name);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(
+               struct bt_ctf_field_type_array *array);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(
+               struct bt_ctf_field_type_sequence *sequence);
+
+BT_HIDDEN
+struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type(
+               struct bt_ctf_field_type_variant *variant, int64_t tag_value);
+
+BT_HIDDEN
+int bt_ctf_field_type_serialize(struct bt_ctf_field_type *type,
+               struct metadata_context *context);
+
+BT_HIDDEN
+int bt_ctf_field_type_validate(struct bt_ctf_field_type *type);
+
+#endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
diff --git a/include/babeltrace/ctf-ir/event-types.h b/include/babeltrace/ctf-ir/event-types.h
new file mode 100644 (file)
index 0000000..0c0a04e
--- /dev/null
@@ -0,0 +1,359 @@
+#ifndef BABELTRACE_CTF_IR_EVENT_TYPES_H
+#define BABELTRACE_CTF_IR_EVENT_TYPES_H
+
+/*
+ * BabelTrace - CTF IR: Event Types
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#include <babeltrace/ctf/events.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event_class;
+struct bt_ctf_event;
+struct bt_ctf_field_type;
+
+enum bt_ctf_integer_base {
+       BT_CTF_INTEGER_BASE_UNKNOWN = -1,
+       BT_CTF_INTEGER_BASE_BINARY = 2,
+       BT_CTF_INTEGER_BASE_OCTAL = 8,
+       BT_CTF_INTEGER_BASE_DECIMAL = 10,
+       BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
+};
+
+enum bt_ctf_byte_order {
+       BT_CTF_BYTE_ORDER_NATIVE = 0,
+       BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
+       BT_CTF_BYTE_ORDER_BIG_ENDIAN,
+       BT_CTF_BYTE_ORDER_NETWORK,
+};
+
+/*
+ * bt_ctf_field_type_integer_create: create an integer field type.
+ *
+ * Allocate a new integer field type of the given size. The creation of a field
+ * type sets its reference count to 1.
+ *
+ * @param size Integer field type size/length in bits.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
+               unsigned int size);
+
+/*
+ * bt_ctf_field_type_integer_set_signed: set an integer type's signedness.
+ *
+ * Set an integer type's signedness attribute.
+ *
+ * @param integer Integer type.
+ * @param is_signed Integer's signedness, defaults to FALSE.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_integer_set_signed(
+               struct bt_ctf_field_type *integer, int is_signed);
+
+/*
+ * bt_ctf_field_type_integer_set_base: set an integer type's base.
+ *
+ * Set an integer type's base used to pretty-print the resulting trace.
+ *
+ * @param integer Integer type.
+ * @param base Integer base, defaults to BT_CTF_INTEGER_BASE_DECIMAL.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_integer_set_base(
+               struct bt_ctf_field_type *integer,
+               enum bt_ctf_integer_base base);
+
+/*
+ * bt_ctf_field_type_integer_set_encoding: set an integer type's encoding.
+ *
+ * An integer encoding may be set to signal that the integer must be printed as
+ * a text character.
+ *
+ * @param integer Integer type.
+ * @param encoding Integer output encoding, defaults to CTF_STRING_ENCODING_NONE
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_integer_set_encoding(
+               struct bt_ctf_field_type *integer,
+               enum ctf_string_encoding encoding);
+
+/*
+ * bt_ctf_field_type_enumeration_create: create an enumeration field type.
+ *
+ * Allocate a new enumeration field type with the given underlying type. The
+ * creation of a field type sets its reference count to 1.
+ * The resulting enumeration will share the integer_container_type's ownership
+ * by increasing its reference count.
+ *
+ * @param integer_container_type Underlying integer type of the enumeration
+ *     type.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
+               struct bt_ctf_field_type *integer_container_type);
+
+/*
+ * bt_ctf_field_type_enumeration_add_mapping: add an enumeration mapping.
+ *
+ * Add a mapping to the enumeration. The range's values are inclusive.
+ *
+ * @param enumeration Enumeration type.
+ * @param string Enumeration mapping name (will be copied).
+ * @param range_start Enumeration mapping range start.
+ * @param range_end Enumeration mapping range end.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_enumeration_add_mapping(
+               struct bt_ctf_field_type *enumeration, const char *string,
+               int64_t range_start, int64_t range_end);
+
+/*
+ * bt_ctf_field_type_floating_point_create: create a floating point field type.
+ *
+ * Allocate a new floating point field type. The creation of a field type sets
+ * its reference count to 1.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
+
+/*
+ * bt_ctf_field_type_floating_point_set_exponent_digits: set exponent digit
+ * count.
+ *
+ * Set the number of exponent digits to use to store the floating point field.
+ * The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG.
+ *
+ * @param floating_point Floating point type.
+ * @param exponent_digits Number of digits to allocate to the exponent (defaults
+ *     to FLT_EXP_DIG).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_floating_point_set_exponent_digits(
+               struct bt_ctf_field_type *floating_point,
+               unsigned int exponent_digits);
+
+/*
+ * bt_ctf_field_type_floating_point_set_mantissa_digits: set mantissa digit
+ * count.
+ *
+ * Set the number of mantissa digits to use to store the floating point field.
+ * The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG.
+ *
+ * @param floating_point Floating point type.
+ * @param mantissa_digits Number of digits to allocate to the mantissa (defaults
+ *     to FLT_MANT_DIG).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
+               struct bt_ctf_field_type *floating_point,
+               unsigned int mantissa_digits);
+
+/*
+ * bt_ctf_field_type_structure_create: create a structure field type.
+ *
+ * Allocate a new structure field type. The creation of a field type sets
+ * its reference count to 1.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
+
+/*
+ * bt_ctf_field_type_structure_add_field: add a field to a structure.
+ *
+ * Add a field of type "field_type" to the structure. The structure will share
+ * field_type's ownership by increasing its reference count.
+ *
+ * @param structure Structure type.
+ * @param field_type Type of the field to add to the structure type.
+ * @param field_name Name of the structure's new field (will be copied).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_structure_add_field(
+               struct bt_ctf_field_type *structure,
+               struct bt_ctf_field_type *field_type,
+               const char *field_name);
+
+/*
+ * bt_ctf_field_type_variant_create: create a variant field type.
+ *
+ * Allocate a new variant field type. The creation of a field type sets
+ * its reference count to 1. tag_name must be the name of an enumeration
+ * field declared in the same scope as this variant.
+ *
+ * @param enum_tag Type of the variant's tag/selector (must be an enumeration).
+ * @param tag_name Name of the variant's tag/selector field (will be copied).
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
+               struct bt_ctf_field_type *enum_tag,
+               const char *tag_name);
+
+/*
+ * bt_ctf_field_type_variant_add_field: add a field to a variant.
+ *
+ * Add a field of type "field_type" to the variant.The variant will share
+ * field_type's ownership by increasing its reference count. The "field_name"
+ * will be copied. field_name must match a mapping in the tag/selector
+ * enumeration.
+ *
+ * @param variant Variant type.
+ * @param field_type Type of the variant type's new field.
+ * @param field_name Name of the variant type's new field (will be copied).
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_variant_add_field(
+               struct bt_ctf_field_type *variant,
+               struct bt_ctf_field_type *field_type,
+               const char *field_name);
+
+/*
+ * bt_ctf_field_type_array_create: create an array field type.
+ *
+ * Allocate a new array field type. The creation of a field type sets
+ * its reference count to 1.
+ *
+ * @param element_type Array's element type.
+ * @oaram length Array type's length.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
+               struct bt_ctf_field_type *element_type,
+               unsigned int length);
+
+/*
+ * bt_ctf_field_type_sequence_create: create a sequence field type.
+ *
+ * Allocate a new sequence field type. The creation of a field type sets
+ * its reference count to 1. "length_field_name" must match an integer field
+ * declared in the same scope.
+ *
+ * @param element_type Sequence's element type.
+ * @param length_field_name Name of the sequence's length field (will be
+ *     copied).
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
+               struct bt_ctf_field_type *element_type,
+               const char *length_field_name);
+
+/*
+ * bt_ctf_field_type_string_create: create a string field type.
+ *
+ * Allocate a new string field type. The creation of a field type sets
+ * its reference count to 1.
+ *
+ * Returns an allocated field type on success, NULL on error.
+ */
+extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
+
+/*
+ * bt_ctf_field_type_string_set_encoding: set a string type's encoding.
+ *
+ * Set the string type's encoding.
+ *
+ * @param string String type.
+ * @param encoding String field encoding, default CTF_STRING_ENCODING_ASCII.
+ *     Valid values are CTF_STRING_ENCODING_ASCII and CTF_STRING_ENCODING_UTF8.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_string_set_encoding(
+               struct bt_ctf_field_type *string,
+               enum ctf_string_encoding encoding);
+
+/*
+ * bt_ctf_field_type_set_alignment: set a field type's alignment.
+ *
+ * Set the field type's alignment.
+ *
+ * @param type Field type.
+ * @param alignment Type's alignment. Defaults to 1 (bit-aligned). However,
+ *     some types, such as structures and string, may impose other alignment
+ *     constraints.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type,
+               unsigned int alignment);
+
+/*
+ * bt_ctf_field_type_set_byte_order: set a field type's byte order.
+ *
+ * Set the field type's byte order.
+ *
+ * @param type Field type.
+ * @param byte_order Field type's byte order. Defaults to
+ * BT_CTF_BYTE_ORDER_NATIVE, the host machine's endianness.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type,
+               enum bt_ctf_byte_order byte_order);
+
+/*
+ * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
+ * the field type's reference count.
+ *
+ * These functions ensure that the field type 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 a field type.
+ *
+ * When the field type's reference count is decremented to 0 by a
+ * bt_ctf_field_type_put, the field type is freed.
+ *
+ * @param type Field type.
+ */
+extern void bt_ctf_field_type_get(struct bt_ctf_field_type *type);
+extern void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_EVENT_TYPES_H */
diff --git a/include/babeltrace/ctf-ir/event.h b/include/babeltrace/ctf-ir/event.h
new file mode 100644 (file)
index 0000000..ca0d638
--- /dev/null
@@ -0,0 +1,154 @@
+#ifndef BABELTRACE_CTF_IR_EVENT_H
+#define BABELTRACE_CTF_IR_EVENT_H
+
+/*
+ * BabelTrace - CTF IR: Event
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event_class;
+struct bt_ctf_event;
+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);
+
+/*
+ * 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);
+
+/*
+ * 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);
+
+/*
+ * 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 int bt_ctf_event_set_payload(struct bt_ctf_event *event,
+               const char *name,
+               struct bt_ctf_field *value);
+
+/*
+ * 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,
+               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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_EVENT_H */
diff --git a/include/babeltrace/ctf-ir/stream-class-internal.h b/include/babeltrace/ctf-ir/stream-class-internal.h
new file mode 100644 (file)
index 0000000..0a1420d
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H
+#define BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H
+
+/*
+ * BabelTrace - CTF IR: Stream class internal
+ *
+ * Copyright 2013 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/ctf-writer/ref-internal.h>
+#include <babeltrace/ctf-writer/clock.h>
+#include <babeltrace/ctf-writer/event-fields.h>
+#include <babeltrace/ctf-writer/event-types.h>
+#include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/ctf/types.h>
+#include <glib.h>
+
+struct bt_ctf_stream_class {
+       struct bt_ctf_ref ref_count;
+       GString *name;
+       struct bt_ctf_clock *clock;
+       GPtrArray *event_classes; /* Array of pointers to bt_ctf_event_class */
+       int id_set;
+       uint32_t id;
+       uint32_t next_event_id;
+       uint32_t next_stream_id;
+       struct bt_ctf_field_type *event_header_type;
+       struct bt_ctf_field *event_header;
+       struct bt_ctf_field_type *packet_context_type;
+       struct bt_ctf_field *packet_context;
+       struct bt_ctf_field_type *event_context_type;
+       struct bt_ctf_field *event_context;
+       int frozen;
+};
+
+BT_HIDDEN
+void bt_ctf_stream_class_freeze(struct bt_ctf_stream_class *stream_class);
+
+BT_HIDDEN
+int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
+               uint32_t id);
+
+BT_HIDDEN
+int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
+               struct metadata_context *context);
+
+BT_HIDDEN
+int bt_ctf_stream_class_set_byte_order(struct bt_ctf_stream_class *stream_class,
+               enum bt_ctf_byte_order byte_order);
+
+#endif /* BABELTRACE_CTF_IR_STREAM_CLASS_INTERNAL_H */
diff --git a/include/babeltrace/ctf-ir/stream-class.h b/include/babeltrace/ctf-ir/stream-class.h
new file mode 100644 (file)
index 0000000..2e2f3fb
--- /dev/null
@@ -0,0 +1,107 @@
+#ifndef BABELTRACE_CTF_IR_STREAM_CLASS_H
+#define BABELTRACE_CTF_IR_STREAM_CLASS_H
+
+/*
+ * BabelTrace - CTF IR: Stream Class
+ *
+ * Copyright 2014 EfficiOS Inc.
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * The Common Trace Format (CTF) Specification is available at
+ * http://www.efficios.com/ctf
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_ctf_event_class;
+struct bt_ctf_stream_class;
+struct bt_ctf_clock;
+
+/*
+ * bt_ctf_stream_class_create: create a stream class.
+ *
+ * Allocate a new stream class of the given name. The creation of an event class
+ * sets its reference count to 1.
+ *
+ * @param name Stream name.
+ *
+ * Returns an allocated stream class on success, NULL on error.
+ */
+extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
+
+/*
+ * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
+ *
+ * Assign a clock to a stream class. This clock will be sampled each time an
+ * event is appended to an instance of this stream class.
+ *
+ * @param stream_class Stream class.
+ * @param clock Clock to assign to the provided stream class.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_class_set_clock(
+               struct bt_ctf_stream_class *stream_class,
+               struct bt_ctf_clock *clock);
+
+/*
+ * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
+ *
+ * Add an event class to a stream class. New events can be added even after a
+ * stream has beem instanciated and events have been appended. However, a stream
+ * will not accept events of a class that has not been registered beforehand.
+ * The stream class will share the ownership of "event_class" by incrementing
+ * its reference count.
+ *
+ * @param stream_class Stream class.
+ * @param event_class Event class to add to the provided stream class.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_stream_class_add_event_class(
+               struct bt_ctf_stream_class *stream_class,
+               struct bt_ctf_event_class *event_class);
+
+/*
+ * bt_ctf_stream_class_get and bt_ctf_stream_class_put: increment and
+ * decrement the stream class' reference count.
+ *
+ * These functions ensure that the stream 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 a stream class.
+ *
+ * When the stream class' reference count is decremented to 0 by a
+ * bt_ctf_stream_class_put, the stream class is freed.
+ *
+ * @param stream_class Stream class.
+ */
+extern void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
+extern void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_CTF_IR_STREAM_CLASS_H */
diff --git a/include/babeltrace/ctf-writer/clock-internal.h b/include/babeltrace/ctf-writer/clock-internal.h
deleted file mode 100644 (file)
index c60e5c0..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H
-
-/*
- * BabelTrace - CTF Writer: Clock internal
- *
- * Copyright 2013 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/ctf-writer/ref-internal.h>
-#include <babeltrace/ctf-writer/clock.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
-#include <uuid/uuid.h>
-
-struct bt_ctf_clock {
-       struct bt_ctf_ref ref_count;
-       GString *name;
-       GString *description;
-       uint64_t frequency;
-       uint64_t precision;
-       uint64_t offset_s;      /* Offset in seconds */
-       uint64_t offset;        /* Offset in ticks */
-       uint64_t time;          /* Current clock value */
-       uuid_t uuid;
-       int absolute;
-       /*
-        * A clock's properties can't be modified once it is added to a stream
-        * class.
-        */
-       int frozen;
-};
-
-BT_HIDDEN
-void bt_ctf_clock_freeze(struct bt_ctf_clock *clock);
-
-BT_HIDDEN
-void bt_ctf_clock_serialize(struct bt_ctf_clock *clock,
-               struct metadata_context *context);
-
-BT_HIDDEN
-uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock);
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_INTERNAL_H */
index 7cfc073f741b5d8e3d495a975e66ce481a969301..672cb0e7e14a20d3759f39f9caf68b4a8b65b15c 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef BABELTRACE_CTF_WRITER_CLOCK_H
-#define BABELTRACE_CTF_WRITER_CLOCK_H
-
 /*
  * BabelTrace - CTF Writer: Clock
  *
  * http://www.efficios.com/ctf
  */
 
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_clock;
-
-/*
- * bt_ctf_clock_create: create a clock.
- *
- * Allocate a new clock setting its reference count to 1.
- *
- * @param name Name of the clock (will be copied).
- *
- * Returns an allocated clock on success, NULL on error.
- */
-extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
-
-/*
- * bt_ctf_clock_set_description: set a clock's description.
- *
- * Set the clock's description. The description appears in the clock's TSDL
- * meta-data.
- *
- * @param clock Clock instance.
- * @param desc Description of the clock.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
-               const char *desc);
-
-/*
- * bt_ctf_clock_set_frequency: set a clock's frequency.
- *
- * Set the clock's frequency (Hz).
- *
- * @param clock Clock instance.
- * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
-               uint64_t freq);
-
-/*
- * bt_ctf_clock_set_precision: set a clock's precision.
- *
- * Set the clock's precision.
- *
- * @param clock Clock instance.
- * @param precision Clock's precision in clock ticks, defaults to 1.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
-               uint64_t precision);
-
-/*
- * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
- *
- * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
- * defaults to 0.
- *
- * @param clock Clock instance.
- * @param offset_s Clock's offset in seconds, defaults to 0.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
-               uint64_t offset_s);
-
-
-/*
- * bt_ctf_clock_set_offset: set a clock's offset in ticks.
- *
- * Set the clock's offset in ticks from Epoch + offset_s.
- *
- * @param clock Clock instance.
- * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
-               uint64_t offset);
-
-/*
- * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
- *
- * A clock is absolute if the clock is a global reference across the trace's
- * other clocks.
- *
- * @param clock Clock instance.
- * @param is_absolute Clock's absolute attribute, defaults to FALSE.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
-               int is_absolute);
-
-/*
- * bt_ctf_clock_set_time: set a clock's current time value.
- *
- * Set the current time in nanoseconds since the clock's origin (offset and
- * offset_s attributes). The clock's value will be sampled as events are
- * appended to a stream.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, uint64_t time);
-
-/*
- * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the
- * refcount of the clock
- *
- * These functions ensure that the clock won't be destroyed when it
- * is in use. The same number of get and put (plus one extra put to
- * release the initial reference done at creation) has to be done to
- * destroy a clock.
- *
- * When the clock refcount is decremented to 0 by a bt_ctf_clock_put,
- * the clock is freed.
- *
- * @param clock Clock instance.
- */
-extern void bt_ctf_clock_get(struct bt_ctf_clock *clock);
-extern void bt_ctf_clock_put(struct bt_ctf_clock *clock);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_CLOCK_H */
+#include <babeltrace/ctf-ir/clock.h>
diff --git a/include/babeltrace/ctf-writer/event-fields-internal.h b/include/babeltrace/ctf-writer/event-fields-internal.h
deleted file mode 100644 (file)
index 9f2670d..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H
-
-/*
- * BabelTrace - CTF Writer: Event Fields internal
- *
- * Copyright 2013 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/ctf-writer/ref-internal.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf/types.h>
-#include <glib.h>
-
-struct bt_ctf_field {
-       struct bt_ctf_ref ref_count;
-       struct bt_ctf_field_type *type;
-       int payload_set;
-};
-
-struct bt_ctf_field_integer {
-       struct bt_ctf_field parent;
-       struct definition_integer definition;
-};
-
-struct bt_ctf_field_enumeration {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *payload;
-};
-
-struct bt_ctf_field_floating_point {
-       struct bt_ctf_field parent;
-       struct definition_float definition;
-       struct definition_integer sign, mantissa, exp;
-};
-
-struct bt_ctf_field_structure {
-       struct bt_ctf_field parent;
-       GHashTable *field_name_to_index;
-       GPtrArray *fields; /* Array of pointers to struct bt_ctf_field */
-};
-
-struct bt_ctf_field_variant {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *tag;
-       struct bt_ctf_field *payload;
-};
-
-struct bt_ctf_field_array {
-       struct bt_ctf_field parent;
-       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
-};
-
-struct bt_ctf_field_sequence {
-       struct bt_ctf_field parent;
-       struct bt_ctf_field *length;
-       GPtrArray *elements; /* Array of pointers to struct bt_ctf_field */
-};
-
-struct bt_ctf_field_string {
-       struct bt_ctf_field parent;
-       GString *payload;
-};
-
-/*
- * Set a field's value with an already allocated field instance.
- */
-BT_HIDDEN
-int bt_ctf_field_structure_set_field(struct bt_ctf_field *structure,
-               const char *name, struct bt_ctf_field *value);
-
-BT_HIDDEN
-int bt_ctf_field_validate(struct bt_ctf_field *field);
-
-BT_HIDDEN
-int bt_ctf_field_serialize(struct bt_ctf_field *field,
-               struct ctf_stream_pos *pos);
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_INTERNAL_H */
index 8d3190b433303206ff489cc187d4ffaebb0fc8e9..f1e532efd2f7429fd60e531620048ce9367cb6f6 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
-#define BABELTRACE_CTF_WRITER_EVENT_FIELDS_H
-
 /*
  * BabelTrace - CTF Writer: Event Fields
  *
  * http://www.efficios.com/ctf
  */
 
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event_class;
-struct bt_ctf_event;
-struct bt_ctf_field;
-struct bt_ctf_field_type;
-
-/*
- * bt_ctf_field_create: create an instance of a field.
- *
- * Allocate a new field of the type described by the bt_ctf_field_type
- * structure.The creation of a field sets its reference count to 1.
- *
- * @param type Field type to be instanciated.
- *
- * Returns an allocated field on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_create(
-               struct bt_ctf_field_type *type);
-
-/*
- * bt_ctf_field_structure_get_field: get a structure's field.
- *
- * Get the structure's field corresponding to the provided field name.
- * bt_ctf_field_put() must be called on the returned value.
- *
- * @param structure Structure field instance.
- * @param name Name of the field in the provided structure.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_structure_get_field(
-               struct bt_ctf_field *structure, const char *name);
-
-/*
- * bt_ctf_field_array_get_field: get an array's field at position "index".
- *
- * Return the array's field at position "index". bt_ctf_field_put() must be
- * called on the returned value.
- *
- * @param array Array field instance.
- * @param index Position of the array's desired element.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_array_get_field(
-               struct bt_ctf_field *array, uint64_t index);
-
-/*
- * bt_ctf_field_sequence_set_length: set a sequence's length.
- *
- * Set the sequence's length field.
- *
- * @param sequence Sequence field instance.
- * @param length_field Integer field instance indicating the sequence's length.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence,
-               struct bt_ctf_field *length_field);
-
-/*
- * bt_ctf_field_sequence_get_field: get a sequence's field at position "index".
- *
- * Return the sequence's field at position "index". The sequence's length must
- * have been set prior to calling this function using
- * bt_ctf_field_sequence_set_length().
- * bt_ctf_field_put() must be called on the returned value.
- *
- * @param array Sequence field instance.
- * @param index Position of the sequence's desired element.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
-               struct bt_ctf_field *sequence, uint64_t index);
-
-/*
- * bt_ctf_field_variant_get_field: get a variant's selected field.
- *
- * Return the variant's selected field. The "tag" field is the selector enum
- * field. bt_ctf_field_put() must be called on the returned value.
- *
- * @param variant Variant field instance.
- * @param tag Selector enumeration field.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
-               struct bt_ctf_field *variant, struct bt_ctf_field *tag);
-
-/*
- * bt_ctf_field_enumeration_get_container: get an enumeration field's container.
- *
- * Return the enumeration's underlying container field (an integer).
- * bt_ctf_field_put() must be called on the returned value.
- *
- * @param enumeration Enumeration field instance.
- *
- * Returns a field instance on success, NULL on error.
- */
-extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
-               struct bt_ctf_field *enumeration);
-
-/*
- * bt_ctf_field_signed_integer_set_value: set a signed integer field's value
- *
- * Set a signed integer field's value. The value is checked to make sure it
- * can be stored in the underlying field.
- *
- * @param integer Signed integer field instance.
- * @param value Signed integer field value.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_signed_integer_set_value(struct bt_ctf_field *integer,
-               int64_t value);
-
-/*
- * bt_ctf_field_unsigned_integer_set_value: set unsigned integer field's value
- *
- * Set an unsigned integer field's value. The value is checked to make sure it
- * can be stored in the underlying field.
- *
- * @param integer Unsigned integer field instance.
- * @param value Unsigned integer field value.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_unsigned_integer_set_value(struct bt_ctf_field *integer,
-               uint64_t value);
-
-/*
- * bt_ctf_field_floating_point_set_value: set a floating point field's value
- *
- * Set a floating point field's value. The underlying type may not support the
- * double's full precision.
- *
- * @param floating_point Floating point field instance.
- * @param value Floating point field value.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_floating_point_set_value(
-               struct bt_ctf_field *floating_point,
-               double value);
-
-/*
- * bt_ctf_field_string_set_value: set a string field's value
- *
- * Set a string field's value.
- *
- * @param string String field instance.
- * @param value String field value (will be copied).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string,
-               const char *value);
-
-/*
- * bt_ctf_field_get and bt_ctf_field_put: increment and decrement the
- * field's reference count.
- *
- * These functions ensure that the field won't be destroyed when 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 a field.
- *
- * When the field's reference count is decremented to 0 by a bt_ctf_field_put,
- * the field is freed.
- *
- * @param field Field instance.
- */
-extern void bt_ctf_field_get(struct bt_ctf_field *field);
-extern void bt_ctf_field_put(struct bt_ctf_field *field);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_FIELDS_H */
+#include <babeltrace/ctf-ir/event-fields.h>
diff --git a/include/babeltrace/ctf-writer/event-internal.h b/include/babeltrace/ctf-writer/event-internal.h
deleted file mode 100644 (file)
index b84c3dd..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H
-
-/*
- * BabelTrace - CTF Writer: Event internal
- *
- * Copyright 2013 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/ctf-writer/ref-internal.h>
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/ctf/types.h>
-#include <glib.h>
-
-struct bt_ctf_event_class {
-       struct bt_ctf_ref ref_count;
-       GQuark name;
-       int id_set;
-       uint32_t id;
-       int stream_id_set;
-       uint32_t stream_id;
-       /* Structure type containing the event's context */
-       struct bt_ctf_field_type *context;
-       /* Structure type containing the event's fields */
-       struct bt_ctf_field_type *fields;
-       int frozen;
-};
-
-struct bt_ctf_event {
-       struct bt_ctf_ref ref_count;
-       uint64_t timestamp;
-       struct bt_ctf_event_class *event_class;
-       struct bt_ctf_field *context_payload;
-       struct bt_ctf_field *fields_payload;
-};
-
-BT_HIDDEN
-void bt_ctf_event_class_freeze(struct bt_ctf_event_class *event_class);
-
-BT_HIDDEN
-int bt_ctf_event_class_set_id(struct bt_ctf_event_class *event_class,
-               uint32_t id);
-
-BT_HIDDEN
-uint32_t bt_ctf_event_class_get_id(struct bt_ctf_event_class *event_class);
-
-BT_HIDDEN
-int bt_ctf_event_class_set_stream_id(struct bt_ctf_event_class *event_class,
-               uint32_t id);
-
-BT_HIDDEN
-int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
-               struct metadata_context *context);
-
-BT_HIDDEN
-int bt_ctf_event_validate(struct bt_ctf_event *event);
-
-BT_HIDDEN
-int bt_ctf_event_serialize(struct bt_ctf_event *event,
-               struct ctf_stream_pos *pos);
-
-BT_HIDDEN
-int bt_ctf_event_set_timestamp(struct bt_ctf_event *event, uint64_t timestamp);
-
-BT_HIDDEN
-uint64_t bt_ctf_event_get_timestamp(struct bt_ctf_event *event);
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_INTERNAL_H */
diff --git a/include/babeltrace/ctf-writer/event-types-internal.h b/include/babeltrace/ctf-writer/event-types-internal.h
deleted file mode 100644 (file)
index a937c78..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_TYPES_INTERNAL_H
-#define BABELTRACE_CTF_WRITER_EVENT_TYPES_INTERNAL_H
-
-/*
- * BabelTrace - CTF Writer: Event types internal
- *
- * Copyright 2013 EfficiOS Inc.
- *
- * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <babeltrace/ctf-writer/event-types.h>
-#include <babeltrace/ctf-writer/ref-internal.h>
-#include <babeltrace/ctf-writer/event-fields.h>
-#include <babeltrace/ctf-writer/writer.h>
-#include <babeltrace/ctf-writer/writer-internal.h>
-#include <babeltrace/babeltrace-internal.h>
-#include <babeltrace/types.h>
-#include <babeltrace/ctf/events.h>
-#include <glib.h>
-
-typedef void(*type_freeze_func)(struct bt_ctf_field_type *);
-typedef int(*type_serialize_func)(struct bt_ctf_field_type *,
-               struct metadata_context *);
-
-struct bt_ctf_field_type {
-       struct bt_ctf_ref ref_count;
-       struct bt_declaration *declaration;
-       type_freeze_func freeze;
-       type_serialize_func serialize;
-       /*
-        * A type can't be modified once it is added to an event or after a
-        * a field has been instanciated from it.
-        */
-       int frozen;
-};
-
-struct bt_ctf_field_type_integer {
-       struct bt_ctf_field_type parent;
-       struct declaration_integer declaration;
-};
-
-struct enumeration_mapping {
-       int64_t range_start;
-       int64_t range_end;
-       GQuark string;
-};
-
-struct bt_ctf_field_type_enumeration {
-       struct bt_ctf_field_type parent;
-       struct bt_ctf_field_type *container;
-       GPtrArray *entries; /* Array of pointers to struct enum_mapping */
-       struct declaration_enum declaration;
-};
-
-struct bt_ctf_field_type_floating_point {
-       struct bt_ctf_field_type parent;
-       struct declaration_float declaration;
-       struct declaration_integer sign;
-       struct declaration_integer mantissa;
-       struct declaration_integer exp;
-};
-
-struct structure_field {
-       GQuark name;
-       struct bt_ctf_field_type *type;
-};
-
-struct bt_ctf_field_type_structure {
-       struct bt_ctf_field_type parent;
-       GHashTable *field_name_to_index;
-       GPtrArray *fields; /* Array of pointers to struct structure_field */
-       struct declaration_enum declaration;
-};
-
-struct bt_ctf_field_type_variant {
-       struct bt_ctf_field_type parent;
-       GString *tag_name;
-       struct bt_ctf_field_type_enumeration *tag;
-       GHashTable *field_name_to_index;
-       GPtrArray *fields; /* Array of pointers to struct structure_field */
-       struct declaration_variant declaration;
-};
-
-struct bt_ctf_field_type_array {
-       struct bt_ctf_field_type parent;
-       struct bt_ctf_field_type *element_type;
-       unsigned int length; /* Number of elements */
-       struct declaration_array declaration;
-};
-
-struct bt_ctf_field_type_sequence {
-       struct bt_ctf_field_type parent;
-       struct bt_ctf_field_type *element_type;
-       GString *length_field_name;
-       struct declaration_sequence declaration;
-};
-
-struct bt_ctf_field_type_string {
-       struct bt_ctf_field_type parent;
-       struct declaration_string declaration;
-};
-
-BT_HIDDEN
-void bt_ctf_field_type_freeze(struct bt_ctf_field_type *type);
-
-BT_HIDDEN
-enum ctf_type_id bt_ctf_field_type_get_type_id(
-               struct bt_ctf_field_type *type);
-
-BT_HIDDEN
-struct bt_ctf_field_type *bt_ctf_field_type_structure_get_type(
-               struct bt_ctf_field_type_structure *structure,
-               const char *name);
-
-BT_HIDDEN
-struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(
-               struct bt_ctf_field_type_array *array);
-
-BT_HIDDEN
-struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(
-               struct bt_ctf_field_type_sequence *sequence);
-
-BT_HIDDEN
-struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type(
-               struct bt_ctf_field_type_variant *variant, int64_t tag_value);
-
-BT_HIDDEN
-int bt_ctf_field_type_serialize(struct bt_ctf_field_type *type,
-               struct metadata_context *context);
-
-BT_HIDDEN
-int bt_ctf_field_type_validate(struct bt_ctf_field_type *type);
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_TYPES_INTERNAL_H */
index cf43ed61ccb68651ddc11880dc515a2bdbb6576f..abad28c56928b6fdcf9f8b38a44947723c44a885 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_TYPES_H
-#define BABELTRACE_CTF_WRITER_EVENT_TYPES_H
-
 /*
  * BabelTrace - CTF Writer: Event Types
  *
  * http://www.efficios.com/ctf
  */
 
-#include <babeltrace/ctf-writer/writer.h>
-#include <babeltrace/ctf/events.h>
-#include <stdint.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event_class;
-struct bt_ctf_event;
-struct bt_ctf_field_type;
-
-enum bt_ctf_integer_base {
-       BT_CTF_INTEGER_BASE_UNKNOWN = -1,
-       BT_CTF_INTEGER_BASE_BINARY = 2,
-       BT_CTF_INTEGER_BASE_OCTAL = 8,
-       BT_CTF_INTEGER_BASE_DECIMAL = 10,
-       BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
-};
-
-/*
- * bt_ctf_field_type_integer_create: create an integer field type.
- *
- * Allocate a new integer field type of the given size. The creation of a field
- * type sets its reference count to 1.
- *
- * @param size Integer field type size/length in bits.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
-               unsigned int size);
-
-/*
- * bt_ctf_field_type_integer_set_signed: set an integer type's signedness.
- *
- * Set an integer type's signedness attribute.
- *
- * @param integer Integer type.
- * @param is_signed Integer's signedness, defaults to FALSE.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_integer_set_signed(
-               struct bt_ctf_field_type *integer, int is_signed);
-
-/*
- * bt_ctf_field_type_integer_set_base: set an integer type's base.
- *
- * Set an integer type's base used to pretty-print the resulting trace.
- *
- * @param integer Integer type.
- * @param base Integer base, defaults to BT_CTF_INTEGER_BASE_DECIMAL.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_integer_set_base(
-               struct bt_ctf_field_type *integer,
-               enum bt_ctf_integer_base base);
-
-/*
- * bt_ctf_field_type_integer_set_encoding: set an integer type's encoding.
- *
- * An integer encoding may be set to signal that the integer must be printed as
- * a text character.
- *
- * @param integer Integer type.
- * @param encoding Integer output encoding, defaults to CTF_STRING_ENCODING_NONE
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_integer_set_encoding(
-               struct bt_ctf_field_type *integer,
-               enum ctf_string_encoding encoding);
-
-/*
- * bt_ctf_field_type_enumeration_create: create an enumeration field type.
- *
- * Allocate a new enumeration field type with the given underlying type. The
- * creation of a field type sets its reference count to 1.
- * The resulting enumeration will share the integer_container_type's ownership
- * by increasing its reference count.
- *
- * @param integer_container_type Underlying integer type of the enumeration
- *     type.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
-               struct bt_ctf_field_type *integer_container_type);
-
-/*
- * bt_ctf_field_type_enumeration_add_mapping: add an enumeration mapping.
- *
- * Add a mapping to the enumeration. The range's values are inclusive.
- *
- * @param enumeration Enumeration type.
- * @param string Enumeration mapping name (will be copied).
- * @param range_start Enumeration mapping range start.
- * @param range_end Enumeration mapping range end.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_enumeration_add_mapping(
-               struct bt_ctf_field_type *enumeration, const char *string,
-               int64_t range_start, int64_t range_end);
-
-/*
- * bt_ctf_field_type_floating_point_create: create a floating point field type.
- *
- * Allocate a new floating point field type. The creation of a field type sets
- * its reference count to 1.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
-
-/*
- * bt_ctf_field_type_floating_point_set_exponent_digits: set exponent digit
- * count.
- *
- * Set the number of exponent digits to use to store the floating point field.
- * The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG.
- *
- * @param floating_point Floating point type.
- * @param exponent_digits Number of digits to allocate to the exponent (defaults
- *     to FLT_EXP_DIG).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_floating_point_set_exponent_digits(
-               struct bt_ctf_field_type *floating_point,
-               unsigned int exponent_digits);
-
-/*
- * bt_ctf_field_type_floating_point_set_mantissa_digits: set mantissa digit
- * count.
- *
- * Set the number of mantissa digits to use to store the floating point field.
- * The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG.
- *
- * @param floating_point Floating point type.
- * @param mantissa_digits Number of digits to allocate to the mantissa (defaults
- *     to FLT_MANT_DIG).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
-               struct bt_ctf_field_type *floating_point,
-               unsigned int mantissa_digits);
-
-/*
- * bt_ctf_field_type_structure_create: create a structure field type.
- *
- * Allocate a new structure field type. The creation of a field type sets
- * its reference count to 1.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
-
-/*
- * bt_ctf_field_type_structure_add_field: add a field to a structure.
- *
- * Add a field of type "field_type" to the structure. The structure will share
- * field_type's ownership by increasing its reference count.
- *
- * @param structure Structure type.
- * @param field_type Type of the field to add to the structure type.
- * @param field_name Name of the structure's new field (will be copied).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_structure_add_field(
-               struct bt_ctf_field_type *structure,
-               struct bt_ctf_field_type *field_type,
-               const char *field_name);
-
-/*
- * bt_ctf_field_type_variant_create: create a variant field type.
- *
- * Allocate a new variant field type. The creation of a field type sets
- * its reference count to 1. tag_name must be the name of an enumeration
- * field declared in the same scope as this variant.
- *
- * @param enum_tag Type of the variant's tag/selector (must be an enumeration).
- * @param tag_name Name of the variant's tag/selector field (will be copied).
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
-               struct bt_ctf_field_type *enum_tag,
-               const char *tag_name);
-
-/*
- * bt_ctf_field_type_variant_add_field: add a field to a variant.
- *
- * Add a field of type "field_type" to the variant.The variant will share
- * field_type's ownership by increasing its reference count. The "field_name"
- * will be copied. field_name must match a mapping in the tag/selector
- * enumeration.
- *
- * @param variant Variant type.
- * @param field_type Type of the variant type's new field.
- * @param field_name Name of the variant type's new field (will be copied).
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_variant_add_field(
-               struct bt_ctf_field_type *variant,
-               struct bt_ctf_field_type *field_type,
-               const char *field_name);
-
-/*
- * bt_ctf_field_type_array_create: create an array field type.
- *
- * Allocate a new array field type. The creation of a field type sets
- * its reference count to 1.
- *
- * @param element_type Array's element type.
- * @oaram length Array type's length.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
-               struct bt_ctf_field_type *element_type,
-               unsigned int length);
-
-/*
- * bt_ctf_field_type_sequence_create: create a sequence field type.
- *
- * Allocate a new sequence field type. The creation of a field type sets
- * its reference count to 1. "length_field_name" must match an integer field
- * declared in the same scope.
- *
- * @param element_type Sequence's element type.
- * @param length_field_name Name of the sequence's length field (will be
- *     copied).
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
-               struct bt_ctf_field_type *element_type,
-               const char *length_field_name);
-
-/*
- * bt_ctf_field_type_string_create: create a string field type.
- *
- * Allocate a new string field type. The creation of a field type sets
- * its reference count to 1.
- *
- * Returns an allocated field type on success, NULL on error.
- */
-extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
-
-/*
- * bt_ctf_field_type_string_set_encoding: set a string type's encoding.
- *
- * Set the string type's encoding.
- *
- * @param string String type.
- * @param encoding String field encoding, default CTF_STRING_ENCODING_ASCII.
- *     Valid values are CTF_STRING_ENCODING_ASCII and CTF_STRING_ENCODING_UTF8.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_string_set_encoding(
-               struct bt_ctf_field_type *string,
-               enum ctf_string_encoding encoding);
-
-/*
- * bt_ctf_field_type_set_alignment: set a field type's alignment.
- *
- * Set the field type's alignment.
- *
- * @param type Field type.
- * @param alignment Type's alignment. Defaults to 1 (bit-aligned). However,
- *     some types, such as structures and string, may impose other alignment
- *     constraints.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type,
-               unsigned int alignment);
-
-/*
- * bt_ctf_field_type_set_byte_order: set a field type's byte order.
- *
- * Set the field type's byte order.
- *
- * @param type Field type.
- * @param byte_order Field type's byte order. Defaults to
- * BT_CTF_BYTE_ORDER_NATIVE, the host machine's endianness.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type,
-               enum bt_ctf_byte_order byte_order);
-
-/*
- * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
- * the field type's reference count.
- *
- * These functions ensure that the field type 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 a field type.
- *
- * When the field type's reference count is decremented to 0 by a
- * bt_ctf_field_type_put, the field type is freed.
- *
- * @param type Field type.
- */
-extern void bt_ctf_field_type_get(struct bt_ctf_field_type *type);
-extern void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_TYPES_H */
+#include <babeltrace/ctf-ir/event-types.h>
index d8ef9d92776d2c4f908c46e140020ecf7787c56c..f91d2cd57ba80d10c4b7ce004520eb65fb4bf0fb 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef BABELTRACE_CTF_WRITER_EVENT_H
-#define BABELTRACE_CTF_WRITER_EVENT_H
-
 /*
  * BabelTrace - CTF Writer: Event
  *
  * http://www.efficios.com/ctf
  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event_class;
-struct bt_ctf_event;
-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);
-
-/*
- * 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);
-
-/*
- * 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);
-
-/*
- * 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 int bt_ctf_event_set_payload(struct bt_ctf_event *event,
-               const char *name,
-               struct bt_ctf_field *value);
-
-/*
- * 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,
-               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);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_EVENT_H */
+#include <babeltrace/ctf-ir/event.h>
index 8ec0fc59d6077d812b3d9779d30b475d37a2faad..2f6c8bdbba55a560012b90d7a72c5a12fdc2731c 100644 (file)
@@ -1,6 +1,3 @@
-#ifndef BABELTRACE_CTF_WRITER_STREAM_CLASS_H
-#define BABELTRACE_CTF_WRITER_STREAM_CLASS_H
-
 /*
  * BabelTrace - CTF Writer: Stream Class
  *
  * http://www.efficios.com/ctf
  */
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct bt_ctf_event_class;
-struct bt_ctf_stream_class;
-struct bt_ctf_clock;
-
-/*
- * bt_ctf_stream_class_create: create a stream class.
- *
- * Allocate a new stream class of the given name. The creation of an event class
- * sets its reference count to 1.
- *
- * @param name Stream name.
- *
- * Returns an allocated stream class on success, NULL on error.
- */
-extern struct bt_ctf_stream_class *bt_ctf_stream_class_create(const char *name);
-
-/*
- * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
- *
- * Assign a clock to a stream class. This clock will be sampled each time an
- * event is appended to an instance of this stream class.
- *
- * @param stream_class Stream class.
- * @param clock Clock to assign to the provided stream class.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_class_set_clock(
-               struct bt_ctf_stream_class *stream_class,
-               struct bt_ctf_clock *clock);
-
-/*
- * bt_ctf_stream_class_set_clock: assign a clock to a stream class.
- *
- * Add an event class to a stream class. New events can be added even after a
- * stream has beem instanciated and events have been appended. However, a stream
- * will not accept events of a class that has not been registered beforehand.
- * The stream class will share the ownership of "event_class" by incrementing
- * its reference count.
- *
- * @param stream_class Stream class.
- * @param event_class Event class to add to the provided stream class.
- *
- * Returns 0 on success, a negative value on error.
- */
-extern int bt_ctf_stream_class_add_event_class(
-               struct bt_ctf_stream_class *stream_class,
-               struct bt_ctf_event_class *event_class);
-
-/*
- * bt_ctf_stream_class_get and bt_ctf_stream_class_put: increment and
- * decrement the stream class' reference count.
- *
- * These functions ensure that the stream 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 a stream class.
- *
- * When the stream class' reference count is decremented to 0 by a
- * bt_ctf_stream_class_put, the stream class is freed.
- *
- * @param stream_class Stream class.
- */
-extern void bt_ctf_stream_class_get(struct bt_ctf_stream_class *stream_class);
-extern void bt_ctf_stream_class_put(struct bt_ctf_stream_class *stream_class);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* BABELTRACE_CTF_WRITER_STREAM_CLASS_H */
+#include <babeltrace/ctf-ir/stream-class.h>
index 57dd992d103706a494fb756774e5f58b185386fa..f1cb27c237257efebb7cc237216531b22b629d42 100644 (file)
 
 typedef void(*flush_func)(struct bt_ctf_stream *, void *);
 
-struct bt_ctf_stream_class {
-       struct bt_ctf_ref ref_count;
-       GString *name;
-       struct bt_ctf_clock *clock;
-       GPtrArray *event_classes; /* Array of pointers to bt_ctf_event_class */
-       int id_set;
-       uint32_t id;
-       uint32_t next_event_id;
-       uint32_t next_stream_id;
-       struct bt_ctf_field_type *event_header_type;
-       struct bt_ctf_field *event_header;
-       struct bt_ctf_field_type *packet_context_type;
-       struct bt_ctf_field *packet_context;
-       struct bt_ctf_field_type *event_context_type;
-       struct bt_ctf_field *event_context;
-       int frozen;
-};
-
 struct flush_callback {
        flush_func func;
        void *data;
@@ -72,21 +54,6 @@ struct bt_ctf_stream {
        uint64_t events_discarded;
 };
 
-BT_HIDDEN
-void bt_ctf_stream_class_freeze(struct bt_ctf_stream_class *stream_class);
-
-BT_HIDDEN
-int bt_ctf_stream_class_set_id(struct bt_ctf_stream_class *stream_class,
-               uint32_t id);
-
-BT_HIDDEN
-int bt_ctf_stream_class_serialize(struct bt_ctf_stream_class *stream_class,
-               struct metadata_context *context);
-
-BT_HIDDEN
-int bt_ctf_stream_class_set_byte_order(struct bt_ctf_stream_class *stream_class,
-               enum bt_ctf_byte_order byte_order);
-
 BT_HIDDEN
 struct bt_ctf_stream *bt_ctf_stream_create(
                struct bt_ctf_stream_class *stream_class);
index 68031ac3fce2b52facc099925975e9728f5b94f3..7a8dc60f2a3682a0768f379e7d5ab2c91f0ede1f 100644 (file)
@@ -30,6 +30,8 @@
  * http://www.efficios.com/ctf
  */
 
+#include <babeltrace/ctf-ir/event-types.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -39,13 +41,6 @@ struct bt_ctf_stream;
 struct bt_ctf_stream_class;
 struct bt_ctf_clock;
 
-enum bt_ctf_byte_order {
-       BT_CTF_BYTE_ORDER_NATIVE = 0,
-       BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
-       BT_CTF_BYTE_ORDER_BIG_ENDIAN,
-       BT_CTF_BYTE_ORDER_NETWORK,
-};
-
 /*
  * bt_ctf_writer_create: create a writer instance.
  *
This page took 0.058856 seconds and 4 git commands to generate.