package network.aika.neuron;

import network.aika.neuron.excitatory.PatternNeuron;
import network.aika.neuron.excitatory.PatternPartNeuron;
import network.aika.neuron.excitatory.PatternPartSynapse;
import network.aika.neuron.excitatory.PatternSynapse;
import network.aika.neuron.inhibitory.InhibitoryNeuron;
import network.aika.neuron.inhibitory.InhibitorySynapse;
import network.aika.neuron.inhibitory.PrimaryInhibitorySynapse;

public class Templates {

    public static final PatternPartNeuron PATTERN_PART_TEMPLATE = init(new PatternPartNeuron(), -1, "Template Patter Part Neuron");
    public static final PatternNeuron PATTERN_TEMPLATE = init(new PatternNeuron(), -2, "Template Patter Neuron");
    public static final InhibitoryNeuron INHIBITORY_TEMPLATE = init(new InhibitoryNeuron(), -3, "Template Inhibitory Neuron");

    public static final PatternPartSynapse PRIMARY_INPUT_SYNAPSE_TEMPLATE = init(new PatternPartSynapse(PATTERN_TEMPLATE, PATTERN_PART_TEMPLATE, null, false, false, true, false));
    public static final PatternPartSynapse RELATED_INPUT_SYNAPSE_FROM_PP_TEMPLATE = init(new PatternPartSynapse(PATTERN_PART_TEMPLATE, PATTERN_PART_TEMPLATE, null, false, false, true, false));
    public static final PatternPartSynapse RELATED_INPUT_SYNAPSE_FROM_INHIBITORY_TEMPLATE = init(new PatternPartSynapse(INHIBITORY_TEMPLATE, PATTERN_PART_TEMPLATE, null, false, false, true, false));
    public static final PatternPartSynapse SAME_PATTERN_SYNAPSE_TEMPLATE = init(new PatternPartSynapse(PATTERN_PART_TEMPLATE, PATTERN_PART_TEMPLATE, null, false, false, false, true));
    public static final PatternPartSynapse RECURRENT_SAME_PATTERN_SYNAPSE_TEMPLATE = init(new PatternPartSynapse(PATTERN_TEMPLATE, PATTERN_PART_TEMPLATE, null, false, true, false, true));
    public static final PatternPartSynapse NEGATIVE_SYNAPSE_TEMPLATE = init(new PatternPartSynapse(INHIBITORY_TEMPLATE, PATTERN_PART_TEMPLATE, null, true, true, false, false));

    public static final PatternSynapse PATTERN_SYNAPSE_TEMPLATE = init(new PatternSynapse(PATTERN_PART_TEMPLATE, PATTERN_TEMPLATE, null));

    public static final PrimaryInhibitorySynapse PRIMARY_INHIBITORY_SYNAPSE_TEMPLATE = init(new PrimaryInhibitorySynapse(PATTERN_TEMPLATE, INHIBITORY_TEMPLATE, null));
    public static final InhibitorySynapse INHIBITORY_SYNAPSE_TEMPLATE = init(new InhibitorySynapse(PATTERN_PART_TEMPLATE, INHIBITORY_TEMPLATE, null));

    private static <N extends Neuron> N init(N n, int id, String label) {
        NeuronProvider np = new NeuronProvider(id);
        np.setNeuron(n);
        n.setProvider(np);
        n.setLabel(label);
        return n;
    }

    private static <S extends Synapse> S init(S ts) {
        ts.linkInput();
        ts.linkOutput();
        return ts;
    }
}

@@ -890,38 +890,63 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A            
 new PatternPartS
@@ -1017,35 +1017,93 @@
 se, true, false)
+,%0A            true,%0A                    true%0A            
 );%0A
+%0A
     public stati
@@ -1161,38 +1161,71 @@
 OM_PP_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternPartS
@@ -1301,35 +1301,101 @@
 se, true, false)
+,%0A                    true,%0A                    true%0A            
 );%0A
+%0A
     public stati
@@ -1461,38 +1461,71 @@
 ITORY_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternPartS
@@ -1607,19 +1607,85 @@
 , false)
+,%0A                    true,%0A                    true%0A            
 );%0A
+%0A
     publ
@@ -1742,38 +1742,71 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternPartS
@@ -1882,35 +1882,101 @@
 se, false, true)
+,%0A                    true,%0A                    true%0A            
 );%0A
+%0A
     public stati
@@ -2035,38 +2035,71 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternPartS
@@ -2177,19 +2177,85 @@
 e, true)
+,%0A                    true,%0A                    true%0A            
 );%0A
+%0A
     publ
@@ -2308,38 +2308,71 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternPartS
@@ -2453,16 +2453,81 @@
 , false)
+,%0A                    true,%0A                    true%0A            
 );%0A%0A    
@@ -2579,38 +2579,71 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A                    
 new PatternSynap
@@ -2683,32 +2683,97 @@
 _TEMPLATE, null)
+,%0A                    true,%0A                    true%0A            
 );%0A%0A    public s
@@ -2838,32 +2838,44 @@
 NAPSE_TEMPLATE =
+%0A           
  init(new Primar
@@ -2937,19 +2937,85 @@
 E, null)
+,%0A                    true,%0A                    true%0A            
 );%0A
+%0A
     publ
@@ -3069,38 +3069,71 @@
 NAPSE_TEMPLATE =
- init(
+%0A            init(%0A                    
 new InhibitorySy
@@ -3187,20 +3187,87 @@
 E, null)
+,%0A                    false,%0A                    true%0A            
 );%0A%0A
+%0A
     priv
@@ -3542,36 +3542,142 @@
 S ts
-) %7B%0A        ts.linkInput();%0A
+, boolean linkInput, boolean linkOutput) %7B%0A        if(linkInput) %7B%0A            ts.linkInput();%0A        %7D%0A        if(linkOutput) %7B%0A    
     
@@ -3693,24 +3693,34 @@
 nkOutput();%0A
+        %7D%0A
         retu

work on templates