org.integratedmodelling.engine.modelling.runtime.AbstractSubjectInstantiator Maven / Gradle / Ivy
The newest version!
package org.integratedmodelling.engine.modelling.runtime;
import java.util.Map;
import org.integratedmodelling.api.knowledge.IObservation;
import org.integratedmodelling.api.modelling.IActiveSubject;
import org.integratedmodelling.api.modelling.IModel;
import org.integratedmodelling.api.modelling.IObservableSemantics;
import org.integratedmodelling.api.modelling.IScale;
import org.integratedmodelling.api.modelling.IState;
import org.integratedmodelling.api.modelling.contextualization.ISubjectInstantiator;
import org.integratedmodelling.api.modelling.resolution.IResolutionScope;
import org.integratedmodelling.api.modelling.scheduling.ITransition;
import org.integratedmodelling.api.monitoring.IMonitor;
import org.integratedmodelling.api.project.IProject;
import org.integratedmodelling.base.HashableObject;
import org.integratedmodelling.exceptions.KlabException;
public abstract class AbstractSubjectInstantiator extends HashableObject implements ISubjectInstantiator {
protected IScale scale;
protected IResolutionScope scope;
protected IActiveSubject context;
protected IModel model;
protected IMonitor monitor;
private boolean canDispose;
/**
* Create all subjects from an object source in a given scale and context.
*
* @param model
* @param objectSource
* @param scale
* @param contextSubject
* @param monitor
* @return new subjects
* @throws KlabException
*/
public abstract Map createSubjects(IActiveSubject context, ITransition transition)
throws KlabException;
@Override
public boolean canDispose() {
return canDispose;
}
@Override
public void setContext(Map parameters, IModel model, IProject project) {
}
@Override
public void initialize(IActiveSubject contextSubject, IResolutionScope context, IModel model, Map expectedInputs, Map expectedOutputs, IMonitor monitor)
throws KlabException {
this.context = contextSubject;
this.scope = context;
this.scale = contextSubject.getScale();
this.model = model;
this.monitor = monitor;
}
@Override
public Map createSubjects(IActiveSubject context, ITransition transition, Map inputs)
throws KlabException {
canDispose = transition == null ? !scale.isTemporallyDistributed() : transition.isLast();
return createSubjects(context, transition);
}
}