.gitignore: add some missing files
[babeltrace.git] / src / plugins / utils / muxer / comp.cpp
... / ...
CommitLineData
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
11namespace bt2mux {
12
13Comp::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
37void Comp::_getSupportedMipVersions(bt2::SelfComponentClass, bt2::ConstValue, bt2::LoggingLevel,
38 const bt2::UnsignedIntegerRangeSet ranges)
39{
40 ranges.addRange(0, 1);
41}
42
43void Comp::_inputPortConnected(const bt2::SelfComponentInputPort, const bt2::ConstOutputPort)
44{
45 this->_addAvailInputPort();
46}
47
48void 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.024007 seconds and 5 git commands to generate.