package geniusweb.protocol.session;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import geniusweb.actions.Action;
import geniusweb.inform.Agreements;
import geniusweb.progress.Progress;
import geniusweb.protocol.NegoState;
import geniusweb.protocol.session.amop.AMOPState;
import geniusweb.protocol.session.learn.LearnState;
import geniusweb.protocol.session.mopac.MOPACState;
import geniusweb.protocol.session.saop.SAOPState;
import geniusweb.protocol.session.shaop.SHAOPState;
/**
* The current state of the session. E.g. typically contains the actions so far
* and the parties currently connected.
* The state checks if transitions (Actions from the party) are following the
* protocol, and thus implement most of the protocol .
*
* If protocol errors occur, these should be stored in the state and the state
* should become {@link #isFinal(long)}. Throwing should happen only in case of
* a bug.
*
* Implementations should be immutable (to ensure thread safety, testability
* etc).
*
* States must be serializable so that listeners can follow what is going on in
* the protocol. As uaual, mark non-serializable fields as transient.
*/
@JsonSubTypes({ @JsonSubTypes.Type(value = SAOPState.class),
@JsonSubTypes.Type(value = SHAOPState.class),
@JsonSubTypes.Type(value = AMOPState.class),
@JsonSubTypes.Type(value = MOPACState.class),
@JsonSubTypes.Type(value = LearnState.class) })
public interface SessionState extends NegoState {
@Override
SessionSettings getSettings();
/**
*
* @return unmodifyable list of actions done so far, in the order in which
* they arrived. List of list allows implementations to add some
* extra structure to the actions, eg one list per phase
*/
List getActions();
/**
*
* @return the progress of the session. Can return null if the session did
* not even start yet. Notice that the protocol determines when a
* session officially starts (eg, in SAOP it starts after all
* parties were connected succesfully).
*/
Progress getProgress();
/**
*
* @return the current standing {@link Agreements}. An agreement does not
* necessarily mean {@link #isFinal(long)}.
*/
Agreements getAgreements();
}