7cce5edbff9e3f7f965f19a7984ce250b5d5c7e1
[babeltrace.git] / src / plugins / utils / muxer / comp.cpp
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright 2017-2023 Philippe Proulx <pproulx@efficios.com>
5 */
6
7 #include "cpp-common/vendor/fmt/core.h"
8
9 #include "comp.hpp"
10
11 namespace bt2mux {
12
13 Comp::Comp(const bt2::SelfFilterComponent selfComp, const bt2::ConstMapValue params, void *) :
14 bt2::UserFilterComponent<Comp, MsgIter> {selfComp, "PLUGIN/FLT.UTILS.MUXER"}
15 {
16 BT_CPPLOGI("Initializing component.");
17
18 /* No parameters expected */
19 if (!params.isEmpty()) {
20 BT_CPPLOGE_APPEND_CAUSE_AND_THROW(
21 bt2c::Error, "This component expects no parameters: param-count={}", params.length());
22 }
23
24 /* Add initial available input port */
25 this->_addAvailInputPort();
26
27 /* Add single output port */
28 try {
29 this->_addOutputPort("out");
30 } catch (const bt2c::Error&) {
31 BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW("Failed to add a single output port.");
32 }
33
34 BT_CPPLOGI("Initialized component.");
35 }
36
37 void Comp::_getSupportedMipVersions(bt2::SelfComponentClass, bt2::ConstValue, bt2::LoggingLevel,
38 const bt2::UnsignedIntegerRangeSet ranges)
39 {
40 ranges.addRange(0, 1);
41 }
42
43 void Comp::_inputPortConnected(const bt2::SelfComponentInputPort, const bt2::ConstOutputPort)
44 {
45 this->_addAvailInputPort();
46 }
47
48 void Comp::_addAvailInputPort()
49 {
50 try {
51 this->_addInputPort(fmt::format("in{}", this->_inputPorts().length()));
52 } catch (const bt2c::Error&) {
53 BT_CPPLOGE_APPEND_CAUSE_AND_RETHROW("Failed to add an available input port.");
54 }
55
56 BT_CPPLOGI("Added one available input port: name={}", this->_inputPorts().back().name());
57 }
58
59 } /* namespace bt2mux */
This page took 0.032232 seconds and 5 git commands to generate.