Visibility: split graph API into public and private interfaces
[babeltrace.git] / lib / component / source.c
index 7b51590c7214117fc3a080b67f07f3d8c94c82af..bddd2f6a2408fee405133de591b0d6824e0eb7c0 100644 (file)
@@ -28,8 +28,9 @@
 
 #include <babeltrace/ref.h>
 #include <babeltrace/compiler.h>
-#include <babeltrace/component/source-internal.h>
+#include <babeltrace/component/component-source-internal.h>
 #include <babeltrace/component/component-internal.h>
+#include <babeltrace/component/port-internal.h>
 #include <babeltrace/component/notification/iterator.h>
 #include <babeltrace/component/notification/iterator-internal.h>
 
@@ -58,30 +59,118 @@ end:
        return ret;
 }
 
+BT_HIDDEN
+void bt_component_source_destroy(struct bt_component *component)
+{
+}
+
 BT_HIDDEN
 struct bt_component *bt_component_source_create(
                struct bt_component_class *class, struct bt_value *params)
 {
        struct bt_component_source *source = NULL;
-       enum bt_component_status ret;
 
        source = g_new0(struct bt_component_source, 1);
        if (!source) {
                goto end;
        }
 
-       source->parent.class = bt_get(class);
-       ret = bt_component_init(&source->parent, NULL);
-       if (ret != BT_COMPONENT_STATUS_OK) {
-               BT_PUT(source);
+end:
+       return source ? &source->parent : NULL;
+}
+
+enum bt_component_status bt_component_source_get_output_port_count(
+               struct bt_component *component, uint64_t *count)
+{
+       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+
+       if (!component || !count ||
+                       component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               status = BT_COMPONENT_STATUS_INVALID;
                goto end;
        }
+
+       *count = bt_component_get_output_port_count(component);
 end:
-       return source ? &source->parent : NULL;
+       return status;
 }
 
-struct bt_notification_iterator *bt_component_source_create_iterator(
+struct bt_port *bt_component_source_get_output_port(
+               struct bt_component *component, const char *name)
+{
+       struct bt_port *port = NULL;
+
+       if (!component || !name ||
+                       component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               goto end;
+       }
+
+       port = bt_component_get_output_port(component, name);
+end:
+       return port;
+}
+
+struct bt_port *bt_component_source_get_output_port_at_index(
+               struct bt_component *component, int index)
+{
+       struct bt_port *port = NULL;
+
+       if (!component ||
+                       component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               goto end;
+       }
+
+       port = bt_component_get_output_port_at_index(component, index);
+end:
+       return port;
+}
+
+struct bt_port *bt_component_source_get_default_output_port(
                struct bt_component *component)
 {
-       return bt_component_create_iterator(component);
+       return bt_component_source_get_output_port(component,
+                       DEFAULT_OUTPUT_PORT_NAME);
+}
+
+struct bt_private_port *bt_private_component_source_get_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name)
+{
+       return bt_private_port_from_port(bt_component_source_get_output_port(
+               bt_component_from_private(private_component), name));
+}
+
+struct bt_private_port *
+bt_private_component_source_get_output_private_port_at_index(
+               struct bt_private_component *private_component, int index)
+{
+       return bt_private_port_from_port(
+               bt_component_source_get_output_port_at_index(
+                       bt_component_from_private(private_component), index));
+}
+
+struct bt_private_port *bt_private_component_source_get_default_output_private_port(
+               struct bt_private_component *private_component)
+{
+       return bt_private_port_from_port(
+               bt_component_source_get_default_output_port(
+                       bt_component_from_private(private_component)));
+}
+
+struct bt_private_port *bt_private_component_source_add_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name)
+{
+       struct bt_port *port = NULL;
+       struct bt_component *component =
+               bt_component_from_private(private_component);
+
+       if (!component ||
+                       component->class->type != BT_COMPONENT_CLASS_TYPE_SOURCE) {
+               goto end;
+       }
+
+       port = bt_component_add_output_port(component, name);
+end:
+       return bt_private_port_from_port(port);
 }
This page took 0.024405 seconds and 4 git commands to generate.