package jetbrains.mps.debugger.java.runtime.engine;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import jetbrains.mps.logging.Logger;
import java.util.List;
import java.util.ArrayList;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.debugger.java.runtime.engine.events.Context;
import jetbrains.mps.debugger.java.runtime.engine.events.EventsProcessor;

@GeneratedClass(node = "r:0b933946-5ee4-42ea-9b69-bd1790a8e611(jetbrains.mps.debugger.java.runtime.engine)/8961922059449034278", model = "r:0b933946-5ee4-42ea-9b69-bd1790a8e611(jetbrains.mps.debugger.java.runtime.engine)")
public class DebugProcessMulticaster {
  private static Logger LOG = Logger.getLogger(DebugProcessMulticaster.class);
  private final List<DebugProcessListener> myListeners = new ArrayList<DebugProcessListener>();
  public DebugProcessMulticaster() {
  }
  private List<DebugProcessListener> getListeners() {
    synchronized (myListeners) {
      List<DebugProcessListener> result = new ArrayList<DebugProcessListener>(myListeners);
      return result;
    }
  }
  public void addListener(@NotNull DebugProcessListener listener) {
    synchronized (myListeners) {
      myListeners.add(listener);
    }
  }
  public void removeListener(@NotNull DebugProcessListener listener) {
    synchronized (myListeners) {
      myListeners.remove(listener);
    }
  }
  public void connectorIsReady() {
    for (DebugProcessListener listener : getListeners()) {
      try {
        listener.connectorIsReady();
      } catch (Throwable t) {
        LOG.error(t);
      }
    }
  }
  public void paused(@NotNull Context suspendContext) {
    for (DebugProcessListener listener : getListeners()) {
      try {
        listener.paused(suspendContext);
      } catch (Throwable t) {
        LOG.error(t);
      }
    }
  }
  public void resumed(@NotNull Context suspendContext) {
    for (DebugProcessListener listener : getListeners()) {
      try {
        listener.resumed(suspendContext);
      } catch (Throwable t) {
        LOG.error(t);
      }
    }
  }
  public void processDetached(@NotNull EventsProcessor process, boolean closedByUser) {
    for (DebugProcessListener listener : getListeners()) {
      try {
        listener.processDetached(process, closedByUser);
      } catch (Throwable t) {
        LOG.error(t);
      }
    }
  }
  public void processAttached(@NotNull EventsProcessor process) {
    for (DebugProcessListener listener : getListeners()) {
      try {
        listener.processAttached(process);
      } catch (Throwable t) {
        LOG.error(t);
      }
    }
  }
}
