Visibility: split graph API into public and private interfaces
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Tue, 28 Mar 2017 18:14:42 +0000 (14:14 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:39 +0000 (12:57 -0400)
The goal here is to avoid that a component or a graph user calls methods
that do not logically apply to itself, but should according to the API's
intention. For example, a component should not be able to remove the
ports of another component, and a graph user should not be able to
create a notification iterator directly.

Therefore the existing bt_component, bt_port, bt_connection, and
bt_notification_iterator objects are considered "public": any user can
call their API.

The user-defined methods (callbacks) now accept private versions of
those objects:

* bt_private_component
* bt_private_port
* bt_private_connection
* bt_private_notification_iterator

This ensures that only the user which is called back with those private
objects can call specific, private methods, which start with the
`bt_private_` prefix.

For example, any user can get a sink component's input port by name with
bt_component_sink_get_input_port(). This function accepts a bt_component
object parameter and returns a bt_port object. However, only the called
back user can get its private version of the port with the equivalent
bt_private_component_sink_get_input_private_port(). This function
accepts a bt_private_component object parameter and returns a
bt_private_port object. The private port API has the
bt_private_port_remove_from_component() function: thus only the owner
component of a port can remove it from itself.

Each private API has a bt_OBJ_from_private_OBJ() function which
returns a _new reference_ to the equivalent public object of a private
object to be able to call public functions.

With all this, if a user calls a private function with a public object,
the compiler emits a warning similar to:

    warning: assignment from incompatible pointer type

With GCC and Clang, you can make this warning an error with:

    -Werror=incompatible-pointer-types

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
43 files changed:
include/Makefile.am
include/babeltrace/component/component-class-sink.h
include/babeltrace/component/component-class.h
include/babeltrace/component/component-filter-internal.h
include/babeltrace/component/component-filter.h
include/babeltrace/component/component-internal.h
include/babeltrace/component/component-sink.h
include/babeltrace/component/component-source-internal.h
include/babeltrace/component/component-source.h
include/babeltrace/component/component.h
include/babeltrace/component/connection-internal.h
include/babeltrace/component/connection.h
include/babeltrace/component/notification/iterator-internal.h
include/babeltrace/component/notification/iterator.h
include/babeltrace/component/notification/private-iterator.h [new file with mode: 0644]
include/babeltrace/component/port-internal.h
include/babeltrace/component/private-component-filter.h [new file with mode: 0644]
include/babeltrace/component/private-component-sink.h [new file with mode: 0644]
include/babeltrace/component/private-component-source.h [new file with mode: 0644]
include/babeltrace/component/private-component.h [new file with mode: 0644]
include/babeltrace/component/private-connection.h [new file with mode: 0644]
include/babeltrace/component/private-port.h [new file with mode: 0644]
lib/component/component.c
lib/component/connection.c
lib/component/filter.c
lib/component/iterator.c
lib/component/port.c
lib/component/sink.c
lib/component/source.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/muxer/muxer.c
plugins/text/text.c
plugins/utils/dummy/dummy.c
plugins/utils/dummy/dummy.h
plugins/utils/trimmer/iterator.c
plugins/utils/trimmer/iterator.h
plugins/utils/trimmer/trimmer.c
plugins/utils/trimmer/trimmer.h
plugins/writer/writer.c
tests/lib/test-plugin-plugins/sfs.c

index b4d86eccea81ecec546c50dacbc831f7bf4f5674..94676992a3e0e14e22cff5e11f0de918ca4d249c 100644 (file)
@@ -49,7 +49,8 @@ babeltracecomponentnotifinclude_HEADERS = \
        babeltrace/component/notification/packet.h \
        babeltrace/component/notification/schema.h \
        babeltrace/component/notification/stream.h \
-       babeltrace/component/notification/heap.h
+       babeltrace/component/notification/heap.h \
+       babeltrace/component/notification/private-iterator.h
 
 babeltracecomponentinclude_HEADERS = \
        babeltrace/component/component.h \
@@ -62,7 +63,13 @@ babeltracecomponentinclude_HEADERS = \
        babeltrace/component/graph.h \
        babeltrace/component/component-source.h \
        babeltrace/component/component-sink.h \
-       babeltrace/component/component-filter.h
+       babeltrace/component/component-filter.h \
+       babeltrace/component/private-connection.h \
+       babeltrace/component/private-port.h \
+       babeltrace/component/private-component.h \
+       babeltrace/component/private-component-source.h \
+       babeltrace/component/private-component-sink.h \
+       babeltrace/component/private-component-filter.h
 
 noinst_HEADERS = \
        babeltrace/align.h \
index 8b3ed62daa525e0927c8f31bd8481eac3567dcd1..b93b51d677928ac4569bb9a6ee30a82a4913efe0 100644 (file)
@@ -25,7 +25,7 @@
  * SOFTWARE.
  */
 
-#include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -34,7 +34,7 @@ extern "C" {
 struct bt_component_class;
 
 typedef enum bt_component_status (*bt_component_class_sink_consume_method)(
-        struct bt_component *);
+        struct bt_private_component *private_component);
 
 extern
 struct bt_component_class *bt_component_class_sink_create(const char *name,
index 823301a2696baa1675ad0869cdfd44a4ed3ba81a..f4761bea5b3da6ae85d3847c58d0c702f3245c0f 100644 (file)
@@ -34,10 +34,10 @@ extern "C" {
 
 struct bt_component_class;
 struct bt_component;
-struct bt_port;
-struct bt_connection;
+struct bt_private_component;
+struct bt_private_port;
 struct bt_value;
-struct bt_notification_iterator;
+struct bt_private_notification_iterator;
 
 /**
  * Component class type.
@@ -56,38 +56,43 @@ enum bt_component_class_type {
 };
 
 typedef enum bt_component_status (*bt_component_class_init_method)(
-               struct bt_component *component, struct bt_value *params,
-               void *init_method_data);
+               struct bt_private_component *private_component,
+               struct bt_value *params, void *init_method_data);
 
-typedef void (*bt_component_class_destroy_method)(struct bt_component *component);
+typedef void (*bt_component_class_destroy_method)(
+               struct bt_private_component *private_component);
 
 typedef enum bt_notification_iterator_status
                (*bt_component_class_notification_iterator_init_method)(
-               struct bt_component *component,
-               struct bt_notification_iterator *iterator, void *init_method_data);
+               struct bt_private_component *private_component,
+               struct bt_private_port *private_port,
+               struct bt_private_notification_iterator *private_notification_iterator);
 
 typedef void (*bt_component_class_notification_iterator_destroy_method)(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *private_notification_iterator);
 
 typedef struct bt_notification *(*bt_component_class_notification_iterator_get_method)(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *private_notification_iterator);
 
 typedef enum bt_notification_iterator_status (*bt_component_class_notification_iterator_next_method)(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *private_notification_iterator);
 
 typedef enum bt_notification_iterator_status
                (*bt_component_class_notification_iterator_seek_time_method)(
-               struct bt_notification_iterator *iterator, int64_t time);
+               struct bt_private_notification_iterator *private_notification_iterator,
+               int64_t time);
 
 typedef struct bt_value *(*bt_component_class_query_method)(
                struct bt_component_class *component_class,
                const char *object, struct bt_value *params);
 
 typedef enum bt_component_status (*bt_component_class_accept_port_connection_method)(
-               struct bt_component *component, struct bt_port *port);
+               struct bt_private_component *private_component,
+               struct bt_private_port *private_port);
 
 typedef void (*bt_component_class_port_disconnected_method)(
-               struct bt_component *component, struct bt_port *port);
+               struct bt_private_component *private_component,
+               struct bt_private_port *private_port);
 
 extern int bt_component_class_set_init_method(
                struct bt_component_class *component_class,
index 68598346c963a2fb5587160c56d787427748f906..71690cad3e7e3e39156f5743defceb2a8f1aefa4 100644 (file)
@@ -61,18 +61,4 @@ BT_HIDDEN
 enum bt_component_status bt_component_filter_validate(
                struct bt_component *component);
 
-/**
- * Create an iterator on a component instance.
- *
- * @param component    Component instance
- * @returns            Notification iterator instance
- */
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_filter_create_notification_iterator(
-               struct bt_component *component);
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_filter_create_notification_iterator_with_init_method_data(
-        struct bt_component *component, void *init_method_data);
-
 #endif /* BABELTRACE_COMPONENT_FILTER_INTERNAL_H */
index cda188eb2f874c444ef005b001c1701d9f54fb8d..6f42d4e953e055a458e01f9d8ddd1c5e2fead606 100644 (file)
@@ -36,7 +36,6 @@ extern "C" {
 
 struct bt_port;
 struct bt_component;
-struct bt_notification_iterator;
 
 extern enum bt_component_status bt_component_filter_get_input_port_count(
                struct bt_component *component, uint64_t *count);
index 183db68649c21979e0c78aad2d262eac15637d61..c12b3b368a53fb90e080bc4f34025b9ca26bb658 100644 (file)
@@ -47,7 +47,7 @@ struct bt_component {
         * Internal destroy function specific to a source, filter, or
         * sink component object.
         */
-       bt_component_class_destroy_method destroy;
+       void (*destroy)(struct bt_component *);
 
        /* User-defined data */
        void *user_data;
@@ -63,9 +63,19 @@ struct bt_component {
        GPtrArray *output_ports;
 };
 
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_create_iterator(
-               struct bt_component *component, void *init_method_data);
+static inline
+struct bt_component *bt_component_from_private(
+               struct bt_private_component *private_component)
+{
+       return (void *) private_component;
+}
+
+static inline
+struct bt_private_component *bt_private_component_from_component(
+               struct bt_component *component)
+{
+       return (void *) component;
+}
 
 BT_HIDDEN
 enum bt_component_status bt_component_accept_port_connection(
index e52716214ae941385414f47638d89ac4594826f6..924f8c7470f1bbd77a58efadd3fc7c21ff4b9acf 100644 (file)
@@ -42,11 +42,6 @@ extern struct bt_port *bt_component_sink_get_input_port(
                struct bt_component *component, const char *name);
 extern struct bt_port *bt_component_sink_get_input_port_at_index(
                struct bt_component *component, int index);
-
-/* Only allowed during the sink's initialization. */
-extern struct bt_port *bt_component_sink_add_input_port(
-               struct bt_component *component, const char *name);
-/* Only allowed during the sink's initialization. */
 extern struct bt_port *bt_component_sink_get_default_input_port(
                struct bt_component *component);
 
index 458cc7d28bfc2465990a900513093f431d8cfa7b..0a68e8a50cdd3d7566b266eba80409c0f71ab2b4 100644 (file)
@@ -61,18 +61,4 @@ BT_HIDDEN
 enum bt_component_status bt_component_source_validate(
                struct bt_component *component);
 
-/**
- * Create an iterator on a component instance.
- *
- * @param component    Component instance
- * @returns            Notification iterator instance
- */
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator(
-               struct bt_component *component);
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator_with_init_method_data(
-        struct bt_component *component, void *init_method_data);
-
 #endif /* BABELTRACE_COMPONENT_SOURCE_INTERNAL_H */
index 84e80c3aeaeff00e34b658bd2c17f95d45d978ed..94ebf70715b0eb57282104bb0003c4d7e43f98f4 100644 (file)
@@ -46,10 +46,6 @@ extern struct bt_port *bt_component_source_get_output_port_at_index(
 extern struct bt_port *bt_component_source_get_default_output_port(
                struct bt_component *component);
 
-/* Only allowed during the source's initialization. */
-extern struct bt_port *bt_component_source_add_output_port(
-               struct bt_component *component, const char *name);
-
 #ifdef __cplusplus
 }
 #endif
index 0a2f70d7579735d58be3de9e7fa642318900ba56..1d884968f9d8b25e3b601b0d74694125cfc319b9 100644 (file)
@@ -85,24 +85,6 @@ extern struct bt_component *bt_component_create_with_init_method_data(
                struct bt_component_class *component_class, const char *name,
                struct bt_value *params, void *init_method_data);
 
-/**
- * Get a component's private data.
- *
- * @param component    Component of which to get the private data
- * @returns            Component's private data
- */
-extern void *bt_component_get_private_data(struct bt_component *component);
-
-/**
- * Set a component's private data.
- *
- * @param component    Component of which to set the private data
- * @param data         Component private data
- * @returns            One of #bt_component_status values
- */
-extern enum bt_component_status bt_component_set_private_data(
-               struct bt_component *component, void *data);
-
 /**
  * Get component's name.
  *
index 74144cd5d3eb4b7c582950e8528085fdf817dd61..10533aff7b9e220f9c30350754b725d131db3a3c 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <babeltrace/component/connection.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/object-internal.h>
 
 struct bt_graph;
@@ -49,6 +50,20 @@ struct bt_connection {
        struct bt_port *upstream_port;
 };
 
+static inline
+struct bt_connection *bt_connection_from_private(
+               struct bt_private_connection *private_connection)
+{
+       return (void *) private_connection;
+}
+
+static inline
+struct bt_private_connection *bt_private_connection_from_connection(
+               struct bt_connection *connection)
+{
+       return (void *) connection;
+}
+
 BT_HIDDEN
 struct bt_connection *bt_connection_create(struct bt_graph *graph,
                struct bt_port *upstream_port,
index 4f79359cfa7b14661b013e6857a2b23843984249..4fe1d4c31052c03b9395d91523082619bd269102 100644 (file)
@@ -41,9 +41,6 @@ extern struct bt_port *bt_connection_get_downstream_port(
 extern struct bt_port *bt_connection_get_upstream_port(
                struct bt_connection *connection);
 
-extern struct bt_notification_iterator *
-bt_connection_create_notification_iterator(struct bt_connection *connection);
-
 #ifdef __cplusplus
 }
 #endif
index 8bad9f937b654f1f1fc5a33f871fcc3001c1206d..99e9617ca06505f68bdad4b75c245a446c92fb48 100644 (file)
  */
 
 #include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/object-internal.h>
 #include <babeltrace/ref-internal.h>
 #include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/private-iterator.h>
 
 struct bt_notification_iterator {
        struct bt_object base;
@@ -37,6 +39,21 @@ struct bt_notification_iterator {
        void *user_data;
 };
 
+static inline
+struct bt_notification_iterator *bt_notification_iterator_from_private(
+               struct bt_private_notification_iterator *private_notification_iterator)
+{
+       return (void *) private_notification_iterator;
+}
+
+static inline
+struct bt_private_notification_iterator *
+bt_private_notification_iterator_from_notification_iterator(
+               struct bt_notification_iterator *notification_iterator)
+{
+       return (void *) notification_iterator;
+}
+
 /**
  * Allocate a notification iterator.
  *
index 26583c3a8cd7878e9c34a14fd3068c3e26f22a61..bc226e131b63b58b84b9b6187338f90d635c0151 100644 (file)
@@ -126,26 +126,6 @@ extern enum bt_notification_iterator_status bt_notification_iterator_seek_time(
 extern struct bt_component *bt_notification_iterator_get_component(
                struct bt_notification_iterator *iterator);
 
-/**
- * Set an iterator's private data.
- *
- * @param iterator     Notification iterator instance
- * @param data         Iterator private data
- * @returns            One of #bt_notification_iterator_status values
- */
-extern enum bt_notification_iterator_status
-bt_notification_iterator_set_private_data(
-               struct bt_notification_iterator *iterator, void *data);
-
-/**
- * Get an iterator's private data.
- *
- * @param iterator     Notification iterator instance
- * @returns            Iterator instance private data
- */
-extern void *bt_notification_iterator_get_private_data(
-               struct bt_notification_iterator *iterator);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/include/babeltrace/component/notification/private-iterator.h b/include/babeltrace/component/notification/private-iterator.h
new file mode 100644 (file)
index 0000000..9cc8c66
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef BABELTRACE_COMPONENT_NOTIFICATION_PRIVATE_ITERATOR_H
+#define BABELTRACE_COMPONENT_NOTIFICATION_PRIVATE_ITERATOR_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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:
+ * 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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_connection;
+struct bt_private_port;
+struct bt_private_connection;
+struct bt_private_notification_iterator;
+
+struct bt_notification_iterator *
+bt_notification_iterator_from_private_notification_iterator(
+               struct bt_private_notification_iterator *private_notification_iterator);
+
+extern struct bt_private_component *
+bt_private_notification_iterator_get_private_component(
+               struct bt_private_notification_iterator *private_notification_iterator);
+
+extern enum bt_notification_iterator_status
+bt_private_notification_iterator_set_user_data(
+               struct bt_private_notification_iterator *private_notification_iterator,
+               void *user_data);
+
+extern void *bt_private_notification_iterator_get_user_data(
+               struct bt_private_notification_iterator *private_notification_iterator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_NOTIFICATION_PRIVATE_ITERATOR_H */
index f693b2de2e90f766e5854976a3ee86cd1ade4985..fb4ff727bde71b018ccbf3ce4fff358b7228b731 100644 (file)
@@ -40,6 +40,20 @@ struct bt_port {
        struct bt_connection *connection;
 };
 
+static inline
+struct bt_port *bt_port_from_private(
+               struct bt_private_port *private_port)
+{
+       return (void *) private_port;
+}
+
+static inline
+struct bt_private_port *bt_private_port_from_port(
+               struct bt_port *port)
+{
+       return (void *) port;
+}
+
 BT_HIDDEN
 struct bt_port *bt_port_create(struct bt_component *parent_component,
                enum bt_port_type type, const char *name);
diff --git a/include/babeltrace/component/private-component-filter.h b/include/babeltrace/component/private-component-filter.h
new file mode 100644 (file)
index 0000000..e54ccc4
--- /dev/null
@@ -0,0 +1,75 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H
+#define BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_private_component;
+struct bt_private_port;
+
+extern struct bt_private_port *
+bt_private_component_filter_get_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+extern struct bt_private_port *
+bt_private_component_filter_get_output_private_port_at_index(
+               struct bt_private_component *private_component, int index);
+
+extern struct bt_private_port *
+bt_private_component_filter_get_default_output_private_port(
+               struct bt_private_component *private_component);
+
+extern struct bt_private_port *
+bt_private_component_filter_add_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+extern struct bt_private_port *
+bt_private_component_filter_get_input_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+extern struct bt_private_port *
+bt_private_component_filter_get_input_private_port_at_index(
+               struct bt_private_component *private_component, int index);
+
+extern struct bt_private_port *
+bt_private_component_filter_get_default_input_private_port(
+               struct bt_private_component *private_component);
+
+extern struct bt_private_port *
+bt_private_component_filter_add_input_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H */
diff --git a/include/babeltrace/component/private-component-sink.h b/include/babeltrace/component/private-component-sink.h
new file mode 100644 (file)
index 0000000..f1ba7a7
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H
+#define BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_private_component;
+struct bt_private_port;
+
+extern struct bt_private_port *
+bt_private_component_sink_get_input_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+extern struct bt_private_port *
+bt_private_component_sink_get_input_private_port_at_index(
+               struct bt_private_component *private_component, int index);
+
+extern struct bt_private_port *
+bt_private_component_sink_get_default_input_private_port(
+               struct bt_private_component *private_component);
+
+extern struct bt_private_port *
+bt_private_component_sink_add_input_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SINK_H */
diff --git a/include/babeltrace/component/private-component-source.h b/include/babeltrace/component/private-component-source.h
new file mode 100644 (file)
index 0000000..b54bbfb
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SOURCE_H
+#define BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SOURCE_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_private_component;
+struct bt_private_port;
+
+extern struct bt_private_port *
+bt_private_component_source_get_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+extern struct bt_private_port *
+bt_private_component_source_get_output_private_port_at_index(
+               struct bt_private_component *private_component, int index);
+
+extern struct bt_private_port *
+bt_private_component_source_get_default_output_private_port(
+               struct bt_private_component *private_component);
+
+extern struct bt_private_port *
+bt_private_component_source_add_output_private_port(
+               struct bt_private_component *private_component,
+               const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_COMPONENT_SOURCE_H */
diff --git a/include/babeltrace/component/private-component.h b/include/babeltrace/component/private-component.h
new file mode 100644 (file)
index 0000000..e19b6ff
--- /dev/null
@@ -0,0 +1,48 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_COMPONENT_H
+#define BABELTRACE_COMPONENT_PRIVATE_COMPONENT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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/component/component.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_private_component;
+
+struct bt_component *bt_component_from_private_component(
+               struct bt_private_component *private_component);
+
+extern void *bt_private_component_get_user_data(
+               struct bt_private_component *private_component);
+
+extern enum bt_component_status bt_private_component_set_user_data(
+               struct bt_private_component *private_component,
+               void *user_data);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_COMPONENT_H */
diff --git a/include/babeltrace/component/private-connection.h b/include/babeltrace/component/private-connection.h
new file mode 100644 (file)
index 0000000..7629460
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_CONNECTION_H
+#define BABELTRACE_COMPONENT_PRIVATE_CONNECTION_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_connection;
+struct bt_private_port;
+struct bt_private_connection;
+
+struct bt_connection *bt_connection_from_private_connection(
+               struct bt_private_connection *private_connection);
+
+extern struct bt_notification_iterator *
+bt_private_connection_create_notification_iterator(
+               struct bt_private_connection *private_connection);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_CONNECTION_H */
diff --git a/include/babeltrace/component/private-port.h b/include/babeltrace/component/private-port.h
new file mode 100644 (file)
index 0000000..2f0e49d
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef BABELTRACE_COMPONENT_PRIVATE_PORT_H
+#define BABELTRACE_COMPONENT_PRIVATE_PORT_H
+
+/*
+ * Copyright 2017 Philippe Proulx <pproulx@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.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct bt_port;
+struct bt_private_port;
+struct bt_private_component;
+struct bt_private_connection;
+
+struct bt_port *bt_port_from_private_port(struct bt_private_port *private_port);
+extern struct bt_private_connection *bt_private_port_get_private_connection(
+               struct bt_private_port *private_port);
+extern struct bt_private_component *bt_private_port_get_private_component(
+               struct bt_private_port *private_port);
+extern int bt_private_port_remove_from_component(
+               struct bt_private_port *private_port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_COMPONENT_PRIVATE_PORT_H */
index d55526c8ee4bdfa7d7968d0f4df277035f7039b5..9a2397545963e9c951a8de70394aeabe96973bd4 100644 (file)
  * SOFTWARE.
  */
 
+#include <babeltrace/component/private-component.h>
 #include <babeltrace/component/component.h>
 #include <babeltrace/component/component-internal.h>
 #include <babeltrace/component/component-class-internal.h>
 #include <babeltrace/component/component-source-internal.h>
 #include <babeltrace/component/component-filter-internal.h>
 #include <babeltrace/component/component-sink-internal.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/component/connection-internal.h>
 #include <babeltrace/component/graph-internal.h>
 #include <babeltrace/component/notification/iterator-internal.h>
+#include <babeltrace/component/notification/private-iterator.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler.h>
 #include <babeltrace/ref.h>
@@ -80,7 +83,8 @@ void bt_component_destroy(struct bt_object *obj)
         * instance.
         */
        if (component->class->methods.destroy) {
-               component->class->methods.destroy(component);
+               component->class->methods.destroy(
+                       bt_private_component_from_component(component));
        }
 
        if (component->destroy) {
@@ -100,84 +104,16 @@ void bt_component_destroy(struct bt_object *obj)
        g_free(component);
 }
 
-enum bt_component_class_type bt_component_get_class_type(
-               struct bt_component *component)
+struct bt_component *bt_component_from_private_component(
+               struct bt_private_component *private_component)
 {
-       return component ? component->class->type : BT_COMPONENT_CLASS_TYPE_UNKNOWN;
+       return bt_get(bt_component_from_private(private_component));
 }
 
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_create_iterator(
-               struct bt_component *component, void *init_method_data)
+enum bt_component_class_type bt_component_get_class_type(
+               struct bt_component *component)
 {
-       enum bt_notification_iterator_status ret_iterator;
-       enum bt_component_class_type type;
-       struct bt_notification_iterator *iterator = NULL;
-       struct bt_component_class *class = component->class;
-
-       if (!component) {
-               goto error;
-       }
-
-       type = bt_component_get_class_type(component);
-       if (type != BT_COMPONENT_CLASS_TYPE_SOURCE &&
-                       type != BT_COMPONENT_CLASS_TYPE_FILTER) {
-               /* Unsupported operation. */
-               goto error;
-       }
-
-       iterator = bt_notification_iterator_create(component);
-       if (!iterator) {
-               goto error;
-       }
-
-       switch (type) {
-       case BT_COMPONENT_CLASS_TYPE_SOURCE:
-       {
-               struct bt_component_class_source *source_class;
-               enum bt_notification_iterator_status status;
-
-               source_class = container_of(class, struct bt_component_class_source, parent);
-
-               if (source_class->methods.iterator.init) {
-                       status = source_class->methods.iterator.init(component,
-                                       iterator, init_method_data);
-                       if (status < 0) {
-                               goto error;
-                       }
-               }
-               break;
-       }
-       case BT_COMPONENT_CLASS_TYPE_FILTER:
-       {
-               struct bt_component_class_filter *filter_class;
-               enum bt_notification_iterator_status status;
-
-               filter_class = container_of(class, struct bt_component_class_filter, parent);
-
-               if (filter_class->methods.iterator.init) {
-                       status = filter_class->methods.iterator.init(component,
-                                       iterator, init_method_data);
-                       if (status < 0) {
-                               goto error;
-                       }
-               }
-               break;
-       }
-       default:
-               /* Unreachable. */
-               assert(0);
-       }
-
-       ret_iterator = bt_notification_iterator_validate(iterator);
-       if (ret_iterator != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
-               goto error;
-       }
-
-       return iterator;
-error:
-       BT_PUT(iterator);
-       return iterator;
+       return component ? component->class->type : BT_COMPONENT_CLASS_TYPE_UNKNOWN;
 }
 
 static
@@ -326,7 +262,8 @@ struct bt_component *bt_component_create_with_init_method_data(
        component->initializing = true;
 
        if (component_class->methods.init) {
-               ret = component_class->methods.init(component, params,
+               ret = component_class->methods.init(
+                       bt_private_component_from_component(component), params,
                        init_method_data);
                component->initializing = false;
                if (ret != BT_COMPONENT_STATUS_OK) {
@@ -390,15 +327,21 @@ struct bt_component_class *bt_component_get_class(
        return component ? bt_get(component->class) : NULL;
 }
 
-void *bt_component_get_private_data(struct bt_component *component)
+void *bt_private_component_get_user_data(
+               struct bt_private_component *private_component)
 {
+       struct bt_component *component =
+               bt_component_from_private(private_component);
+
        return component ? component->user_data : NULL;
 }
 
-enum bt_component_status
-bt_component_set_private_data(struct bt_component *component,
+enum bt_component_status bt_private_component_set_user_data(
+               struct bt_private_component *private_component,
                void *data)
 {
+       struct bt_component *component =
+               bt_component_from_private(private_component);
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
        if (!component || !component->initializing) {
@@ -600,7 +543,8 @@ enum bt_component_status bt_component_accept_port_connection(
 
        if (comp->class->methods.accept_port_connection) {
                status = comp->class->methods.accept_port_connection(
-                       comp, port);
+                       bt_private_component_from_component(comp),
+                       bt_private_port_from_port(port));
        }
 
        return status;
@@ -614,6 +558,8 @@ void bt_component_port_disconnected(struct bt_component *comp,
        assert(port);
 
        if (comp->class->methods.port_disconnected) {
-               comp->class->methods.port_disconnected(comp, port);
+               comp->class->methods.port_disconnected(
+                       bt_private_component_from_component(comp),
+                       bt_private_port_from_port(port));
        }
 }
index 702db81d7f73b282e96a83090479ae3776066b14..87d9677883df8a1bb55ebdd0b44ec9d8615e1a99 100644 (file)
  * SOFTWARE.
  */
 
+#include <babeltrace/component/notification/iterator-internal.h>
 #include <babeltrace/component/component-internal.h>
 #include <babeltrace/component/component-source-internal.h>
 #include <babeltrace/component/component-filter-internal.h>
 #include <babeltrace/component/connection-internal.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/component/graph-internal.h>
 #include <babeltrace/component/port-internal.h>
 #include <babeltrace/object-internal.h>
@@ -49,6 +51,12 @@ void bt_connection_destroy(struct bt_object *obj)
        g_free(connection);
 }
 
+struct bt_connection *bt_connection_from_private_connection(
+               struct bt_private_connection *private_connection)
+{
+       return bt_get(bt_connection_from_private(private_connection));
+}
+
 BT_HIDDEN
 struct bt_connection *bt_connection_create(
                struct bt_graph *graph,
@@ -101,14 +109,12 @@ void bt_connection_disconnect_ports(struct bt_connection *conn,
                conn->upstream_port = NULL;
        }
 
-       if (downstream_comp && downstream_comp != acting_comp &&
-                       downstream_comp->class->methods.port_disconnected) {
+       if (downstream_comp && downstream_comp != acting_comp) {
                bt_component_port_disconnected(downstream_comp,
                        downstream_port);
        }
 
-       if (upstream_comp && upstream_comp != acting_comp &&
-                       upstream_comp->class->methods.port_disconnected) {
+       if (upstream_comp && upstream_comp != acting_comp) {
                bt_component_port_disconnected(upstream_comp, upstream_port);
        }
 
@@ -148,35 +154,94 @@ struct bt_port *bt_connection_get_downstream_port(
 }
 
 struct bt_notification_iterator *
-bt_connection_create_notification_iterator(struct bt_connection *connection)
+bt_private_connection_create_notification_iterator(
+               struct bt_private_connection *private_connection)
 {
+       enum bt_notification_iterator_status ret_iterator;
+       enum bt_component_class_type upstream_comp_class_type;
+       struct bt_notification_iterator *iterator = NULL;
+       struct bt_port *upstream_port = NULL;
        struct bt_component *upstream_component = NULL;
-       struct bt_notification_iterator *it = NULL;
+       struct bt_component_class *upstream_comp_class = NULL;
+       struct bt_connection *connection = NULL;
+       bt_component_class_notification_iterator_init_method init_method = NULL;
 
-       if (!connection) {
-               goto end;
+       if (!private_connection) {
+               goto error;
        }
 
+       connection = bt_connection_from_private(private_connection);
+
        if (!connection->upstream_port || !connection->downstream_port) {
-               goto end;
+               goto error;
        }
 
-       upstream_component = bt_port_get_component(connection->upstream_port);
+       upstream_port = connection->upstream_port;
+       assert(upstream_port);
+       upstream_component = bt_port_get_component(upstream_port);
        assert(upstream_component);
+       upstream_comp_class = upstream_component->class;
+
+       if (!upstream_component) {
+               goto error;
+       }
+
+       upstream_comp_class_type =
+               bt_component_get_class_type(upstream_component);
+       if (upstream_comp_class_type != BT_COMPONENT_CLASS_TYPE_SOURCE &&
+                       upstream_comp_class_type != BT_COMPONENT_CLASS_TYPE_FILTER) {
+               /* Unsupported operation. */
+               goto error;
+       }
 
-       switch (bt_component_get_class_type(upstream_component)) {
+       iterator = bt_notification_iterator_create(upstream_component);
+       if (!iterator) {
+               goto error;
+       }
+
+       switch (upstream_comp_class_type) {
        case BT_COMPONENT_CLASS_TYPE_SOURCE:
-               it = bt_component_source_create_notification_iterator(
-                               upstream_component);
+       {
+               struct bt_component_class_source *source_class =
+                       container_of(upstream_comp_class,
+                               struct bt_component_class_source, parent);
+               init_method = source_class->methods.iterator.init;
                break;
+       }
        case BT_COMPONENT_CLASS_TYPE_FILTER:
-               it = bt_component_filter_create_notification_iterator(
-                               upstream_component);
+       {
+               struct bt_component_class_filter *filter_class =
+                       container_of(upstream_comp_class,
+                               struct bt_component_class_filter, parent);
+               init_method = filter_class->methods.iterator.init;
                break;
+       }
        default:
-               goto end;
+               /* Unreachable. */
+               assert(0);
+       }
+
+       if (init_method) {
+               enum bt_notification_iterator_status status = init_method(
+                       bt_private_component_from_component(upstream_component),
+                       bt_private_port_from_port(upstream_port),
+                       bt_private_notification_iterator_from_notification_iterator(iterator));
+               if (status < 0) {
+                       goto error;
+               }
+       }
+
+       ret_iterator = bt_notification_iterator_validate(iterator);
+       if (ret_iterator != BT_NOTIFICATION_ITERATOR_STATUS_OK) {
+               goto error;
        }
+
+       goto end;
+
+error:
+       BT_PUT(iterator);
+
 end:
        bt_put(upstream_component);
-       return it;
+       return iterator;
 }
index da08c7fe7834dad6be1861ebea6689544895f041..2b1eb51f9d0a7c6cecc5a32c54ac154aedff26d0 100644 (file)
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/iterator-internal.h>
 
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_filter_create_notification_iterator(
-               struct bt_component *component)
-{
-       return bt_component_create_iterator(component, NULL);
-}
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_filter_create_notification_iterator_with_init_method_data(
-               struct bt_component *component, void *init_method_data)
-{
-       return bt_component_create_iterator(component, init_method_data);
-}
-
 BT_HIDDEN
 void bt_component_filter_destroy(struct bt_component *component)
 {
@@ -147,21 +133,6 @@ struct bt_port *bt_component_filter_get_default_input_port(
                        DEFAULT_INPUT_PORT_NAME);
 }
 
-struct bt_port *bt_component_filter_add_input_port(
-               struct bt_component *component, const char *name)
-{
-       struct bt_port *port = NULL;
-
-       if (!component ||
-                       component->class->type != BT_COMPONENT_CLASS_TYPE_FILTER) {
-               goto end;
-       }
-
-       port = bt_component_add_input_port(component, name);
-end:
-       return port;
-}
-
 enum bt_component_status bt_component_filter_get_output_port_count(
                struct bt_component *component, uint64_t *count)
 {
@@ -215,10 +186,67 @@ struct bt_port *bt_component_filter_get_default_output_port(
                        DEFAULT_OUTPUT_PORT_NAME);
 }
 
-struct bt_port *bt_component_filter_add_output_port(
-               struct bt_component *component, const char *name)
+struct bt_private_port *
+bt_private_component_filter_get_input_private_port_at_index(
+               struct bt_private_component *private_component, int index)
+{
+       return bt_private_port_from_port(
+               bt_component_filter_get_input_port_at_index(
+                       bt_component_from_private(private_component), index));
+}
+
+struct bt_private_port *
+bt_private_component_filter_get_default_private_input_port(
+               struct bt_private_component *private_component)
+{
+       return bt_private_port_from_port(
+               bt_component_filter_get_default_input_port(
+                       bt_component_from_private(private_component)));
+}
+
+struct bt_private_port *bt_private_component_filter_add_input_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_FILTER) {
+               goto end;
+       }
+
+       port = bt_component_add_input_port(component, name);
+end:
+       return bt_private_port_from_port(port);
+}
+
+struct bt_private_port *
+bt_private_component_filter_get_output_private_port_at_index(
+               struct bt_private_component *private_component, int index)
+{
+       return bt_private_port_from_port(
+               bt_component_filter_get_output_port_at_index(
+                       bt_component_from_private(private_component), index));
+}
+
+struct bt_private_port *
+bt_private_component_filter_get_default_private_output_port(
+               struct bt_private_component *private_component)
+{
+       return bt_private_port_from_port(
+               bt_component_filter_get_default_output_port(
+                       bt_component_from_private(private_component)));
+}
+
+struct bt_private_port *bt_private_component_filter_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_FILTER) {
@@ -227,5 +255,5 @@ struct bt_port *bt_component_filter_add_output_port(
 
        port = bt_component_add_output_port(component, name);
 end:
-       return port;
+       return bt_private_port_from_port(port);
 }
index cffa0d91a2570aa2fa768d575ffdb27aefd65cfd..78a76c2a2098816e74717d91d2f3330516b80605 100644 (file)
@@ -55,7 +55,8 @@ void bt_notification_iterator_destroy(struct bt_object *obj)
                source_class = container_of(comp_class, struct bt_component_class_source, parent);
 
                if (source_class->methods.iterator.destroy) {
-                       source_class->methods.iterator.destroy(iterator);
+                       source_class->methods.iterator.destroy(
+                               bt_private_notification_iterator_from_notification_iterator(iterator));
                }
                break;
        }
@@ -66,7 +67,8 @@ void bt_notification_iterator_destroy(struct bt_object *obj)
                filter_class = container_of(comp_class, struct bt_component_class_filter, parent);
 
                if (filter_class->methods.iterator.destroy) {
-                       filter_class->methods.iterator.destroy(iterator);
+                       filter_class->methods.iterator.destroy(
+                               bt_private_notification_iterator_from_notification_iterator(iterator));
                }
                break;
        }
@@ -125,18 +127,24 @@ end:
        return ret;
 }
 
-void *bt_notification_iterator_get_private_data(
-               struct bt_notification_iterator *iterator)
+void *bt_private_notification_iterator_get_user_data(
+               struct bt_private_notification_iterator *private_iterator)
 {
+       struct bt_notification_iterator *iterator =
+               bt_notification_iterator_from_private(private_iterator);
+
        return iterator ? iterator->user_data : NULL;
 }
 
 enum bt_notification_iterator_status
-bt_notification_iterator_set_private_data(
-               struct bt_notification_iterator *iterator, void *data)
+bt_private_notification_iterator_set_user_data(
+               struct bt_private_notification_iterator *private_iterator,
+               void *data)
 {
        enum bt_notification_iterator_status ret =
                        BT_NOTIFICATION_ITERATOR_STATUS_OK;
+       struct bt_notification_iterator *iterator =
+               bt_notification_iterator_from_private(private_iterator);
 
        if (!iterator) {
                ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
@@ -151,6 +159,8 @@ end:
 struct bt_notification *bt_notification_iterator_get_notification(
                struct bt_notification_iterator *iterator)
 {
+       struct bt_private_notification_iterator *priv_iterator =
+               bt_private_notification_iterator_from_notification_iterator(iterator);
        bt_component_class_notification_iterator_get_method get_method = NULL;
 
        assert(iterator);
@@ -184,12 +194,14 @@ struct bt_notification *bt_notification_iterator_get_notification(
        }
 
        assert(get_method);
-       return get_method(iterator);
+       return get_method(priv_iterator);
 }
 
 enum bt_notification_iterator_status
 bt_notification_iterator_next(struct bt_notification_iterator *iterator)
 {
+       struct bt_private_notification_iterator *priv_iterator =
+               bt_private_notification_iterator_from_notification_iterator(iterator);
        bt_component_class_notification_iterator_next_method next_method = NULL;
 
        assert(iterator);
@@ -223,7 +235,7 @@ bt_notification_iterator_next(struct bt_notification_iterator *iterator)
        }
 
        assert(next_method);
-       return next_method(iterator);
+       return next_method(priv_iterator);
 }
 
 struct bt_component *bt_notification_iterator_get_component(
index e5fcd46ca487fdc255ad953bb4615e10def4fb51..ed4eda054c04801405b41b1921807d389a0eb844 100644 (file)
@@ -43,6 +43,12 @@ void bt_port_destroy(struct bt_object *obj)
        g_free(port);
 }
 
+struct bt_port *bt_port_from_private_port(
+               struct bt_private_port *private_port)
+{
+       return bt_get(bt_port_from_private(private_port));
+}
+
 BT_HIDDEN
 struct bt_port *bt_port_create(struct bt_component *parent_component,
                enum bt_port_type type, const char *name)
@@ -104,6 +110,20 @@ struct bt_component *bt_port_get_component(struct bt_port *port)
        return (struct bt_component *) bt_object_get_parent(port);
 }
 
+struct bt_private_connection *bt_private_port_get_private_connection(
+               struct bt_private_port *private_port)
+{
+       return bt_private_connection_from_connection(bt_port_get_connection(
+               bt_port_from_private(private_port)));
+}
+
+struct bt_private_component *bt_private_port_get_private_component(
+               struct bt_private_port *private_port)
+{
+       return bt_private_component_from_component(bt_port_get_component(
+               bt_port_from_private(private_port)));
+}
+
 BT_HIDDEN
 void bt_port_set_connection(struct bt_port *port,
                struct bt_connection *connection)
@@ -116,9 +136,11 @@ void bt_port_set_connection(struct bt_port *port,
        port->connection = connection;
 }
 
-int bt_port_remove_from_component(struct bt_port *port)
+int bt_private_port_remove_from_component(
+               struct bt_private_port *private_port)
 {
        int ret = 0;
+       struct bt_port *port = bt_port_from_private(private_port);
        struct bt_component *comp = NULL;
 
        if (!port) {
index 338c2968e289b928cdc42d70a5772726a2925f32..91fa2353313ad310c5d0d718ed6cb46d4d15c1b5 100644 (file)
@@ -95,7 +95,7 @@ enum bt_component_status bt_component_sink_consume(
 
        sink_class = container_of(component->class, struct bt_component_class_sink, parent);
        assert(sink_class->methods.consume);
-       ret = sink_class->methods.consume(component);
+       ret = sink_class->methods.consume(bt_private_component_from_component(component));
 end:
        return ret;
 }
@@ -153,10 +153,30 @@ struct bt_port *bt_component_sink_get_default_input_port(
                        DEFAULT_INPUT_PORT_NAME);
 }
 
-struct bt_port *bt_component_sink_add_input_port(
-               struct bt_component *component, const char *name)
+struct bt_private_port *
+bt_private_component_sink_get_input_private_port_at_index(
+               struct bt_private_component *private_component, int index)
+{
+       return bt_private_port_from_port(
+               bt_component_sink_get_input_port_at_index(
+                       bt_component_from_private(private_component), index));
+}
+
+struct bt_private_port *bt_private_component_sink_get_default_private_input_port(
+               struct bt_private_component *private_component)
+{
+       return bt_private_port_from_port(
+               bt_component_sink_get_default_input_port(
+                       bt_component_from_private(private_component)));
+}
+
+struct bt_private_port *bt_private_component_sink_add_input_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_SINK) {
@@ -165,5 +185,5 @@ struct bt_port *bt_component_sink_add_input_port(
 
        port = bt_component_add_input_port(component, name);
 end:
-       return port;
+       return bt_private_port_from_port(port);
 }
index da40aa87a822a9797ee22b4aac77d88393b0d69e..bddd2f6a2408fee405133de591b0d6824e0eb7c0 100644 (file)
@@ -79,20 +79,6 @@ end:
        return source ? &source->parent : NULL;
 }
 
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator(
-               struct bt_component *component)
-{
-       return bt_component_create_iterator(component, NULL);
-}
-
-BT_HIDDEN
-struct bt_notification_iterator *bt_component_source_create_notification_iterator_with_init_method_data(
-               struct bt_component *component, void *init_method_data)
-{
-       return bt_component_create_iterator(component, init_method_data);
-}
-
 enum bt_component_status bt_component_source_get_output_port_count(
                struct bt_component *component, uint64_t *count)
 {
@@ -146,10 +132,38 @@ struct bt_port *bt_component_source_get_default_output_port(
                        DEFAULT_OUTPUT_PORT_NAME);
 }
 
-struct bt_port *bt_component_source_add_output_port(
-               struct bt_component *component, const char *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) {
@@ -158,5 +172,5 @@ struct bt_port *bt_component_source_add_output_port(
 
        port = bt_component_add_output_port(component, name);
 end:
-       return port;
+       return bt_private_port_from_port(port);
 }
index ee0c560697bb13bbaac4b1e4fb1ed6d9e1c21d37..4db53f06a1c45ad23c9332edcd72dbeffc49b1d8 100644 (file)
 
 #include <babeltrace/ctf-ir/packet.h>
 #include <babeltrace/ctf-ir/clock-class.h>
+#include <babeltrace/component/private-component.h>
+#include <babeltrace/component/component.h>
 #include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/private-iterator.h>
 #include <babeltrace/component/notification/stream.h>
 #include <babeltrace/component/notification/event.h>
 #include <babeltrace/component/notification/packet.h>
@@ -51,13 +54,14 @@ BT_HIDDEN
 bool ctf_fs_debug;
 
 enum bt_notification_iterator_status ctf_fs_iterator_next(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *iterator);
 
 struct bt_notification *ctf_fs_iterator_get(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        struct ctf_fs_iterator *ctf_it =
-                       bt_notification_iterator_get_private_data(iterator);
+                       bt_private_notification_iterator_get_user_data(
+                               iterator);
 
        if (!ctf_it->current_notification) {
                (void) ctf_fs_iterator_next(iterator);
@@ -246,7 +250,7 @@ end:
 }
 
 enum bt_notification_iterator_status ctf_fs_iterator_next(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        int heap_ret;
        struct bt_ctf_stream *stream = NULL;
@@ -256,7 +260,8 @@ enum bt_notification_iterator_status ctf_fs_iterator_next(
        enum bt_notification_iterator_status ret =
                        BT_NOTIFICATION_ITERATOR_STATUS_OK;
        struct ctf_fs_iterator *ctf_it =
-                       bt_notification_iterator_get_private_data(iterator);
+                       bt_private_notification_iterator_get_user_data(
+                               iterator);
 
        notification = bt_notification_heap_pop(ctf_it->pending_notifications);
        if (!notification && !ctf_it->pending_streams) {
@@ -365,9 +370,9 @@ void ctf_fs_iterator_destroy_data(struct ctf_fs_iterator *ctf_it)
        g_free(ctf_it);
 }
 
-void ctf_fs_iterator_destroy(struct bt_notification_iterator *it)
+void ctf_fs_iterator_destroy(struct bt_private_notification_iterator *it)
 {
-       void *data = bt_notification_iterator_get_private_data(it);
+       void *data = bt_private_notification_iterator_get_user_data(it);
 
        ctf_fs_iterator_destroy_data(data);
 }
@@ -584,9 +589,10 @@ end:
        return ret;
 }
 
-enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *source,
-               struct bt_notification_iterator *it,
-               UNUSED_VAR void *init_method_data)
+enum bt_notification_iterator_status ctf_fs_iterator_init(
+               struct bt_private_component *source,
+               struct bt_private_port *port,
+               struct bt_private_notification_iterator *it)
 {
        struct ctf_fs_iterator *ctf_it;
        struct ctf_fs_component *ctf_fs;
@@ -594,7 +600,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *s
 
        assert(source && it);
 
-       ctf_fs = bt_component_get_private_data(source);
+       ctf_fs = bt_private_component_get_user_data(source);
        if (!ctf_fs) {
                ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
                goto end;
@@ -627,7 +633,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *s
                goto error;
        }
 
-       ret = bt_notification_iterator_set_private_data(it, ctf_it);
+       ret = bt_private_notification_iterator_set_user_data(it, ctf_it);
        if (ret) {
                goto error;
        }
@@ -635,7 +641,7 @@ enum bt_notification_iterator_status ctf_fs_iterator_init(struct bt_component *s
 end:
        return ret;
 error:
-       (void) bt_notification_iterator_set_private_data(it, NULL);
+       (void) bt_private_notification_iterator_set_user_data(it, NULL);
        ctf_fs_iterator_destroy_data(ctf_it);
        goto end;
 }
@@ -656,9 +662,9 @@ void ctf_fs_destroy_data(struct ctf_fs_component *ctf_fs)
        g_free(ctf_fs);
 }
 
-void ctf_fs_destroy(struct bt_component *component)
+void ctf_fs_destroy(struct bt_private_component *component)
 {
-       void *data = bt_component_get_private_data(component);
+       void *data = bt_private_component_get_user_data(component);
 
        ctf_fs_destroy_data(data);
 }
@@ -711,7 +717,7 @@ end:
 }
 
 BT_HIDDEN
-enum bt_component_status ctf_fs_init(struct bt_component *source,
+enum bt_component_status ctf_fs_init(struct bt_private_component *source,
                struct bt_value *params, UNUSED_VAR void *init_method_data)
 {
        struct ctf_fs_component *ctf_fs;
@@ -725,14 +731,14 @@ enum bt_component_status ctf_fs_init(struct bt_component *source,
                goto end;
        }
 
-       ret = bt_component_set_private_data(source, ctf_fs);
+       ret = bt_private_component_set_user_data(source, ctf_fs);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
 end:
        return ret;
 error:
-       (void) bt_component_set_private_data(source, NULL);
+       (void) bt_private_component_set_user_data(source, NULL);
         ctf_fs_destroy_data(ctf_fs);
        return ret;
 }
index 80e56c1b6f94013fdc330391285ec4ddc6ed51bd..3749137d820936e71283c0ef637410e3c2e67680 100644 (file)
@@ -106,25 +106,25 @@ struct ctf_fs_component {
 };
 
 BT_HIDDEN
-enum bt_component_status ctf_fs_init(struct bt_component *source,
+enum bt_component_status ctf_fs_init(struct bt_private_component *source,
                struct bt_value *params, void *init_method_data);
 
 BT_HIDDEN
-void ctf_fs_destroy(struct bt_component *component);
+void ctf_fs_destroy(struct bt_private_component *component);
 
 BT_HIDDEN
 enum bt_notification_iterator_status ctf_fs_iterator_init(
-               struct bt_component *source,
-               struct bt_notification_iterator *it,
-               void *init_method_data);
+               struct bt_private_component *source,
+               struct bt_private_port *port,
+               struct bt_private_notification_iterator *it);
 
-void ctf_fs_iterator_destroy(struct bt_notification_iterator *it);
+void ctf_fs_iterator_destroy(struct bt_private_notification_iterator *it);
 
 enum bt_notification_iterator_status ctf_fs_iterator_next(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *iterator);
 
 struct bt_notification *ctf_fs_iterator_get(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *iterator);
 
 BT_HIDDEN
 struct bt_value *ctf_fs_query(struct bt_component_class *comp_class,
index 17d8e87eb4ac7efaeca71e36d91cedab6159c44f..61c3f19063a6e84a1283e5b0f37c3597a2933a0c 100644 (file)
 #define LTTNG_LIVE_COMPONENT_DESCRIPTION "Component implementing an LTTng-live client."
 
 BT_HIDDEN
-enum bt_component_status lttng_live_init(struct bt_component *source,
+enum bt_component_status lttng_live_init(struct bt_private_component *source,
                struct bt_value *params, void *init_method_data);
 
 BT_HIDDEN
 struct bt_notification *lttng_live_iterator_get(
-        struct bt_notification_iterator *iterator);
+        struct bt_private_notification_iterator *iterator);
 
 BT_HIDDEN
 enum bt_notification_iterator_status lttng_live_iterator_next(
-        struct bt_notification_iterator *iterator);
+        struct bt_private_notification_iterator *iterator);
 
 #endif /* BABELTRACE_PLUGIN_CTF_LTTNG_LIVE_INTERNAL_H */
index 5f082fcc5ef0f4a49016052cd24797f7005f8adf..6b11e434714cd4b55a796d02fc1fed61ba8979ce 100644 (file)
 
 BT_HIDDEN
 struct bt_notification *lttng_live_iterator_get(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        return NULL;
 }
 
 BT_HIDDEN
 enum bt_notification_iterator_status lttng_live_iterator_next(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 BT_HIDDEN
-enum bt_component_status lttng_live_init(struct bt_component *component,
+enum bt_component_status lttng_live_init(struct bt_private_component *component,
                struct bt_value *params, UNUSED_VAR void *init_method_data)
 {
        return BT_COMPONENT_STATUS_OK;
index 745e0803f6b1c7cac5e1332aeaf5cdd78f9b9a5e..9a58310b3cb5223c588412f38725ede59084d857 100644 (file)
@@ -55,15 +55,15 @@ end:
 }
 
 static
-void destroy_muxer(struct bt_component *component)
+void destroy_muxer(struct bt_private_component *component)
 {
-       void *data = bt_component_get_private_data(component);
+       void *data = bt_private_component_get_user_data(component);
 
        destroy_muxer_data(data);
 }
 
 enum bt_component_status muxer_component_init(
-       struct bt_component *component, struct bt_value *params,
+       struct bt_private_component *component, struct bt_value *params,
        UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
@@ -74,7 +74,7 @@ enum bt_component_status muxer_component_init(
                goto end;
        }
 
-       ret = bt_component_set_private_data(component, muxer);
+       ret = bt_private_component_set_user_data(component, muxer);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
@@ -87,14 +87,14 @@ error:
 
 static
 struct bt_notification *muxer_iterator_get(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        return NULL;
 }
 
 static
 enum bt_notification_iterator_status muxer_iterator_next(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
index 70111631eca0e4151dde5f36c65287c818bc3455..ecd6bbea65e54fc2a2336e5cc1896192a799ce68 100644 (file)
 
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
 #include <babeltrace/component/component-sink.h>
 #include <babeltrace/component/port.h>
+#include <babeltrace/component/private-port.h>
 #include <babeltrace/component/connection.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/iterator.h>
 #include <babeltrace/component/notification/event.h>
@@ -106,9 +109,9 @@ error:
 }
 
 static
-void destroy_text(struct bt_component *component)
+void destroy_text(struct bt_private_component *component)
 {
-       void *data = bt_component_get_private_data(component);
+       void *data = bt_private_component_get_user_data(component);
 
        destroy_text_data(data);
 }
@@ -158,20 +161,21 @@ end:
 }
 
 static
-enum bt_component_status text_accept_port_connection(struct bt_component *component,
-               struct bt_port *self_port)
+enum bt_component_status text_accept_port_connection(
+               struct bt_private_component *component,
+               struct bt_private_port *self_port)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_connection *connection;
+       struct bt_private_connection *connection;
        struct text_component *text;
 
-       text = bt_component_get_private_data(component);
+       text = bt_private_component_get_user_data(component);
        assert(text);
        assert(!text->input_iterator);
-       connection = bt_port_get_connection(self_port);
+       connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
-       text->input_iterator = bt_connection_create_notification_iterator(
-                       connection);
+       text->input_iterator =
+               bt_private_connection_create_notification_iterator(connection);
 
        if (!text->input_iterator) {
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -182,12 +186,13 @@ enum bt_component_status text_accept_port_connection(struct bt_component *compon
 }
 
 static
-enum bt_component_status run(struct bt_component *component)
+enum bt_component_status run(struct bt_private_component *component)
 {
        enum bt_component_status ret;
        struct bt_notification *notification = NULL;
        struct bt_notification_iterator *it;
-       struct text_component *text = bt_component_get_private_data(component);
+       struct text_component *text =
+               bt_private_component_get_user_data(component);
 
        it = text->input_iterator;
 
@@ -711,7 +716,8 @@ void init_stream_packet_context_quarks(void)
 
 static
 enum bt_component_status text_component_init(
-               struct bt_component *component, struct bt_value *params,
+               struct bt_private_component *component,
+               struct bt_value *params,
                UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
@@ -738,7 +744,7 @@ enum bt_component_status text_component_init(
 
        set_use_colors(text);
 
-       ret = bt_component_set_private_data(component, text);
+       ret = bt_private_component_set_user_data(component, text);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
index 79b8f5bad557df62f248bdeef39fb3f122eab376..3487b6e7837c1a1d07e3e1b1f72caa2a1ba09e70 100644 (file)
@@ -22,6 +22,9 @@
 
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
+#include <babeltrace/component/private-port.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/component/component-sink.h>
 #include <babeltrace/component/notification/iterator.h>
 #include <babeltrace/component/notification/notification.h>
@@ -38,17 +41,17 @@ void destroy_private_dummy_data(struct dummy *dummy)
        g_free(dummy);
 }
 
-void dummy_destroy(struct bt_component *component)
+void dummy_destroy(struct bt_private_component *component)
 {
        struct dummy *dummy;
 
        assert(component);
-       dummy = bt_component_get_private_data(component);
+       dummy = bt_private_component_get_user_data(component);
        assert(dummy);
        destroy_private_dummy_data(dummy);
 }
 
-enum bt_component_status dummy_init(struct bt_component *component,
+enum bt_component_status dummy_init(struct bt_private_component *component,
                struct bt_value *params, UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
@@ -66,7 +69,7 @@ enum bt_component_status dummy_init(struct bt_component *component,
                goto end;
        }
 
-       ret = bt_component_set_private_data(component, dummy);
+       ret = bt_private_component_set_user_data(component, dummy);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
@@ -77,21 +80,23 @@ error:
        return ret;
 }
 
-enum bt_component_status dummy_accept_port_connection(struct bt_component *component,
-               struct bt_port *self_port)
+enum bt_component_status dummy_accept_port_connection(
+               struct bt_private_component *component,
+               struct bt_private_port *self_port)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
        struct dummy *dummy;
-       struct bt_connection *connection;
        struct bt_notification_iterator *iterator;
+       struct bt_private_connection *connection;
 
-       dummy = bt_component_get_private_data(component);
+       dummy = bt_private_component_get_user_data(component);
        assert(dummy);
 
-       connection = bt_port_get_connection(self_port);
+       connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
 
-       iterator = bt_connection_create_notification_iterator(connection);
+       iterator = bt_private_connection_create_notification_iterator(
+               connection);
        if (!iterator) {
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
@@ -103,14 +108,14 @@ end:
        return ret;
 }
 
-enum bt_component_status dummy_consume(struct bt_component *component)
+enum bt_component_status dummy_consume(struct bt_private_component *component)
 {
        enum bt_component_status ret;
        struct bt_notification *notif = NULL;
        size_t i;
        struct dummy *dummy;
 
-       dummy = bt_component_get_private_data(component);
+       dummy = bt_private_component_get_user_data(component);
        assert(dummy);
 
        /* Consume one notification from each iterator. */
index 0d388cb391c61434264b4a3044fe4b8c575b566b..4800d4ff3066f909a1635dd55cd1d8fd7443dd95 100644 (file)
  */
 
 #include <glib.h>
-#include <babeltrace/component/component.h>
-#include <babeltrace/component/port.h>
-#include <babeltrace/component/connection.h>
+#include <babeltrace/component/private-component.h>
+#include <babeltrace/component/private-port.h>
 
 struct dummy {
        GPtrArray *iterators;
 };
 
-enum bt_component_status dummy_init(struct bt_component *component,
+enum bt_component_status dummy_init(struct bt_private_component *component,
                struct bt_value *params, void *init_method_data);
-void dummy_destroy(struct bt_component *component);
+void dummy_destroy(struct bt_private_component *component);
 enum bt_component_status dummy_accept_port_connection(
-               struct bt_component *component,
-               struct bt_port *own_port);
-enum bt_component_status dummy_consume(struct bt_component *component);
+               struct bt_private_component *component,
+               struct bt_private_port *own_port);
+enum bt_component_status dummy_consume(struct bt_private_component *component);
 
 #endif /* BABELTRACE_PLUGINS_UTILS_DUMMY_H */
index 652e3ac99731fa13fc9afc00d941246010b580e9..fff388b1399c71d80508f09658e34362a02e7ec5 100644 (file)
 #include "trimmer.h"
 #include "iterator.h"
 #include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/private-iterator.h>
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/event.h>
 #include <babeltrace/component/notification/stream.h>
 #include <babeltrace/component/notification/packet.h>
 #include <babeltrace/component/component-filter.h>
-#include <babeltrace/component/port.h>
-#include <babeltrace/component/connection.h>
+#include <babeltrace/component/private-component-filter.h>
+#include <babeltrace/component/private-port.h>
+#include <babeltrace/component/private-connection.h>
+#include <babeltrace/component/private-component.h>
 #include <babeltrace/ctf-ir/event.h>
 #include <babeltrace/ctf-ir/stream.h>
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <plugins-common.h>
 
 BT_HIDDEN
-void trimmer_iterator_destroy(struct bt_notification_iterator *it)
+void trimmer_iterator_destroy(struct bt_private_notification_iterator *it)
 {
        struct trimmer_iterator *it_data;
 
-       it_data = bt_notification_iterator_get_private_data(it);
+       it_data = bt_private_notification_iterator_get_user_data(it);
        assert(it_data);
 
        bt_put(it_data->current_notification);
@@ -61,15 +64,15 @@ void trimmer_iterator_destroy(struct bt_notification_iterator *it)
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_init(
-               struct bt_component *component,
-               struct bt_notification_iterator *iterator,
-               UNUSED_VAR void *init_method_data)
+               struct bt_private_component *component,
+               struct bt_private_port *port,
+               struct bt_private_notification_iterator *iterator)
 {
        enum bt_notification_iterator_status ret =
                BT_NOTIFICATION_ITERATOR_STATUS_OK;
        enum bt_notification_iterator_status it_ret;
-       struct bt_port *input_port = NULL;
-       struct bt_connection *connection = NULL;
+       struct bt_private_port *input_port = NULL;
+       struct bt_private_connection *connection = NULL;
        struct trimmer_iterator *it_data = g_new0(struct trimmer_iterator, 1);
 
        if (!it_data) {
@@ -78,19 +81,21 @@ enum bt_notification_iterator_status trimmer_iterator_init(
        }
 
        /* Create a new iterator on the upstream component. */
-       input_port = bt_component_filter_get_default_input_port(component);
+       input_port = bt_private_component_filter_get_default_input_private_port(
+               component);
        assert(input_port);
-       connection = bt_port_get_connection(input_port);
+       connection = bt_private_port_get_private_connection(input_port);
        assert(connection);
 
-       it_data->input_iterator = bt_connection_create_notification_iterator(
-                       connection);
+       it_data->input_iterator =
+               bt_private_connection_create_notification_iterator(connection);
        if (!it_data->input_iterator) {
                ret = BT_NOTIFICATION_ITERATOR_STATUS_NOMEM;
                goto end;
        }
 
-       it_ret = bt_notification_iterator_set_private_data(iterator, it_data);
+       it_ret = bt_private_notification_iterator_set_user_data(iterator,
+               it_data);
        if (it_ret) {
                goto end;
        }
@@ -102,11 +107,11 @@ end:
 
 BT_HIDDEN
 struct bt_notification *trimmer_iterator_get(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        struct trimmer_iterator *trim_it;
 
-       trim_it = bt_notification_iterator_get_private_data(iterator);
+       trim_it = bt_private_notification_iterator_get_user_data(iterator);
        assert(trim_it);
 
        if (!trim_it->current_notification) {
@@ -411,22 +416,23 @@ enum bt_notification_iterator_status evaluate_notification(
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_next(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *iterator)
 {
        struct trimmer_iterator *trim_it = NULL;
-       struct bt_component *component = NULL;
+       struct bt_private_component *component = NULL;
        struct trimmer *trimmer = NULL;
        struct bt_notification_iterator *source_it = NULL;
        enum bt_notification_iterator_status ret =
                        BT_NOTIFICATION_ITERATOR_STATUS_OK;
        bool notification_in_range = false;
 
-       trim_it = bt_notification_iterator_get_private_data(iterator);
+       trim_it = bt_private_notification_iterator_get_user_data(iterator);
        assert(trim_it);
 
-       component = bt_notification_iterator_get_component(iterator);
+       component = bt_private_notification_iterator_get_private_component(
+               iterator);
        assert(component);
-       trimmer = bt_component_get_private_data(component);
+       trimmer = bt_private_component_get_user_data(component);
        assert(trimmer);
 
        source_it = trim_it->input_iterator;
@@ -467,7 +473,8 @@ end:
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_seek_time(
-               struct bt_notification_iterator *iterator, int64_t time)
+               struct bt_private_notification_iterator *iterator,
+               int64_t time)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
index ef8c4eb8b96ebdd14772bf9ee953a977bb38c116..2edbbc71c37b99603802dd3d46a6e07d77feb81d 100644 (file)
@@ -30,6 +30,8 @@
 #include "trimmer.h"
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/private-component.h>
+#include <babeltrace/component/private-port.h>
 
 struct trimmer_iterator {
        /* Input iterator associated with this output iterator. */
@@ -39,22 +41,24 @@ struct trimmer_iterator {
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_init(
-               struct bt_component *component,
-               struct bt_notification_iterator *iterator, void *init_method_data);
+               struct bt_private_component *component,
+               struct bt_private_port *port,
+               struct bt_private_notification_iterator *iterator);
 
 BT_HIDDEN
-void trimmer_iterator_destroy(struct bt_notification_iterator *it);
+void trimmer_iterator_destroy(struct bt_private_notification_iterator *it);
 
 BT_HIDDEN
 struct bt_notification *trimmer_iterator_get(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *iterator);
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_next(
-               struct bt_notification_iterator *iterator);
+               struct bt_private_notification_iterator *iterator);
 
 BT_HIDDEN
 enum bt_notification_iterator_status trimmer_iterator_seek_time(
-               struct bt_notification_iterator *iterator, int64_t time);
+               struct bt_private_notification_iterator *iterator,
+               int64_t time);
 
 #endif /* BABELTRACE_PLUGIN_TRIMMER_ITERATOR_H */
index af838d723e8adfbed3b938e6e4662f5e3d57ef8c..1007886857d4e7a2624a5452e6ceabf865f5504d 100644 (file)
 
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
 #include <babeltrace/component/component-filter.h>
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/iterator.h>
+#include <babeltrace/component/notification/private-iterator.h>
 #include <babeltrace/component/notification/event.h>
 #include <plugins-common.h>
 #include "trimmer.h"
@@ -56,9 +58,9 @@ end:
        return trimmer;
 }
 
-void destroy_trimmer(struct bt_component *component)
+void destroy_trimmer(struct bt_private_component *component)
 {
-       void *data = bt_component_get_private_data(component);
+       void *data = bt_private_component_get_user_data(component);
 
        destroy_trimmer_data(data);
 }
@@ -285,7 +287,8 @@ lazy:
 }
 
 static
-enum bt_component_status init_from_params(struct trimmer *trimmer, struct bt_value *params)
+enum bt_component_status init_from_params(struct trimmer *trimmer,
+               struct bt_value *params)
 {
        struct bt_value *value = NULL;
        bool gmt = false;
@@ -349,7 +352,7 @@ end:
 }
 
 enum bt_component_status trimmer_component_init(
-       struct bt_component *component, struct bt_value *params,
+       struct bt_private_component *component, struct bt_value *params,
        UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
@@ -360,7 +363,7 @@ enum bt_component_status trimmer_component_init(
                goto end;
        }
 
-       ret = bt_component_set_private_data(component, trimmer);
+       ret = bt_private_component_set_user_data(component, trimmer);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
index 655a60cb8971d7fd30456399c24b16b4ef6f9a4f..fafb7ada0d56ad04ade3546f57fba94ba44a00b9 100644 (file)
@@ -30,7 +30,7 @@
 #include <stdbool.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/values.h>
-#include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
 
 #define NSEC_PER_SEC   1000000000LL
 
@@ -51,9 +51,9 @@ struct trimmer {
 };
 
 enum bt_component_status trimmer_component_init(
-       struct bt_component *component, struct bt_value *params,
-       void *init_method_data);
+       struct bt_private_component *component,
+       struct bt_value *params, void *init_method_data);
 
-void destroy_trimmer(struct bt_component *component);
+void destroy_trimmer(struct bt_private_component *component);
 
 #endif /* BABELTRACE_PLUGINS_UTILS_TRIMMER_H */
index ae01e5550476d900f9c9d6243bcd3128719b705f..360d0d685d12c171c6e792088636f5ce9e4bfade 100644 (file)
 #include <babeltrace/ctf-ir/packet.h>
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/component/component.h>
+#include <babeltrace/component/private-component.h>
 #include <babeltrace/component/component-sink.h>
-#include <babeltrace/component/port.h>
-#include <babeltrace/component/connection.h>
+#include <babeltrace/component/private-component-sink.h>
+#include <babeltrace/component/private-port.h>
+#include <babeltrace/component/private-connection.h>
 #include <babeltrace/component/notification/notification.h>
 #include <babeltrace/component/notification/iterator.h>
 #include <babeltrace/component/notification/event.h>
@@ -55,10 +57,10 @@ void destroy_writer_component_data(struct writer_component *writer_component)
 }
 
 static
-void destroy_writer_component(struct bt_component *component)
+void destroy_writer_component(struct bt_private_component *component)
 {
        struct writer_component *writer_component = (struct writer_component *)
-               bt_component_get_private_data(component);
+               bt_private_component_get_user_data(component);
 
        destroy_writer_component_data(writer_component);
        g_free(writer_component);
@@ -186,19 +188,20 @@ end:
 
 static
 enum bt_component_status writer_component_accept_port_connection(
-               struct bt_component *component, struct bt_port *self_port)
+               struct bt_private_component *component,
+               struct bt_private_port *self_port)
 {
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
-       struct bt_connection *connection;
+       struct bt_private_connection *connection;
        struct writer_component *writer;
 
-       writer = bt_component_get_private_data(component);
+       writer = bt_private_component_get_user_data(component);
        assert(writer);
        assert(!writer->input_iterator);
-       connection = bt_port_get_connection(self_port);
+       connection = bt_private_port_get_private_connection(self_port);
        assert(connection);
-        writer->input_iterator = bt_connection_create_notification_iterator(
-                       connection);
+        writer->input_iterator =
+               bt_private_connection_create_notification_iterator(connection);
 
        if (!writer->input_iterator) {
                ret = BT_COMPONENT_STATUS_ERROR;
@@ -208,14 +211,14 @@ enum bt_component_status writer_component_accept_port_connection(
 }
 
 static
-enum bt_component_status run(struct bt_component *component)
+enum bt_component_status run(struct bt_private_component *component)
 {
        enum bt_component_status ret;
        enum bt_notification_iterator_status it_status;
        struct bt_notification *notification = NULL;
        struct bt_notification_iterator *it;
        struct writer_component *writer_component =
-               bt_component_get_private_data(component);
+               bt_private_component_get_user_data(component);
 
        it = writer_component->input_iterator;
        assert(it);
@@ -241,7 +244,7 @@ end:
 
 static
 enum bt_component_status writer_component_init(
-       struct bt_component *component, struct bt_value *params,
+       struct bt_private_component *component, struct bt_value *params,
        UNUSED_VAR void *init_method_data)
 {
        enum bt_component_status ret;
@@ -275,7 +278,7 @@ enum bt_component_status writer_component_init(
                goto error;
        }
 
-       ret = bt_component_set_private_data(component, writer_component);
+       ret = bt_private_component_set_user_data(component, writer_component);
        if (ret != BT_COMPONENT_STATUS_OK) {
                goto error;
        }
index a3b7f84b3e16966939b66c8f440b66fd7a941b5c..b1f8aea6b9afb304d74d66325bc43374b5c4e7b7 100644 (file)
 #include <babeltrace/ref.h>
 #include <assert.h>
 
-static enum bt_component_status sink_consume(struct bt_component *component)
+static enum bt_component_status sink_consume(
+               struct bt_private_component *private_component)
 {
        return BT_COMPONENT_STATUS_OK;
 }
 
 static enum bt_notification_iterator_status dummy_iterator_init_method(
-               struct bt_component *component,
-               struct bt_notification_iterator *iterator,
-               void *init_method_data)
+               struct bt_private_component *private_component,
+               struct bt_private_port *private_port,
+               struct bt_private_notification_iterator *private_iterator)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 static void dummy_iterator_destroy_method(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *private_iterator)
 {
 }
 
 static struct bt_notification *dummy_iterator_get_method(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *private_iterator)
 {
        return NULL;
 }
 
 static enum bt_notification_iterator_status dummy_iterator_next_method(
-               struct bt_notification_iterator *iterator)
+               struct bt_private_notification_iterator *private_iterator)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
 
 static enum bt_notification_iterator_status dummy_iterator_seek_time_method(
-               struct bt_notification_iterator *iterator, int64_t time)
+               struct bt_private_notification_iterator *private_iterator,
+               int64_t time)
 {
        return BT_NOTIFICATION_ITERATOR_STATUS_OK;
 }
This page took 0.063142 seconds and 4 git commands to generate.