X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Flib%2Fgraph%2Fcomponent-class.c;h=be0fdf70bdaacb99856ee47b0448eaef39fc080c;hb=43c59509042845f8d42c3e99ec74d45fa2dc0908;hp=9d7e17b57bbb447b1a8be8d3a19246e515fdf4be;hpb=d24d56638469189904fb6ddbb3c725817b3e9417;p=babeltrace.git diff --git a/src/lib/graph/component-class.c b/src/lib/graph/component-class.c index 9d7e17b5..be0fdf70 100644 --- a/src/lib/graph/component-class.c +++ b/src/lib/graph/component-class.c @@ -28,21 +28,15 @@ #include "lib/assert-pre.h" #include "compat/compiler.h" #include -#include -#include -#include -#include -#include -#include -#include #include #include #include "component-class.h" #include "lib/func-status.h" +#include "lib/graph/message-iterator-class.h" -#define BT_ASSERT_PRE_COMP_CLS_HOT(_cc) \ - BT_ASSERT_PRE_HOT(((const struct bt_component_class *) (_cc)), \ +#define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \ + BT_ASSERT_PRE_DEV_HOT(((const struct bt_component_class *) (_cc)), \ "Component class", ": %!+C", (_cc)) static @@ -83,11 +77,25 @@ void destroy_component_class(struct bt_object *obj) class->help = NULL; } + if (class->plugin_name) { + g_string_free(class->plugin_name, TRUE); + class->plugin_name = NULL; + } + if (class->destroy_listeners) { g_array_free(class->destroy_listeners, TRUE); class->destroy_listeners = NULL; } + if (bt_component_class_has_message_iterator_class(class)) { + struct bt_component_class_with_iterator_class *class_with_iter_class = + container_of(class, struct bt_component_class_with_iterator_class, parent); + + BT_ASSERT(class_with_iter_class->msg_iter_cls); + bt_message_iterator_class_put_ref(class_with_iter_class->msg_iter_cls); + class_with_iter_class->msg_iter_cls = NULL; + } + g_free(class); } @@ -101,26 +109,32 @@ int bt_component_class_init(struct bt_component_class *class, class->type = type; class->name = g_string_new(name); if (!class->name) { - BT_LOGE_STR("Failed to allocate a GString."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString."); goto error; } class->description = g_string_new(NULL); if (!class->description) { - BT_LOGE_STR("Failed to allocate a GString."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString."); goto error; } class->help = g_string_new(NULL); if (!class->help) { - BT_LOGE_STR("Failed to allocate a GString."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString."); + goto error; + } + + class->plugin_name = g_string_new(NULL); + if (!class->plugin_name) { + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GString."); goto error; } class->destroy_listeners = g_array_new(FALSE, TRUE, sizeof(struct bt_component_class_destroy_listener)); if (!class->destroy_listeners) { - BT_LOGE_STR("Failed to allocate a GArray."); + BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray."); goto error; } @@ -134,27 +148,50 @@ end: return ret; } +static +int bt_component_class_with_iterator_class_init( + struct bt_component_class_with_iterator_class *class, + enum bt_component_class_type type, const char *name, + struct bt_message_iterator_class *message_iterator_class) +{ + int ret; + + ret = bt_component_class_init(&class->parent, type, name); + if (ret != 0) { + goto end; + } + + class->msg_iter_cls = message_iterator_class; + bt_message_iterator_class_get_ref(class->msg_iter_cls); + bt_message_iterator_class_freeze(class->msg_iter_cls); + +end: + return ret; +} + struct bt_component_class_source *bt_component_class_source_create( const char *name, - bt_component_class_source_message_iterator_next_method method) + struct bt_message_iterator_class *message_iterator_class) { struct bt_component_class_source *source_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); - BT_LOGI("Creating source component class: " - "name=\"%s\", msg-iter-next-method-addr=%p", - name, method); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_LIB_LOGI("Creating source component class: " + "name=\"%s\", %![msg-iter-cls-]+I", + name, message_iterator_class); source_class = g_new0(struct bt_component_class_source, 1); if (!source_class) { - BT_LOGE_STR("Failed to allocate one source component class."); + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one source component class."); goto end; } /* bt_component_class_init() logs errors */ - ret = bt_component_class_init(&source_class->parent, - BT_COMPONENT_CLASS_TYPE_SOURCE, name); + ret = bt_component_class_with_iterator_class_init(&source_class->parent, + BT_COMPONENT_CLASS_TYPE_SOURCE, name, message_iterator_class); if (ret) { /* * If bt_component_class_init() fails, the component @@ -165,7 +202,6 @@ struct bt_component_class_source *bt_component_class_source_create( goto end; } - source_class->methods.msg_iter_next = method; BT_LIB_LOGI("Created source component class: %!+C", source_class); end: @@ -174,25 +210,27 @@ end: struct bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_component_class_filter_message_iterator_next_method method) + struct bt_message_iterator_class *message_iterator_class) { struct bt_component_class_filter *filter_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); - BT_ASSERT_PRE_NON_NULL(method, "Message iterator next method"); - BT_LOGI("Creating filter component class: " - "name=\"%s\", msg-iter-next-method-addr=%p", - name, method); + BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class"); + BT_LIB_LOGI("Creating filter component class: " + "name=\"%s\", %![msg-iter-cls-]+I", + name, message_iterator_class); filter_class = g_new0(struct bt_component_class_filter, 1); if (!filter_class) { - BT_LOGE_STR("Failed to allocate one filter component class."); + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one filter component class."); goto end; } /* bt_component_class_init() logs errors */ - ret = bt_component_class_init(&filter_class->parent, - BT_COMPONENT_CLASS_TYPE_FILTER, name); + ret = bt_component_class_with_iterator_class_init(&filter_class->parent, + BT_COMPONENT_CLASS_TYPE_FILTER, name, message_iterator_class); if (ret) { /* * If bt_component_class_init() fails, the component @@ -203,7 +241,6 @@ struct bt_component_class_filter *bt_component_class_filter_create( goto end; } - filter_class->methods.msg_iter_next = method; BT_LIB_LOGI("Created filter component class: %!+C", filter_class); end: @@ -216,6 +253,7 @@ struct bt_component_class_sink *bt_component_class_sink_create( struct bt_component_class_sink *sink_class = NULL; int ret; + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(name, "Name"); BT_ASSERT_PRE_NON_NULL(method, "Consume next method"); BT_LOGI("Creating sink component class: " @@ -223,7 +261,8 @@ struct bt_component_class_sink *bt_component_class_sink_create( name, method); sink_class = g_new0(struct bt_component_class_sink, 1); if (!sink_class) { - BT_LOGE_STR("Failed to allocate one sink component class."); + BT_LIB_LOGE_APPEND_CAUSE( + "Failed to allocate one sink component class."); goto end; } @@ -248,13 +287,59 @@ end: } enum bt_component_class_set_method_status -bt_component_class_source_set_init_method( +bt_component_class_source_set_get_supported_mip_versions_method( struct bt_component_class_source *comp_cls, - bt_component_class_source_init_method method) + bt_component_class_source_get_supported_mip_versions_method method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_NON_NULL(method, "Method"); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); + comp_cls->methods.get_supported_mip_versions = method; + BT_LIB_LOGD("Set source component class's \"get supported MIP versions\" method: " + "%!+C", comp_cls); + return BT_FUNC_STATUS_OK; +} + +enum bt_component_class_set_method_status +bt_component_class_filter_set_get_supported_mip_versions_method( + struct bt_component_class_filter *comp_cls, + bt_component_class_filter_get_supported_mip_versions_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); + comp_cls->methods.get_supported_mip_versions = method; + BT_LIB_LOGD("Set filter component class's \"get supported MIP versions\" method: " + "%!+C", comp_cls); + return BT_FUNC_STATUS_OK; +} + +enum bt_component_class_set_method_status +bt_component_class_sink_set_get_supported_mip_versions_method( + struct bt_component_class_sink *comp_cls, + bt_component_class_sink_get_supported_mip_versions_method method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_NON_NULL(method, "Method"); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); + comp_cls->methods.get_supported_mip_versions = method; + BT_LIB_LOGD("Set sink component class's \"get supported MIP versions\" method: " + "%!+C", comp_cls); + return BT_FUNC_STATUS_OK; +} + +enum bt_component_class_set_method_status +bt_component_class_source_set_initialize_method( + struct bt_component_class_source *comp_cls, + bt_component_class_source_initialize_method method) +{ + BT_ASSERT_PRE_NO_ERROR(); + BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_NON_NULL(method, "Method"); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.init = method; BT_LIB_LOGD("Set source component class's initialization method: " "%!+C", comp_cls); @@ -262,13 +347,14 @@ bt_component_class_source_set_init_method( } enum bt_component_class_set_method_status -bt_component_class_filter_set_init_method( +bt_component_class_filter_set_initialize_method( struct bt_component_class_filter *comp_cls, - bt_component_class_filter_init_method method) + bt_component_class_filter_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.init = method; BT_LIB_LOGD("Set filter component class's initialization method: " "%!+C", comp_cls); @@ -276,13 +362,14 @@ bt_component_class_filter_set_init_method( } enum bt_component_class_set_method_status -bt_component_class_sink_set_init_method( +bt_component_class_sink_set_initialize_method( struct bt_component_class_sink *comp_cls, - bt_component_class_sink_init_method method) + bt_component_class_sink_initialize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.init = method; BT_LIB_LOGD("Set sink component class's initialization method: " "%!+C", comp_cls); @@ -294,9 +381,10 @@ bt_component_class_source_set_finalize_method( struct bt_component_class_source *comp_cls, bt_component_class_source_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.finalize = method; BT_LIB_LOGD("Set source component class's finalization method: " "%!+C", comp_cls); @@ -308,9 +396,10 @@ bt_component_class_filter_set_finalize_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.finalize = method; BT_LIB_LOGD("Set filter component class's finalization method: " "%!+C", comp_cls); @@ -322,9 +411,10 @@ bt_component_class_sink_set_finalize_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_finalize_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.finalize = method; BT_LIB_LOGD("Set sink component class's finalization method: " "%!+C", comp_cls); @@ -336,9 +426,10 @@ bt_component_class_source_set_query_method( struct bt_component_class_source *comp_cls, bt_component_class_source_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.query = method; BT_LIB_LOGD("Set source component class's query method: " "%!+C", comp_cls); @@ -350,9 +441,10 @@ bt_component_class_filter_set_query_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.query = method; BT_LIB_LOGD("Set filter component class's query method: " "%!+C", comp_cls); @@ -364,9 +456,10 @@ bt_component_class_sink_set_query_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_query_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.query = method; BT_LIB_LOGD("Set sink component class's query method: " "%!+C", comp_cls); @@ -378,9 +471,10 @@ bt_component_class_filter_set_input_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_input_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.input_port_connected = method; BT_LIB_LOGD("Set filter component class's \"input port connected\" method" ": %!+C", comp_cls); @@ -392,9 +486,10 @@ bt_component_class_sink_set_input_port_connected_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_input_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.input_port_connected = method; BT_LIB_LOGD("Set sink component class's \"input port connected\" method" ": %!+C", comp_cls); @@ -406,9 +501,10 @@ bt_component_class_source_set_output_port_connected_method( struct bt_component_class_source *comp_cls, bt_component_class_source_output_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.output_port_connected = method; BT_LIB_LOGD("Set source component class's \"output port connected\" method" ": %!+C", comp_cls); @@ -420,9 +516,10 @@ bt_component_class_filter_set_output_port_connected_method( struct bt_component_class_filter *comp_cls, bt_component_class_filter_output_port_connected_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.output_port_connected = method; BT_LIB_LOGD("Set filter component class's \"output port connected\" method" ": %!+C", comp_cls); @@ -434,191 +531,25 @@ bt_component_class_sink_set_graph_is_configured_method( struct bt_component_class_sink *comp_cls, bt_component_class_sink_graph_is_configured_method method) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); comp_cls->methods.graph_is_configured = method; BT_LIB_LOGD("Set sink component class's \"graph is configured\" method" ": %!+C", comp_cls); return BT_FUNC_STATUS_OK; } -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_init_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_init_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_init = method; - BT_LIB_LOGD("Set source component class's message iterator initialization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_init_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_init_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_init = method; - BT_LIB_LOGD("Set filter component class's message iterator initialization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_finalize_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_finalize_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_finalize = method; - BT_LIB_LOGD("Set source component class's message iterator finalization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_finalize_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_finalize_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_finalize = method; - BT_LIB_LOGD("Set filter component class's message iterator finalization method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_seek_ns_from_origin_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_ns_from_origin = method; - BT_LIB_LOGD("Set filter component class's message iterator \"seek nanoseconds from origin\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_ns_from_origin_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_seek_ns_from_origin_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_ns_from_origin = method; - BT_LIB_LOGD("Set source component class's message iterator \"seek nanoseconds from origin\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_seek_beginning_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_seek_beginning_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_beginning = method; - BT_LIB_LOGD("Set filter component class's message iterator \"seek beginning\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_seek_beginning_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_seek_beginning_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_seek_beginning = method; - BT_LIB_LOGD("Set source component class's message iterator \"seek beginning\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_can_seek_beginning_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_can_seek_beginning_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_can_seek_beginning = method; - BT_LIB_LOGD("Set filter component class's message iterator \"can seek beginning\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_can_seek_beginning_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_can_seek_beginning_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_can_seek_beginning = method; - BT_LIB_LOGD("Set source component class's message iterator \"can seek beginning\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method( - struct bt_component_class_filter *comp_cls, - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_can_seek_ns_from_origin = method; - BT_LIB_LOGD("Set filter component class's message iterator \"can seek nanoseconds from origin\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - -enum bt_component_class_set_method_status -bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method( - struct bt_component_class_source *comp_cls, - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method method) -{ - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); - BT_ASSERT_PRE_NON_NULL(method, "Method"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); - comp_cls->methods.msg_iter_can_seek_ns_from_origin = method; - BT_LIB_LOGD("Set source component class's message iterator \"can seek nanoseconds from origin\" method" - ": %!+C", comp_cls); - return BT_FUNC_STATUS_OK; -} - enum bt_component_class_set_description_status bt_component_class_set_description( struct bt_component_class *comp_cls, const char *description) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(description, "Description"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); g_string_assign(comp_cls->description, description); BT_LIB_LOGD("Set component class's description: " "addr=%p, name=\"%s\", type=%s", @@ -632,9 +563,10 @@ enum bt_component_class_set_help_status bt_component_class_set_help( struct bt_component_class *comp_cls, const char *help) { + BT_ASSERT_PRE_NO_ERROR(); BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); BT_ASSERT_PRE_NON_NULL(help, "Help"); - BT_ASSERT_PRE_COMP_CLS_HOT(comp_cls); + BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls); g_string_assign(comp_cls->help, help); BT_LIB_LOGD("Set component class's help text: %!+C", comp_cls); return BT_FUNC_STATUS_OK; @@ -642,21 +574,21 @@ enum bt_component_class_set_help_status bt_component_class_set_help( const char *bt_component_class_get_name(const struct bt_component_class *comp_cls) { - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class"); return comp_cls->name->str; } enum bt_component_class_type bt_component_class_get_type( const struct bt_component_class *comp_cls) { - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class"); return comp_cls->type; } const char *bt_component_class_get_description( const struct bt_component_class *comp_cls) { - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class"); return comp_cls->description && comp_cls->description->str[0] != '\0' ? comp_cls->description->str : NULL; @@ -665,7 +597,7 @@ const char *bt_component_class_get_description( const char *bt_component_class_get_help( const struct bt_component_class *comp_cls) { - BT_ASSERT_PRE_NON_NULL(comp_cls, "Component class"); + BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class"); return comp_cls->help && comp_cls->help->str[0] != '\0' ? comp_cls->help->str : NULL; }