From e1deba5b6cba82054f66a4ff682f28510c89b1b4 Mon Sep 17 00:00:00 2001 From: Marcus Winter Date: Mon, 13 Oct 2014 12:31:43 +0200 Subject: [PATCH] dataflow_cpp: added operator to directly connect output 0 to input 0 --- dataflow_cpp/include/embb/dataflow/internal/constant_source.h | 5 +++++ dataflow_cpp/include/embb/dataflow/internal/process.h | 5 +++++ dataflow_cpp/include/embb/dataflow/internal/select.h | 5 +++++ dataflow_cpp/include/embb/dataflow/internal/source.h | 5 +++++ dataflow_cpp/include/embb/dataflow/internal/switch.h | 5 +++++ dataflow_cpp/include/embb/dataflow/network.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/examples/dataflow/dataflow_connect-snippet.h | 4 ++-- 7 files changed, 75 insertions(+), 2 deletions(-) diff --git a/dataflow_cpp/include/embb/dataflow/internal/constant_source.h b/dataflow_cpp/include/embb/dataflow/internal/constant_source.h index c7fa38d..47f5d88 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/constant_source.h +++ b/dataflow_cpp/include/embb/dataflow/internal/constant_source.h @@ -68,6 +68,11 @@ class ConstantSource typename TypeAt::Result & GetOutput() { return outputs_.template Get(); } + + template + void operator >> (T & target) { + GetOutput<0>() >> target.GetInput<0>(); + } }; } // namespace internal diff --git a/dataflow_cpp/include/embb/dataflow/internal/process.h b/dataflow_cpp/include/embb/dataflow/internal/process.h index 0b00b35..0a5093a 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/process.h +++ b/dataflow_cpp/include/embb/dataflow/internal/process.h @@ -98,6 +98,11 @@ class Process< Slices, Serial, Inputs, return outputs_.template Get(); } + template + void operator >> (T & target) { + GetOutput<0>() >> target.GetInput<0>(); + } + virtual void OnClock(int clock) { const int idx = clock % Slices; if (!inputs_.AreAtClock(clock)) diff --git a/dataflow_cpp/include/embb/dataflow/internal/select.h b/dataflow_cpp/include/embb/dataflow/internal/select.h index 7744ca1..50c4c85 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/select.h +++ b/dataflow_cpp/include/embb/dataflow/internal/select.h @@ -99,6 +99,11 @@ class Select return outputs_.template Get(); } + template + void operator >> (T & target) { + GetOutput<0>() >> target.GetInput<0>(); + } + virtual void OnClock(int clock) { //const int idx = clock % Slices; if (!inputs_.AreAtClock(clock)) diff --git a/dataflow_cpp/include/embb/dataflow/internal/source.h b/dataflow_cpp/include/embb/dataflow/internal/source.h index 6a925e8..3bcef96 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/source.h +++ b/dataflow_cpp/include/embb/dataflow/internal/source.h @@ -81,6 +81,11 @@ class Source< Slices, Outputs > return outputs_.template Get(); } + template + void operator >> (T & target) { + GetOutput<0>() >> target.GetInput<0>(); + } + private: OutputsType outputs_; ExecutorType executor_; diff --git a/dataflow_cpp/include/embb/dataflow/internal/switch.h b/dataflow_cpp/include/embb/dataflow/internal/switch.h index 242e357..1b5fe7b 100644 --- a/dataflow_cpp/include/embb/dataflow/internal/switch.h +++ b/dataflow_cpp/include/embb/dataflow/internal/switch.h @@ -96,6 +96,11 @@ class Switch return outputs_.template Get(); } + template + void operator >> (T & target) { + GetOutput<0>() >> target.GetInput<0>(); + } + virtual void OnClock(int clock) { //const int idx = clock % Slices; if (!inputs_.AreAtClock(clock)) diff --git a/dataflow_cpp/include/embb/dataflow/network.h b/dataflow_cpp/include/embb/dataflow/network.h index 3610ccc..bdd9bdd 100644 --- a/dataflow_cpp/include/embb/dataflow/network.h +++ b/dataflow_cpp/include/embb/dataflow/network.h @@ -235,6 +235,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** @@ -315,6 +323,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** @@ -385,6 +401,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** @@ -455,6 +479,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** @@ -588,6 +620,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** @@ -639,6 +679,14 @@ class Network { */ template typename OutputsType::Types::Result & GetOutput(); + + /** + * Connects output port 0 to input port 0 of \c target. + * \param target Process to connect to. + * \tparam T Type of target process. + */ + template + void operator >> (T & target); }; /** diff --git a/doc/examples/dataflow/dataflow_connect-snippet.h b/doc/examples/dataflow/dataflow_connect-snippet.h index eac1dfe..6660f53 100644 --- a/doc/examples/dataflow/dataflow_connect-snippet.h +++ b/doc/examples/dataflow/dataflow_connect-snippet.h @@ -1,2 +1,2 @@ - read.GetOutput<0>() >> replace.GetInput<0>(); - replace.GetOutput<0>() >> write.GetInput<0>(); + read >> replace; + replace >> write; -- libgit2 0.26.0