package com.ociweb.gl.impl;

import com.ociweb.gl.impl.schema.MessagePrivate;
import com.ociweb.pronghorn.pipe.Pipe;
import com.ociweb.pronghorn.pipe.PipeConfig;

public class PrivateTopic {

	private Pipe<MessagePrivate> p;
	public final String topic;
	
	private final PipeConfig<MessagePrivate> config;
	
	public PrivateTopic(String topic, int messageCount, int messageSize, boolean hideLabels) {
		this.topic = topic;
		this.config = new PipeConfig<MessagePrivate>(MessagePrivate.instance, messageCount, messageSize);		
		if (hideLabels) {
			this.config.hideLabels(); //private topics can clutter if they show all the details.
		}
	}
	
	public PrivateTopic(String topic, PipeConfig<MessagePrivate> config) {
		this.topic = topic;
		this.config = config;
	}

	public Pipe<MessagePrivate> getPipe() {
		if (null==p) {
			p = PipeConfig.pipe(config);			
		}
		return p;
	}
	
}


@@ -214,20 +214,52 @@
 Private%3E
+%5B%5D
  p;%0A
+%09private int activeIndex=0;%0A%09%0A
 %09public 
@@ -385,16 +385,32 @@
 eCount, 
+%0A%09%09%09            
 int mess
@@ -432,24 +432,62 @@
 n hideLabels
+,%0A%09%09%09            int parallelismTracks
 ) %7B%0A%09%09this.t
@@ -714,16 +714,80 @@
 ls.%0A%09%09%7D%0A
+%09%09this.p = (Pipe%3CMessagePrivate%3E%5B%5D)new Pipe%5BparallelismTracks%5D;%0A
 %09%7D%0A%09%0A%09pu
@@ -946,16 +946,64 @@
 ipe() %7B%0A
+%09%09Pipe%3CMessagePrivate%3E result = p%5BactiveIndex%5D;%0A
 %09%09if (nu
@@ -1008,19 +1008,48 @@
 null
+ 
 ==
-p) %7B%0A%09%09%09p
+ result) %7B%0A%09%09%09result = p%5BactiveIndex%5D
  = P
@@ -1076,25 +1076,486 @@
 g);%09
+%0A
 %09%09
+%7D
 %0A%09%09
-%7D%0A%09%09return p
+activeIndex = 0; //clear back to zero%0A%09%09return result;%0A%09%09%0A%09%09//one vs many is causing unconnected pipe%0A%09%09%0A%09%7D%0A%0A%09public void cloneSource(int parallelInstanceUnderActiveConstruction) %7B%0A%09%09//store index so next getPipe() call picks it up%0A%09%09activeIndex = parallelInstanceUnderActiveConstruction;%0A%09%7D%0A%0A%09public void cloneTarget(int parallelInstanceUnderActiveConstruction) %7B%0A%09%09//store index so next getPipe() call picks it up%0A%09%09activeIndex = parallelInstanceUnderActiveConstruction
 ;%0A%09%7D

bring in these changes