cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[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_STR("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_STR_APPEND_CAUSE_AND_RETHROW("Failed to add a single output port.");
32 }
33
34 BT_CPPLOGI_STR("Initialized component.");
35 }
36
37 void Comp::_inputPortConnected(const bt2::SelfComponentInputPort, const bt2::ConstOutputPort)
38 {
39 this->_addAvailInputPort();
40 }
41
42 void Comp::_addAvailInputPort()
43 {
44 try {
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.");
48 }
49
50 BT_CPPLOGI("Added one available input port: name={}", this->_inputPorts().back().name());
51 }
52
53 } /* namespace bt2mux */
This page took 0.030343 seconds and 4 git commands to generate.