Ejemplo n.º 1
0
        public FlowMerger <TForward, TBackward> ConnectOutsWithIn(IFlowComponentUniqueOutgoing <TForward, TBackward>[] fromOuts, IFlowComponentUniqueIncoming <TForward, TBackward> to)
        {
            // fromOuts[] --> Merger --> to
            var elementNos = fromOuts.Length;

            if (elementNos == 0)
            {
                throw new ArgumentException("need at least one source element");
            }
            else if (elementNos == 1)
            {
                var newPort = new FlowPort <TForward, TBackward>();
                fromOuts[0].Outgoing = newPort;
                to.Incoming          = newPort;
                AddAtomicConnection(fromOuts[0], to);
                return(null);
            }
            else
            {
                // create virtual merging component.
                var flowVirtualMerger = CreateFlowVirtualMerger(elementNos);
                for (int i = 0; i < elementNos; i++)
                {
                    var newPortToMerger = new FlowPort <TForward, TBackward>();
                    fromOuts[i].Outgoing           = newPortToMerger;
                    flowVirtualMerger.Incomings[i] = newPortToMerger;
                    AddAtomicConnection(fromOuts[i], flowVirtualMerger);
                }
                var newPortFromMerger = new FlowPort <TForward, TBackward>();
                flowVirtualMerger.Outgoing = newPortFromMerger;
                to.Incoming = newPortFromMerger;
                AddAtomicConnection(flowVirtualMerger, to);
                return(flowVirtualMerger);
            }
        }
Ejemplo n.º 2
0
 protected FlowSplitter(int number)
 {
     Number    = number;
     Outgoings = new FlowPort <TForward, TBackward> [number];
     for (var i = 0; i < Outgoings.Length; i++)
     {
         Outgoings[i] = new FlowPort <TForward, TBackward>();
     }
 }
Ejemplo n.º 3
0
        public void ConnectOutWithIn(IFlowComponentUniqueOutgoing <TForward, TBackward> @from, IFlowComponentUniqueIncoming <TForward, TBackward> to)
        {
            var newPort = new FlowPort <TForward, TBackward>();

            from.Outgoing = newPort;
            to.Incoming   = newPort;

            AddAtomicConnection(from, to);
        }
Ejemplo n.º 4
0
 public FlowMerger(int number)
 {
     Number    = number;
     Incomings = new FlowPort <TForward, TBackward> [number];
     for (var i = 0; i < Incomings.Length; i++)
     {
         Incomings[i] = new FlowPort <TForward, TBackward>();
     }
 }
Ejemplo n.º 5
0
        private void Connect(FlowPort <TForward, TBackward> from, FlowPort <TForward, TBackward> to)
        {
            // Forward goes from [from]-->[to]
            // Backward goes from [to]-->[from]
            // they all point towards the same forward and backward elements
            var flowForward  = new TForward();
            var flowBackward = new TBackward();

            from.Forward  = flowForward;
            from.Backward = flowBackward;
            to.Forward    = flowForward;
            to.Backward   = flowBackward;
        }
Ejemplo n.º 6
0
        public FlowSplitter <TForward, TBackward> ConnectOutWithIns(IFlowComponentUniqueOutgoing <TForward, TBackward> @from, IFlowComponentUniqueIncoming <TForward, TBackward>[] tos)
        {
            // from --> Splitter --> to[]
            var elementNos = tos.Length;

            if (elementNos == 0)
            {
                throw new ArgumentException("need at least one source element");
            }
            else if (elementNos == 1)
            {
                var newPort = new FlowPort <TForward, TBackward>();
                from.Outgoing   = newPort;
                tos[0].Incoming = newPort;
                AddAtomicConnection(from, tos[0]);
                return(null);
            }
            else
            {
                // create virtual splitting component.
                var flowVirtualSplitter = CreateFlowVirtualSplitter(elementNos);

                var newPortToSplitter = new FlowPort <TForward, TBackward>();
                @from.Outgoing = newPortToSplitter;
                flowVirtualSplitter.Incoming = newPortToSplitter;
                AddAtomicConnection(from, flowVirtualSplitter);
                for (int i = 0; i < elementNos; i++)
                {
                    var newPortFromSplitter = new FlowPort <TForward, TBackward>();
                    flowVirtualSplitter.Outgoings[i] = newPortFromSplitter;
                    tos[i].Incoming = newPortFromSplitter;
                    AddAtomicConnection(flowVirtualSplitter, tos[i]);
                }
                return(flowVirtualSplitter);
            }
        }
Ejemplo n.º 7
0
 public FlowMerger(int number)
 {
     Number    = number;
     Incomings = new FlowPort <TForward, TBackward> [number];
 }