This commit is contained in:
parent
da8f4d9926
commit
9acc42b2e9
@ -51,9 +51,10 @@ public:
|
|||||||
using return_tuple = detail::repeat_tuple_t<T, N>;
|
using return_tuple = detail::repeat_tuple_t<T, N>;
|
||||||
using return_raw = return_tuple;
|
using return_raw = return_tuple;
|
||||||
|
|
||||||
static constexpr std::size_t input_count = 1;
|
static constexpr std::size_t input_count = 1;
|
||||||
static constexpr std::size_t output_count = N;
|
static constexpr std::size_t output_count = N;
|
||||||
static constexpr std::size_t unique_tag = Id;
|
static constexpr std::size_t unique_tag = Id;
|
||||||
|
static constexpr bool is_fanout_node = true;
|
||||||
|
|
||||||
explicit FanoutNode(std::size_t fifo_capacity = 5)
|
explicit FanoutNode(std::size_t fifo_capacity = 5)
|
||||||
: fifo_capacity_(fifo_capacity)
|
: fifo_capacity_(fifo_capacity)
|
||||||
|
|||||||
@ -101,9 +101,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t I>
|
template<std::size_t I>
|
||||||
InputPort<MainThreadNode, I> input() {
|
InputPort<Derived, I> input() {
|
||||||
static_assert(I < input_count, "input index out of range");
|
static_assert(I < input_count, "input index out of range");
|
||||||
return {*this};
|
return {static_cast<Derived&>(*this)};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<fixed_string Name>
|
template<fixed_string Name>
|
||||||
|
|||||||
@ -72,6 +72,8 @@ std::string node_display_name() {
|
|||||||
constexpr std::string_view lbl = node_label_v<NodeT>;
|
constexpr std::string_view lbl = node_label_v<NodeT>;
|
||||||
if constexpr (!lbl.empty()) {
|
if constexpr (!lbl.empty()) {
|
||||||
return std::string(lbl);
|
return std::string(lbl);
|
||||||
|
} else if constexpr (requires { NodeT::is_fanout_node; NodeT::unique_tag; }) {
|
||||||
|
return "fanout[" + std::to_string(NodeT::unique_tag) + "]";
|
||||||
} else if constexpr (requires { NodeT::unique_tag; }) {
|
} else if constexpr (requires { NodeT::unique_tag; }) {
|
||||||
return "node[" + std::to_string(NodeT::unique_tag) + "]";
|
return "node[" + std::to_string(NodeT::unique_tag) + "]";
|
||||||
} else {
|
} else {
|
||||||
@ -261,6 +263,29 @@ auto make_network(Edges&&... edges) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Pre-pass: build fanout_id → source display name map so fanout nodes
|
||||||
|
// can be named after the node feeding them (e.g. "capture_fanout").
|
||||||
|
std::map<std::size_t, std::string> fanout_src_name;
|
||||||
|
[&]<typename... SEs>(tmp::TypeList<SEs...>) {
|
||||||
|
([&]<typename SE>(SE) {
|
||||||
|
using DstNode = typename SE::dst_node_t;
|
||||||
|
using SrcNode = typename SE::src_node_t;
|
||||||
|
if constexpr (requires { DstNode::is_fanout_node; })
|
||||||
|
fanout_src_name.emplace(DstNode::unique_tag, node_display_name<SrcNode>());
|
||||||
|
}(SEs{}), ...);
|
||||||
|
}(ExpandedEdges{});
|
||||||
|
|
||||||
|
// Helper: display name for any node type, resolving fanouts to "src_fanout".
|
||||||
|
auto node_name = [&]<typename NodeT>() -> std::string {
|
||||||
|
if constexpr (requires { NodeT::is_fanout_node; }) {
|
||||||
|
auto it = fanout_src_name.find(NodeT::unique_tag);
|
||||||
|
return it != fanout_src_name.end() ? it->second + "_fanout"
|
||||||
|
: node_display_name<NodeT>();
|
||||||
|
} else {
|
||||||
|
return node_display_name<NodeT>();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
std::vector<std::unique_ptr<IChannelProbe>> channel_probes;
|
std::vector<std::unique_ptr<IChannelProbe>> channel_probes;
|
||||||
|
|
||||||
auto wire_one = [&]<typename SE>(SE) {
|
auto wire_one = [&]<typename SE>(SE) {
|
||||||
@ -275,9 +300,9 @@ auto make_network(Edges&&... edges) {
|
|||||||
if (src && dst) {
|
if (src && dst) {
|
||||||
auto& ch = dst->template input_channel<DstIdx>();
|
auto& ch = dst->template input_channel<DstIdx>();
|
||||||
src->template set_output_channel<SrcIdx>(&ch);
|
src->template set_output_channel<SrcIdx>(&ch);
|
||||||
std::string ch_name = node_display_name<SrcNode>() + ":" + std::to_string(SrcIdx)
|
std::string ch_name = node_name.template operator()<SrcNode>() + ":" + std::to_string(SrcIdx)
|
||||||
+ " \xe2\x86\x92 " // UTF-8 →
|
+ " \xe2\x86\x92 " // UTF-8 →
|
||||||
+ node_display_name<DstNode>() + ":" + std::to_string(DstIdx);
|
+ node_name.template operator()<DstNode>() + ":" + std::to_string(DstIdx);
|
||||||
channel_probes.push_back(std::make_unique<ChannelProbe<out_t>>(ch, ch_name));
|
channel_probes.push_back(std::make_unique<ChannelProbe<out_t>>(ch, ch_name));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -291,8 +316,9 @@ auto make_network(Edges&&... edges) {
|
|||||||
std::vector<std::string> fanout_node_names;
|
std::vector<std::string> fanout_node_names;
|
||||||
std::apply([&](auto&... fn) {
|
std::apply([&](auto&... fn) {
|
||||||
([&](auto& node) {
|
([&](auto& node) {
|
||||||
|
using NodeT = std::decay_t<decltype(node)>;
|
||||||
fanout_ptrs.push_back(static_cast<INode*>(&node));
|
fanout_ptrs.push_back(static_cast<INode*>(&node));
|
||||||
fanout_node_names.push_back(node_display_name<std::decay_t<decltype(node)>>());
|
fanout_node_names.push_back(node_name.template operator()<NodeT>());
|
||||||
}(fn), ...);
|
}(fn), ...);
|
||||||
}, *fanout_storage);
|
}, *fanout_storage);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user