X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=plugins%2Fiterator.c;h=66f918c8dbe629a266fd14380c5e915943d970fa;hb=47e5a0329d01fa74bdf8b3fdcf75940f6789c93f;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=48c86b66fe007c348e5ce543d8ee1ce7a066f894;p=babeltrace.git diff --git a/plugins/iterator.c b/plugins/iterator.c index e69de29b..66f918c8 100644 --- a/plugins/iterator.c +++ b/plugins/iterator.c @@ -0,0 +1,91 @@ +/* + * iterator.c + * + * Babeltrace Notification Iterator + * + * Copyright 2015 Jérémie Galarneau + * + * Author: Jérémie Galarneau + * + * 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 +#include +#include +#include +#include + +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); +}