public class

RuleStorage

extends Object
implements Provider<T> SharedStateStorage
java.lang.Object
   ↳ uk.ac.imperial.presage2.rules.RuleStorage

Class Overview

Implementation of SharedStateStorage using a drools StatefulKnowledgeSession.

Summary

Public Constructors
RuleStorage(Map<IntegerString> ruleFiles)
Public Methods
void change(String name, UUID participantID, Serializable value)

Change a shared state value for a given agent to a given value.

void change(String name, UUID participantID, StateTransformer change)

Modify a shared state value for a given agent.

void changeGlobal(String name, Serializable value)

Change a global shared state value to a given new value,

Value will not be changed until the next time slice.

void changeGlobal(String name, StateTransformer change)

Modify a global shared state value.

void create(String name, UUID participantID, Serializable value)

Create a shared state value for a given agent.

void create(ParticipantSharedState state)

Create a shared state value for a given agent.

void createGlobal(String name, Serializable value)

Create a value in the global shared state.

void createGlobal(SharedState state)

Create a value in the global shared state.

void delete(String name, UUID participantID)

Delete a shared state value for a given agent.

void deleteGlobal(String name)

Delete a value in the global shared state.

StatefulKnowledgeSession get()
Serializable get(String name, UUID participantID)
Get a shared state value for an individual agent.
Serializable getGlobal(String name)
Get a global shared state value.
KnowledgeBase getKbase()
void incrementTime()
void setEventBus(EventBus e)
Protected Methods
Map<UUIDMap<String, FactHandle>> initAgentStateMap()
Map<String, FactHandle> initGlobalStateMap()
void initialiseTranslators(Set<StateTranslator> stateTranslators, Set<AgentStateTranslator> agentStateTranslators)
void updateState()
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.inject.Provider
From interface javax.inject.Provider
From interface uk.ac.imperial.presage2.core.TimeDriven
From interface uk.ac.imperial.presage2.core.environment.EnvironmentSharedStateAccess

Public Constructors

public RuleStorage (Map<IntegerString> ruleFiles)

Public Methods

public void change (String name, UUID participantID, Serializable value)

Change a shared state value for a given agent to a given value.

Value will not be changed until the next time slice.

Parameters
name String key of the value to change
participantID UUID of the agent
value StateTransformer which will perform the change.

public void change (String name, UUID participantID, StateTransformer change)

Modify a shared state value for a given agent.

Value will not be changed until the next time slice.

Parameters
name String key of the value to change
participantID UUID of the agent
change StateTransformer which will perform the change.

public void changeGlobal (String name, Serializable value)

Change a global shared state value to a given new value,

Value will not be changed until the next time slice.

Parameters
name String key name of the value to be changed.
value New value to be set.

public void changeGlobal (String name, StateTransformer change)

Modify a global shared state value.

Value will not be changed until the next time slice.

Parameters
name String key name of the value to be changed.
change StateTransformer which will perform the change.

public void create (String name, UUID participantID, Serializable value)

Create a shared state value for a given agent.

Value will be created in the current time cycle.

Parameters
name String key of the value to change
participantID UUID of the agent
value Initial value to set state to.

public void create (ParticipantSharedState state)

Create a shared state value for a given agent.

Value will be created in the current time cycle.

Parameters
state ParticipantSharedState describing the state to create.

public void createGlobal (String name, Serializable value)

Create a value in the global shared state.

Value will be created in the current time cycle.

Parameters
name String key name of the value to create.
value Initial value to set state to.

public void createGlobal (SharedState state)

Create a value in the global shared state.

Value will be created in the current time cycle.

Parameters
state SharedState describing the state to create.

public void delete (String name, UUID participantID)

Delete a shared state value for a given agent.

Parameters
name String key of the value to change
participantID UUID of the agent

public void deleteGlobal (String name)

Delete a value in the global shared state.

Parameters
name String key name of the value to create.

public StatefulKnowledgeSession get ()

public Serializable get (String name, UUID participantID)

Get a shared state value for an individual agent.

Parameters
name String key of the value to get
participantID UUID of the agent
Returns
  • Serializable value if it exists in the state for this agent, null otherwise.

public Serializable getGlobal (String name)

Get a global shared state value.

Parameters
name String key name of the value
Returns
  • Serializable value if it exists in the state, null otherwise.

public KnowledgeBase getKbase ()

public void incrementTime ()

public void setEventBus (EventBus e)

Protected Methods

protected Map<UUIDMap<String, FactHandle>> initAgentStateMap ()

protected Map<String, FactHandle> initGlobalStateMap ()

protected void initialiseTranslators (Set<StateTranslator> stateTranslators, Set<AgentStateTranslator> agentStateTranslators)

protected void updateState ()