Package org.protelis.vm.impl
Class SimpleNetworkManager
- java.lang.Object
-
- org.protelis.vm.impl.SimpleNetworkManager
-
- All Implemented Interfaces:
NetworkManager
public final class SimpleNetworkManager extends java.lang.Object implements NetworkManager
Stub network manager for testing, in which there are no neighbors and no messages are ever sent.
-
-
Constructor Summary
Constructors Constructor Description SimpleNetworkManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<DeviceUID,java.util.Map<CodePath,java.lang.Object>>
getNeighborState()
Called byProtelisVM
during execution to collect the most recent information available from neighbors.void
shareState(java.util.Map<CodePath,java.lang.Object> toSend)
Called byProtelisVM
during execution to send its current shared state to neighbors.
-
-
-
Method Detail
-
getNeighborState
public java.util.Map<DeviceUID,java.util.Map<CodePath,java.lang.Object>> getNeighborState()
Description copied from interface:NetworkManager
Called byProtelisVM
during execution to collect the most recent information available from neighbors. The call is serial within the execution, so this should probably poll state maintained by a separate thread, rather than gathering state during this call.- Specified by:
getNeighborState
in interfaceNetworkManager
- Returns:
- A map associating each neighbor with its shared state. The object
returned should not be modified, and
ProtelisVM
will not change it either.
-
shareState
public void shareState(java.util.Map<CodePath,java.lang.Object> toSend)
Description copied from interface:NetworkManager
Called byProtelisVM
during execution to send its current shared state to neighbors. The call is serial within the execution, so this should probably queue up a message to be sent, rather than actually carrying out a lengthy operations during this call.- Specified by:
shareState
in interfaceNetworkManager
- Parameters:
toSend
- Shared state to be transmitted to neighbors.
-
-