bt2: add support for the "query info" API
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 11 Feb 2017 18:27:06 +0000 (13:27 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:38 +0000 (12:57 -0400)
commit911dec0860545c08f347bf8dc291f94494cd4da5
treecff87e7a4220440bd83853758feedcb94be243b4
parent9a0a47aeda7c5de37b7090c074bd9031109bb47d
bt2: add support for the "query info" API

Any user-defined component class can now define a _query_info() static
method which accepts an action name and parameters (value object, or
None) and returns a bt2.create_value()-compatible object:

    class MySink(bt2.UserSinkComponent):
        def _consume(self):
            pass

        @staticmethod
        def _query_info(action, params):
            if action == 'get-stuff':
                return {
                    'stuff': get_stuff(),
                    'id': get_id()
                }
            elif action == 'get-thing':
                return the_thing()

This static method can raise any exception: the caller of
bt_component_class_query_info() gets NULL.

On the Python side, either with a user-defined component class or with
a component class wrapper:

    results = comp_class.query_info('get-stuff', {'name': 'wrerzvr'})

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
bindings/python/bt2/component.py
bindings/python/bt2/native_btcomponentclass.i
This page took 0.024774 seconds and 4 git commands to generate.