ir: add bt_ctf_clock_class object, modify bt_ctf_clock object
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 16 Jan 2017 20:02:23 +0000 (15:02 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:08 +0000 (14:09 -0400)
commitac0c6bddcdde51dcbb46fc73c61d4f2330774451
treecd9151e84e49a93d098f9328b249bae148b98d61
parent98a4cbefe4c162067144bf5e1b7341c8dd8767bb
ir: add bt_ctf_clock_class object, modify bt_ctf_clock object

In an attempt to isolate the CTF writer API from the general API
(sometimes called the non-writer API), let's make the clock object a
compound object made of:

1. A clock class object, a new object which holds all the static
   properties of a clock.
2. A single value.

You can only use the clock object with the functions of the CTF writer
API:

* bt_ctf_writer_add_clock()
* bt_ctf_stream_class_set_clock()
* bt_ctf_stream_class_get_clock()

The purpose of a clock object is to automate the setting of the
`timestamp` field in event headers part of a CTF writer object. The
clock object has nothing to do with the non-writer part of the API, that
is, the one you use to write BT component classes and plugins.

The functions above do this from now on:

* bt_ctf_writer_add_clock(): Calls bt_ctf_trace_add_clock_class() on
  the clock class of the clock object parameter.

* bt_ctf_stream_class_set_clock(): Registers the clock object as the
  current stream class's clock and maps the field named `timestamp`
  in the current event header field type to this same clock class.

  NOTE: If you set a custom event header field type after having called
        bt_ctf_stream_class_set_clock(), this mapping is LOST.

When you call bt_ctf_stream_append_event(), the `timestamp` field of the
event header is automatically set (from the stream class's clock's
current value) if, and only if all the following conditions are
satisfied:

1. The event header field `timestamp` exists and is an integer field.

2. The stream's class has a registered clock (set with
   bt_ctf_stream_class_set_clock()).

3. The event header field `timestamp` has its type mapped to a clock
   class which is also the clock class of the stream's class's
   registered clock.

4. The event header field `timestamp` is NOT set.

From now on you cannot set a stream class's clock and add this stream
class to a trace which was not created by a CTF writer. This enforces
the fact that bt_ctf_stream_class_set_clock() and
bt_ctf_stream_class_get_clock() are only part of the CTF writer API.

A clock _class_ has no value, although you can create individual clock
value objects linked to a specific clock class with
bt_ctf_clock_value_create(). Note that everything related to clock value
objects has zero effects on the CTF writer API.

What would be named bt_ctf_clock_class_*_offset() after this massive
renaming operation is named bt_ctf_clock_class_*_offset_cycles() for
those functions to be self-documented, and for them to have names that
are parallel with bt_ctf_clock_class_*_offset_s().

bt_ctf_field_type_integer_*_mapped_clock() functions are renamed
to bt_ctf_field_type_integer_*_mapped_clock_class().

Component classes must now include `babeltrace/ctf-ir/clock-class.h`
to deal with clock class objects.

Programs which use the CTF writer API must still include
`babeltrace/ctf-writer/clock.h`.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
33 files changed:
formats/ctf/ir/Makefile.am
formats/ctf/ir/clock-class.c [new file with mode: 0644]
formats/ctf/ir/clock.c [deleted file]
formats/ctf/ir/event.c
formats/ctf/ir/field-types.c
formats/ctf/ir/stream-class.c
formats/ctf/ir/stream.c
formats/ctf/ir/trace.c
formats/ctf/writer/Makefile.am
formats/ctf/writer/clock.c [new file with mode: 0644]
formats/ctf/writer/writer.c
include/Makefile.am
include/babeltrace/ctf-ir/clock-class-internal.h [new file with mode: 0644]
include/babeltrace/ctf-ir/clock-class.h [new file with mode: 0644]
include/babeltrace/ctf-ir/clock-internal.h [deleted file]
include/babeltrace/ctf-ir/clock.h [deleted file]
include/babeltrace/ctf-ir/event-internal.h
include/babeltrace/ctf-ir/event.h
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/field-types.h
include/babeltrace/ctf-ir/stream-class.h
include/babeltrace/ctf-ir/trace-internal.h
include/babeltrace/ctf-ir/trace.h
include/babeltrace/ctf-writer/clock-internal.h [new file with mode: 0644]
include/babeltrace/ctf-writer/clock.h
include/babeltrace/ctf-writer/stream-class.h
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/common/notif-iter/notif-iter.c
plugins/ctf/fs/fs.c
plugins/text/print.c
plugins/trimmer/iterator.c
plugins/writer/write.c
tests/lib/test_ctf_writer.c
This page took 0.028947 seconds and 4 git commands to generate.