From c7d531ebb2b97a56a11f469cf59719f9892dbc9f Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Mon, 14 Nov 2022 10:38:38 -0800 Subject: [PATCH] AddTarget -> ConnectTo and documentation PiperOrigin-RevId: 488407930 --- mediapipe/framework/api2/builder.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/mediapipe/framework/api2/builder.h b/mediapipe/framework/api2/builder.h index 5af9ee5e0..6d3323b97 100644 --- a/mediapipe/framework/api2/builder.h +++ b/mediapipe/framework/api2/builder.h @@ -176,22 +176,40 @@ class SourceImpl { : SourceImpl(&GetWithAutoGrow(vec, 0)) {} explicit SourceImpl(SourceBase* base) : base_(base) {} + // Connects MediaPipe stream or side packet to a destination: + // - node input (input stream) / side input (input side packet) + // - graph output (output stream) / side output (output side packet). + // + // MediaPipe streams and side packets can be connected to multiple + // destinations. Side packets and packets added to streams are sent to all + // connected destinations. template {}, int>::type = 0> - Src& AddTarget(const Dst& dest) { + Src& ConnectTo(const Dst& dest) { CHECK(dest.base_.source == nullptr); dest.base_.source = base_; base_->dests_.emplace_back(&dest.base_); return *this; } + + // Shortcut for `ConnectTo`. + // + // Connects MediaPipe stream or side packet to a destination: + // - node input (input stream) / side input (input side packet) + // - graph output (output stream) / side output (output side packet). + // + // MediaPipe streams and side packets can be connected to multiple + // destinations. Side packets and packets added to streams are sent to all + // connected destinations. + template + Src& operator>>(const Dst& dest) { + return ConnectTo(dest); + } + Src& SetName(std::string name) { base_->name_ = std::move(name); return *this; } - template - Src& operator>>(const Dst& dest) { - return AddTarget(dest); - } template {}, int> = 0>