00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.calcium.skeletons;
00032
00033 import java.util.Arrays;
00034 import java.util.List;
00035
00036 import java.util.Vector;
00037
00038 import org.objectweb.proactive.calcium.interfaces.Instruction;
00039 import org.objectweb.proactive.calcium.interfaces.Skeleton;
00040
00047 public class Pipe<T> implements Skeleton<T> {
00048
00049 Vector<Skeleton<T>> stages;
00050
00051 public Pipe(Skeleton<T> child1, Skeleton<T> child2){
00052
00053 stages = new Vector<Skeleton<T>>();
00054 stages.add(child1);
00055 stages.add(child2);
00056 }
00057
00058 public Pipe(Skeleton<T>... args){
00059 this(Arrays.asList(args));
00060 }
00061
00062 public Pipe(List<Skeleton<T>> stages){
00063 if(stages.size() <=0 ) {
00064 throw new IllegalArgumentException("Pipe must have at least one stage");
00065 }
00066 this.stages = new Vector<Skeleton<T>>();
00067 this.stages.addAll(stages);
00068 }
00069
00070 public Vector<Instruction<T>> getInstructionStack() {
00071
00072 Vector<Instruction<T>> instruction = new Vector<Instruction<T>>();
00073
00074
00075 for(int i=stages.size()-1;i>=0;i--){
00076 instruction.addAll(stages.get(i).getInstructionStack());
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 return instruction;
00090 }
00091 }