Skip to content

Package: IGameMemoryProvider

IGameMemoryProvider

Coverage

1: package de.fhdw.gaming.ipspiel23.memory;
2:
3: import java.util.Optional;
4:
5: /**
6: * Interface for the Memory Provider. Returns Memory for a Memory Identifier.
7: */
8: public interface IGameMemoryProvider {
9:
10: /**
11: * Requests a game memory instance using the specified reuse identifier.
12: * If a game memory instance matches the reuse identifier, that existing instance will be returned.
13: * Otherwise, a new instance will be created for that reuse identifier.
14: *
15: * @param <ROUND_DATA> The type of round data to be stored in the game memory.
16: * @param reuseIdentifier The state-bound ID uniquely identifying the strategy instance requesting the game memory.
17: * @param capacity The requested capacity of the game memory. The capacity is ignored if a memory is found!
18: * @return the new or existing game memory instance.
19: */
20: <ROUND_DATA> IGameMemory<ROUND_DATA> requestMemoryForStrategy(
21: IGameMemoryIdentifier reuseIdentifier, IGameMemoryCapacity capacity);
22:
23: /**
24: * Tries to request a game memory instance using the specified reuse identifier.
25: * If a game memory instance matches the reuse identifier, that existing instance will be returned.
26: * Otherwise, an empty optional will be returned.
27: *
28: * @param <ROUND_DATA> The type of round data to be stored in the game memory.
29: * @param reuseIdentifier The state-bound ID uniquely identifying the strategy instance requesting the game memory.
30: * @return the existing game memory instance, or an empty optional if no instance matches the reuse identifier.
31: */
32: <ROUND_DATA> Optional<IGameMemory<ROUND_DATA>> tryRequestMemoryForStrategy(
33: IGameMemoryIdentifier reuseIdentifier);
34: }