2 * SPDX-License-Identifier: MIT
4 * Copyright 2017-2023 Philippe Proulx <pproulx@efficios.com>
7 #include "cpp-common/vendor/fmt/core.h"
13 Comp::Comp(const bt2::SelfFilterComponent selfComp
, const bt2::ConstMapValue params
, void *) :
14 bt2::UserFilterComponent
<Comp
, MsgIter
> {selfComp
, "PLUGIN/FLT.UTILS.MUXER"}
16 BT_CPPLOGI_STR("Initializing component.");
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());
24 /* Add initial available input port */
25 this->_addAvailInputPort();
27 /* Add single output port */
29 this->_addOutputPort("out");
30 } catch (const bt2c::Error
&) {
31 BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW("Failed to add a single output port.");
34 BT_CPPLOGI_STR("Initialized component.");
37 void Comp::_inputPortConnected(const bt2::SelfComponentInputPort
, const bt2::ConstOutputPort
)
39 this->_addAvailInputPort();
42 void Comp::_addAvailInputPort()
45 this->_addInputPort(fmt::format("in{}", this->_inputPorts().length()));
46 } catch (const bt2c::Error
&) {
47 BT_CPPLOGE_STR_APPEND_CAUSE_AND_RETHROW("Failed to add an available input port.");
50 BT_CPPLOGI("Added one available input port: name={}", this->_inputPorts().back().name());
53 } /* namespace bt2mux */