package modules.gradient;

import utils.*;
import simulator.*;
import java.util.*;

public class GradientInternalPropagation implements PropagationTest {
  private final Object[] gradients;
  public GradientInternalPropagation(Object g) { 
    gradients = new Object[1];
    gradients[0]=g; // copy it over
  }

  public GradientInternalPropagation(Object[] g) { 
    gradients = new Object[g.length];
    for(int i=0;i<gradients.length;i++) gradients[i]=g[i]; // copy it over
  }

  public boolean propagate(Gradient g, PortedProcessor pp) {
    ActiveGradient ag = (ActiveGradient)pp.getModule("ActiveGradient");
    for(int i=0;i<gradients.length;i++) 
      if(ag.get(gradients[i])==null) 
        return false;
    return true;
  }
}
