Update project plugins's properties
[babeltrace.git] / src / bindings / python / bt2 / bt2 / mip.py
1 # The MIT License (MIT)
2 #
3 # Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 # THE SOFTWARE.
22
23 from bt2 import native_bt, utils
24 import bt2
25
26
27 def get_greatest_operative_mip_version(
28 component_descriptors, log_level=bt2.LoggingLevel.NONE
29 ):
30 utils._check_log_level(log_level)
31 comp_descr_set_ptr = native_bt.component_descriptor_set_create()
32
33 if comp_descr_set_ptr is None:
34 raise bt2._MemoryError('cannot create component descriptor set object')
35
36 if len(component_descriptors) == 0:
37 raise ValueError('no component descriptors')
38
39 try:
40 for descr in component_descriptors:
41 if type(descr) is not bt2.ComponentDescriptor:
42 raise TypeError("'{}' is not a component descriptor".format(descr))
43
44 base_cc_ptr = descr.component_class._bt_component_class_ptr()
45 params_ptr = None
46
47 if descr.params is not None:
48 params_ptr = descr.params._ptr
49
50 status = native_bt.bt2_component_descriptor_set_add_descriptor_with_init_method_data(
51 comp_descr_set_ptr, base_cc_ptr, params_ptr, descr.obj
52 )
53 utils._handle_func_status(
54 status, 'cannot add descriptor to component descriptor set'
55 )
56
57 status, version = native_bt.get_greatest_operative_mip_version(
58 comp_descr_set_ptr, log_level
59 )
60
61 if status == native_bt.__BT_FUNC_STATUS_NO_MATCH:
62 return None
63
64 utils._handle_func_status(status, 'cannot get greatest operative MIP version')
65 return version
66 finally:
67 native_bt.component_descriptor_set_put_ref(comp_descr_set_ptr)
68
69
70 def get_maximal_mip_version():
71 return native_bt.get_maximal_mip_version()
This page took 0.031487 seconds and 4 git commands to generate.