1 package cz.cuni.amis.pogamut.base.agent.navigation.impl;
2
3 import cz.cuni.amis.pogamut.base.agent.navigation.IPathExecutorState;
4 import cz.cuni.amis.pogamut.base.agent.navigation.PathExecutorState;
5 import cz.cuni.amis.utils.flag.Flag;
6
7
8
9
10
11
12
13
14
15
16
17 public class BasePathExecutorState implements IPathExecutorState {
18
19
20
21
22 public static final BasePathExecutorState INSTANTIATED = new BasePathExecutorState(PathExecutorState.INSTANTIATED);
23
24
25
26
27 public static final BasePathExecutorState FOLLOW_PATH_CALLED = new BasePathExecutorState(PathExecutorState.FOLLOW_PATH_CALLED);
28
29
30
31
32 public static final BasePathExecutorState PATH_COMPUTED = new BasePathExecutorState(PathExecutorState.PATH_COMPUTED);
33
34
35
36
37 public static final BasePathExecutorState PATH_COMPUTATION_FAILED = new BasePathExecutorState(PathExecutorState.PATH_COMPUTATION_FAILED);
38
39
40
41
42 public static final BasePathExecutorState SWITCHED_TO_ANOTHER_PATH_ELEMENT = new BasePathExecutorState(PathExecutorState.SWITCHED_TO_ANOTHER_PATH_ELEMENT);
43
44
45
46
47 public static final BasePathExecutorState TARGET_REACHED = new BasePathExecutorState(PathExecutorState.TARGET_REACHED);
48
49
50
51
52 public static final BasePathExecutorState STUCK = new BasePathExecutorState(PathExecutorState.STUCK);
53
54
55
56
57 public static final BasePathExecutorState STOPPED = new BasePathExecutorState(PathExecutorState.STOPPED);
58
59 public static BasePathExecutorState getState(PathExecutorState state) {
60 switch(state) {
61 case INSTANTIATED: return BasePathExecutorState.INSTANTIATED;
62 case FOLLOW_PATH_CALLED: return BasePathExecutorState.FOLLOW_PATH_CALLED;
63 case PATH_COMPUTED: return BasePathExecutorState.PATH_COMPUTED;
64 case PATH_COMPUTATION_FAILED: return BasePathExecutorState.PATH_COMPUTATION_FAILED;
65 case SWITCHED_TO_ANOTHER_PATH_ELEMENT: return BasePathExecutorState.SWITCHED_TO_ANOTHER_PATH_ELEMENT;
66 case TARGET_REACHED: return BasePathExecutorState.TARGET_REACHED;
67 case STUCK: return BasePathExecutorState.STUCK;
68 case STOPPED: return BasePathExecutorState.STOPPED;
69 default:
70 throw new RuntimeException("Unhandled state '" + state + "', can't create corresponding BasePathExecutorState.");
71 }
72 }
73
74
75
76
77 private PathExecutorState state;
78
79
80
81
82
83
84
85
86 public BasePathExecutorState(PathExecutorState state) {
87 this.state = state;
88 }
89
90 @Override
91 public PathExecutorState getState() {
92 return state;
93 }
94
95 }