Add iterator and source implementations
[babeltrace.git] / plugins / iterator.c
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..66f918c8dbe629a266fd14380c5e915943d970fa 100644 (file)
@@ -0,0 +1,91 @@
+/*
+ * iterator.c
+ *
+ * Babeltrace Notification Iterator
+ *
+ * Copyright 2015 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <babeltrace/compiler.h>
+#include <babeltrace/plugin/component.h>
+#include <babeltrace/plugin/source-internal.h>
+#include <babeltrace/plugin/notification/iterator.h>
+#include <babeltrace/plugin/notification/iterator-internal.h>
+
+static
+void bt_notification_iterator_destroy(struct bt_notification_iterator *iterator)
+{
+       
+}
+
+BT_HIDDEN
+struct bt_notification_iterator *bt_notification_iterator_create(
+               struct bt_component *component)
+{
+       struct bt_notification_iterator *iterator = NULL;
+
+       if (!component || bt_component_get_type(component) != BT_COMPONENT_TYPE_SOURCE) {
+               goto end;
+       }
+
+       iterator = g_new0(struct bt_notification_iterator, 1);
+       if (!iterator) {
+               goto end;
+       }
+
+       bt_ctf_ref_init(&iterator->ref_count);
+end:
+       return iterator;
+}
+
+BT_HIDDEN
+enum bt_notification_iterator_status bt_notification_iterator_validate(
+               struct bt_notification_iterator *iterator)
+{
+       enum bt_notification_iterator_status ret = BT_NOTIFICATION_ITERATOR_STATUS_OK;
+
+       if (!iterator || !iterator->get || !iterator->next) {
+               ret = BT_NOTIFICATION_ITERATOR_STATUS_INVAL;
+               goto end;
+       }
+end:
+       return ret;
+}
+
+void bt_notification_iterator_get(struct bt_notification_iterator *iterator)
+{
+       if (!iterator) {
+               return;
+       }
+
+       bt_ctf_ref_get(&iterator->ref_count);
+}
+
+void bt_notification_iterator_put(struct bt_notification_iterator *iterator)
+{
+       if (!iterator) {
+               return;
+       }
+
+       bt_ctf_ref_put(&iterator->ref_count, bt_notification_iterator_destroy);
+}
This page took 0.023296 seconds and 4 git commands to generate.