typedef void (*bt_graph_simple_sink_component_finalize_func)(void *data);
-extern bt_graph *bt_graph_create(void);
+extern bt_graph *bt_graph_create(uint64_t mip_version);
typedef enum bt_graph_add_component_status {
BT_GRAPH_ADD_COMPONENT_STATUS_OK = __BT_FUNC_STATUS_OK,
return __BT_UPCAST(bt_component, self_component);
}
+extern
+uint64_t bt_self_component_get_graph_mip_version(bt_self_component *self_component);
+
extern void *bt_self_component_get_data(
const bt_self_component *self_component);
def addr(self):
return int(self._bt_ptr)
+ @property
+ def _graph_mip_version(self):
+ ptr = self._bt_as_self_component_ptr(self._bt_ptr)
+ return native_bt.self_component_get_graph_mip_version(ptr)
+
def __init__(self, params=None, obj=None):
pass
_get_ref = staticmethod(native_bt.graph_get_ref)
_put_ref = staticmethod(native_bt.graph_put_ref)
- def __init__(self):
- ptr = native_bt.graph_create()
+ def __init__(self, mip_version=0):
+ utils._check_uint64(mip_version)
+
+ if mip_version > bt2.get_maximal_mip_version():
+ raise ValueError('unknown MIP version {}'.format(mip_version))
+
+ ptr = native_bt.graph_create(mip_version)
if ptr is None:
raise bt2._MemoryError('cannot create graph object')
}
}
- ctx->graph = bt_graph_create();
+ ctx->graph = bt_graph_create(0);
if (!ctx->graph) {
goto error;
}
return component->log_level;
}
+uint64_t bt_self_component_get_graph_mip_version(
+ bt_self_component *self_component)
+{
+ struct bt_component *comp = (void *) self_component;
+
+ BT_ASSERT_PRE_NON_NULL(self_component, "Component");
+ return bt_component_borrow_graph(comp)->mip_version;
+}
+
void bt_component_get_ref(const struct bt_component *component)
{
bt_object_get_ref(component);
bt_message_unlink_graph(msg);
}
-struct bt_graph *bt_graph_create(void)
+struct bt_graph *bt_graph_create(uint64_t mip_version)
{
struct bt_graph *graph;
int ret;
+ BT_ASSERT_PRE(mip_version <= bt_get_maximal_mip_version(),
+ "Unknown MIP version: mip-version=%" PRIu64 ", "
+ "max-mip-version=%" PRIu64,
+ mip_version, bt_get_maximal_mip_version());
BT_LOGI_STR("Creating graph object.");
graph = g_new0(struct bt_graph, 1);
if (!graph) {
}
bt_object_init_shared(&graph->base, destroy_graph);
+ graph->mip_version = mip_version;
graph->connections = g_ptr_array_new_with_free_func(
(GDestroyNotify) bt_object_try_spec_release);
if (!graph->connections) {
/* Queue of pointers (weak references) to sink bt_components. */
GQueue *sinks_to_consume;
+ uint64_t mip_version;
+
/*
* Array of `struct bt_interrupter *`, each one owned by this.
* If any interrupter is set, then this graph is deemed
comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO)
+ def test_graph_mip_version(self):
+ class MySink(bt2._UserSinkComponent):
+ def __init__(comp_self, params, obj):
+ self.assertEqual(comp_self._graph_mip_version, 0)
+
+ def _user_consume(self):
+ pass
+
+ comp = self._create_comp(MySink, 'yaes', bt2.LoggingLevel.INFO)
+
def test_class(self):
class MySink(bt2._UserSinkComponent):
def __init__(comp_self, params, obj):
def tearDown(self):
del self._graph
- def test_create_empty(self):
- graph = bt2.Graph()
+ def test_create_default(self):
+ bt2.Graph()
+
+ def test_create_known_mip_version(self):
+ bt2.Graph(0)
+
+ def test_create_invalid_mip_version_type(self):
+ with self.assertRaises(TypeError):
+ bt2.Graph('')
+
+ def test_create_unknown_mip_version(self):
+ with self.assertRaisesRegex(ValueError, 'unknown MIP version'):
+ bt2.Graph(1)
def test_add_component_user_cls(self):
class MySink(bt2._UserSinkComponent):
bt_component_class_sink_get_ref(sink_comp_class);
diag("> putting the plugin set object here");
BT_PLUGIN_SET_PUT_REF_AND_RESET(plugin_set);
- graph = bt_graph_create();
+ graph = bt_graph_create(0);
BT_ASSERT(graph);
graph_ret = bt_graph_add_sink_component(graph, sink_comp_class,
"the-sink", NULL, BT_LOGGING_LEVEL_NONE, &sink_component);
static
bt_graph *create_graph(void)
{
- bt_graph *graph = bt_graph_create();
+ bt_graph *graph = bt_graph_create(0);
int ret;
BT_ASSERT(graph);
set_method_status = bt_component_class_source_set_init_method(
src_comp_cls, src_init);
BT_ASSERT(set_method_status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK);
- graph = bt_graph_create();
+ graph = bt_graph_create(0);
BT_ASSERT(graph);
add_comp_status = bt_graph_add_source_component(graph, src_comp_cls,
"src", NULL, BT_LOGGING_LEVEL_NONE, &src_comp);
BT_ASSERT(comp_cls);
ret = bt_component_class_source_set_init_method(comp_cls, src_init);
BT_ASSERT(ret == 0);
- graph = bt_graph_create();
+ graph = bt_graph_create(0);
ret = bt_graph_add_source_component(graph, comp_cls, "src-comp",
NULL, BT_LOGGING_LEVEL_NONE, NULL);
BT_ASSERT(ret == 0);