#include "lib/logging.h"
#include "common/assert.h"
-#include "lib/assert-pre.h"
+#include "lib/assert-cond.h"
#include "compat/compiler.h"
#include <babeltrace2/graph/component-class.h>
#include <babeltrace2/types.h>
#include "lib/func-status.h"
#include "lib/graph/message-iterator-class.h"
-#define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \
- BT_ASSERT_PRE_DEV_HOT(((const struct bt_component_class *) (_cc)), \
+#define BT_ASSERT_PRE_DEV_COMP_CLS_HOT(_cc) \
+ BT_ASSERT_PRE_DEV_HOT("component-class", \
+ ((const struct bt_component_class *) (_cc)), \
"Component class", ": %!+C", (_cc))
static
BT_LIB_LOGI("Destroying component class: %!+C", class);
/* Call destroy listeners in reverse registration order */
- for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
- struct bt_component_class_destroy_listener *listener =
- &g_array_index(class->destroy_listeners,
- struct bt_component_class_destroy_listener,
- i);
-
- BT_LOGD("Calling destroy listener: func-addr=%p, data-addr=%p",
- listener->func, listener->data);
- listener->func(class, listener->data);
+ if (class->destroy_listeners) {
+ for (i = class->destroy_listeners->len - 1; i >= 0; i--) {
+ struct bt_component_class_destroy_listener *listener =
+ &g_array_index(class->destroy_listeners,
+ struct bt_component_class_destroy_listener,
+ i);
+
+ BT_LOGD("Calling destroy listener: func-addr=%p, data-addr=%p",
+ listener->func, listener->data);
+ listener->func(class, listener->data);
+ }
}
if (class->name) {
int ret;
BT_ASSERT_PRE_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NAME_NON_NULL(name);
+ BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
BT_LIB_LOGI("Creating source component class: "
"name=\"%s\", %![msg-iter-cls-]+I",
name, message_iterator_class);
int ret;
BT_ASSERT_PRE_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(message_iterator_class, "Message iterator class");
+ BT_ASSERT_PRE_NAME_NON_NULL(name);
+ BT_ASSERT_PRE_MSG_ITER_CLS_NON_NULL(message_iterator_class);
BT_LIB_LOGI("Creating filter component class: "
"name=\"%s\", %![msg-iter-cls-]+I",
name, message_iterator_class);
int ret;
BT_ASSERT_PRE_NO_ERROR();
- BT_ASSERT_PRE_NON_NULL(name, "Name");
- BT_ASSERT_PRE_NON_NULL(method, "Consume next method");
+ BT_ASSERT_PRE_NAME_NON_NULL(name);
+ BT_ASSERT_PRE_NON_NULL("consume-method", method, "Consume next method");
BT_LOGI("Creating sink component class: "
"name=\"%s\", consume-method-addr=%p",
name, 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_COMP_CLS_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(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: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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: "
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_COMP_CLS_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(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: "
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_COMP_CLS_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(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: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.init = method;
BT_LIB_LOGD("Set filter component class's initialization 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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.init = method;
BT_LIB_LOGD("Set sink component class's initialization method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.finalize = method;
BT_LIB_LOGD("Set source component class's finalization method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.finalize = method;
BT_LIB_LOGD("Set filter component class's finalization method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.finalize = method;
BT_LIB_LOGD("Set sink component class's finalization method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.query = method;
BT_LIB_LOGD("Set source component class's query method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.query = method;
BT_LIB_LOGD("Set filter component class's query method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
BT_ASSERT_PRE_DEV_COMP_CLS_HOT(comp_cls);
comp_cls->methods.query = method;
BT_LIB_LOGD("Set sink component class's query method: "
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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"
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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"
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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"
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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"
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_METHOD_NON_NULL(method);
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"
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_DESCR_NON_NULL(description);
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",
comp_cls,
bt_component_class_get_name(comp_cls),
- bt_component_class_type_string(comp_cls->type));
+ bt_common_component_class_type_string(comp_cls->type));
return BT_FUNC_STATUS_OK;
}
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_NON_NULL(comp_cls);
+ BT_ASSERT_PRE_NON_NULL("help-text", help, "Help text");
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);
const char *bt_component_class_get_name(const struct bt_component_class *comp_cls)
{
- BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
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_DEV_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
return comp_cls->type;
}
const char *bt_component_class_get_description(
const struct bt_component_class *comp_cls)
{
- BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
return comp_cls->description &&
comp_cls->description->str[0] != '\0' ?
comp_cls->description->str : NULL;
const char *bt_component_class_get_help(
const struct bt_component_class *comp_cls)
{
- BT_ASSERT_PRE_DEV_NON_NULL(comp_cls, "Component class");
+ BT_ASSERT_PRE_DEV_COMP_CLS_NON_NULL(comp_cls);
return comp_cls->help &&
comp_cls->help->str[0] != '\0' ? comp_cls->help->str : NULL;
}