public class

AbstractEnvironment

extends Object
implements TimeDriven EnvironmentConnector EnvironmentServiceProvider
java.lang.Object
   ↳ uk.ac.imperial.presage2.util.environment.AbstractEnvironment

Class Overview

General implementation of an environment.

Summary

Fields
protected Set<ActionHandler> actionHandlers
protected Map<UUIDUUID> authkeys Map of participant IDs to authkeys.
protected boolean deferActions
protected Queue<AbstractEnvironment.DeferedAction> deferedActions
protected Set<EnvironmentService> globalEnvironmentServices Global services provided by this environment's EnvironmentServiceProvider
protected Set<Class<? extends EnvironmentService>> participantEnvironmentServices EnvironmentService classes to instantiate and send to agents when they register(EnvironmentRegistrationRequest) with the environment.
protected Set<Class<? extends EnvironmentService>> participantGlobalEnvironmentServices EnvironmentServices to pass to agents on registration with the environment.
protected Map<UUIDParticipant> registeredParticipants Map of Participants in the simulation
protected SharedStateStorage sharedState
Public Constructors
AbstractEnvironment(SharedStateStorage sharedState)

Creates the Environment, initialising it ready for participants to register and act.

Public Methods
void act(Action action, UUID actor, UUID authkey)

Perform an Action on the environment.

void deferActions(boolean defer)
void deregister(UUID participantID, UUID authkey)

Deregister a participant with the environment.

<T extends EnvironmentService> T getEnvironmentService(Class<T> type)
Return a global environment service for the given class name.
void incrementTime()
synchronized EnvironmentRegistrationResponse register(EnvironmentRegistrationRequest request)

Registers a Participant with the simulation environment.

void registerTimeDriven(Scenario s)
Protected Methods
void addActionHandlers(Set<ActionHandler> handlers)
void addGlobalEnvironmentServices(Set<EnvironmentService> services)
void addParticipantEnvironmentServices(Set<Class<? extends EnvironmentService>> services)
void addParticipantGlobalEnvironmentServices(Set<Class<? extends EnvironmentService>> services)
Set<EnvironmentService> generateServices(EnvironmentRegistrationRequest request)

Generate a Set of EnvironmentServices for a participant to be sent.

Set<ActionHandler> initialiseActionHandlers()
Initialise a set of ActionHandlers which the environment will use to process Actions.
Set<EnvironmentService> initialiseGlobalEnvironmentServices()
Initialise the global environment services this environment will provide.
[Expand]
Inherited Methods
From class java.lang.Object
From interface uk.ac.imperial.presage2.core.TimeDriven
From interface uk.ac.imperial.presage2.core.environment.EnvironmentConnector
From interface uk.ac.imperial.presage2.core.environment.EnvironmentServiceProvider

Fields

protected Set<ActionHandler> actionHandlers

protected Map<UUIDUUID> authkeys

Map of participant IDs to authkeys.

protected boolean deferActions

protected Queue<AbstractEnvironment.DeferedAction> deferedActions

protected Set<EnvironmentService> globalEnvironmentServices

Global services provided by this environment's EnvironmentServiceProvider

protected Set<Class<? extends EnvironmentService>> participantEnvironmentServices

EnvironmentService classes to instantiate and send to agents when they register(EnvironmentRegistrationRequest) with the environment.

protected Set<Class<? extends EnvironmentService>> participantGlobalEnvironmentServices

EnvironmentServices to pass to agents on registration with the environment. Must be available via this environment's EnvironmentServiceProvider.

protected Map<UUIDParticipant> registeredParticipants

Map of Participants in the simulation

protected SharedStateStorage sharedState

Public Constructors

public AbstractEnvironment (SharedStateStorage sharedState)

Creates the Environment, initialising it ready for participants to register and act.

The following is initialised:

  • Registered participants map
  • Global shared state
  • Participant shared state
  • Authkeys
  • Action handlers

Public Methods

public void act (Action action, UUID actor, UUID authkey)

public void deferActions (boolean defer)

public void deregister (UUID participantID, UUID authkey)

Deregister a participant with the environment.

public T getEnvironmentService (Class<T> type)

Return a global environment service for the given class name.

public void incrementTime ()

public void registerTimeDriven (Scenario s)

Protected Methods

protected void addActionHandlers (Set<ActionHandler> handlers)

protected void addGlobalEnvironmentServices (Set<EnvironmentService> services)

protected void addParticipantEnvironmentServices (Set<Class<? extends EnvironmentService>> services)

protected void addParticipantGlobalEnvironmentServices (Set<Class<? extends EnvironmentService>> services)

protected Set<EnvironmentService> generateServices (EnvironmentRegistrationRequest request)

Generate a Set of EnvironmentServices for a participant to be sent.

protected Set<ActionHandler> initialiseActionHandlers ()

Initialise a set of ActionHandlers which the environment will use to process Actions.

protected Set<EnvironmentService> initialiseGlobalEnvironmentServices ()

Initialise the global environment services this environment will provide. This services will then be provided through the EnvironmentServiceProvider interface.

Returns
  • Set of global services to provide.