Refactor the component class and component API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 26 Jan 2017 09:03:19 +0000 (04:03 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:37 +0000 (12:57 -0400)
commitd3e4dcd8e7a601e0aa063455147f29fbe051582b
tree93e5ade065a51065c773d753f06083c753472760
parentd1b057f5b2954339b0b48fdc5973ec59a641f5a9
Refactor the component class and component API

This patch modifies the component class and component API so that the
user sets methods to the component class objects, not to the component
objects. This makes sense following the typical object-oriented
paradigm.

Changes:

* bt_component_class_create() is removed.

  You need to use a component class-specific function to create one,
  amongst:

  * bt_component_class_source_create()
  * bt_component_class_filter_create()
  * bt_component_class_sink_create()

  All the parameters of those functions are mandatory: they are the
  name and the mandatory _methods_ of the class, depending on the
  type.

* Component class-specific functions are declared in their own header:

  * babeltrace/component/component-class-source.h
  * babeltrace/component/component-class-filter.h
  * babeltrace/component/component-class-sink.h

  babeltrace/component/component-class.h only contains functions which
  you can use on any component class, whatever the type.

* enum bt_component_type and BT_COMPONENT_TYPE_* are renamed to
  enum bt_component_class_type and BT_COMPONENT_CLASS_TYPE_* since
  the type is a property of the component class.

* Once a component class is created, you can use functions to set
  optional methods:

  * bt_component_class_filter_set_add_iterator_method()
  * bt_component_class_sink_set_add_iterator_method()

  The component initialization and destroy methods are now both
  optional:

  * bt_component_class_set_init_method()
  * bt_component_class_set_destroy_method()

  You can also set the optional description with a function:

  * bt_component_class_set_description()

* New public utility function: bt_component_get_class_type(): returns
  the type of a component's class.

* Component functions which are specific to a class type are moved to
  their respective header in babeltrace/component
  (source.h, filter.h, sink.h).

* Plugin development interface (babeltrace/plugin/plugin-dev.h) is
  updated to follow the API changes. Component class descriptor macros
  contain the component class type in their name, for example:

      BT_PLUGIN_SINK_COMPONENT_CLASS_DESCRIPTION()
      BT_PLUGIN_SOURCE_COMPONENT_CLASS_DESTROY_METHOD()
      BT_PLUGIN_FILTER_COMPONENT_CLASS_ADD_ITERATOR_METHOD()

* Existing plugins, tests, and the command-line converter are updated to
  follow the API changes.

* Other very minor fixes.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
34 files changed:
converter/babeltrace.c
include/Makefile.am
include/babeltrace/component/component-class-filter.h [new file with mode: 0644]
include/babeltrace/component/component-class-internal.h
include/babeltrace/component/component-class-sink.h [new file with mode: 0644]
include/babeltrace/component/component-class-source.h [new file with mode: 0644]
include/babeltrace/component/component-class.h
include/babeltrace/component/component-internal.h
include/babeltrace/component/component.h
include/babeltrace/component/filter-internal.h
include/babeltrace/component/filter.h
include/babeltrace/component/sink-internal.h
include/babeltrace/component/sink.h
include/babeltrace/component/source-internal.h
include/babeltrace/plugin/plugin-dev.h
include/babeltrace/plugin/plugin.h
lib/component/component-class.c
lib/component/component.c
lib/component/filter.c
lib/component/iterator.c
lib/component/sink.c
lib/component/source.c
lib/plugin/plugin.c
plugins/ctf/fs/fs.c
plugins/ctf/fs/fs.h
plugins/ctf/lttng-live/lttng-live-internal.h
plugins/ctf/lttng-live/lttng-live.c
plugins/ctf/plugin.c
plugins/muxer/muxer.c
plugins/text/text.c
plugins/trimmer/trimmer.c
plugins/writer/writer.c
tests/lib/test-plugin-plugins/sfs.c
tests/lib/test_plugin.c
This page took 0.027629 seconds and 4 git commands to generate.