1 package net.mograsim.logic.core.components;
3 import net.mograsim.logic.core.LogicObservable;
4 import net.mograsim.logic.core.LogicObserver;
5 import net.mograsim.logic.core.timeline.Timeline;
6 import net.mograsim.logic.core.timeline.TimelineEventHandler;
9 * A basic component that recomputes all outputs (with a delay), when it is updated.
11 * @author Fabian Stemmler
13 public abstract class BasicCoreComponent extends CoreComponent implements LogicObserver
15 private int processTime;
19 * @param processTime Amount of time this component takes to update its outputs. Must be more than 0, otherwise 1 is assumed.
21 * @author Fabian Stemmler
23 public BasicCoreComponent(Timeline timeline, int processTime)
26 this.processTime = processTime > 0 ? processTime : 1;
30 public final void update(LogicObservable initiator)
37 TimelineEventHandler delayedUpdates = compute();
38 if (delayedUpdates != null)
39 timeline.addEvent(delayedUpdates, processTime);
42 protected abstract TimelineEventHandler compute();