01: package hero.entity;
02:
03: /*
04: *
05: * NodeState.java -
06: * Copyright (C) 2002 Ecoo Team
07: * charoy@loria.fr
08: *
09: *
10: * This program is free software; you can redistribute it and/or
11: * modify it under the terms of the GNU Lesser General Public License
12: * as published by the Free Software Foundation; either version 2
13: * of the License, or (at your option) any later version.
14: *
15: * This program is distributed in the hope that it will be useful,
16: * but WITHOUT ANY WARRANTY; without even the implied warranty of
17: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: * GNU Lesser General Public License for more details.
19: *
20: * You should have received a copy of the GNU Lesser General Public License
21: * along with this program; if not, write to the Free Software
22: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23: */
24:
25: import hero.interfaces.BnNodeLocal;
26:
27: public abstract class NodeState {
28:
29: public static final int START = 0;
30: public static final int TERMINATE = 1;
31: public static final int SUSPEND = 2;
32: public static final int RESUME = 3;
33: public static final int EDGEINITIAL = 4;
34: public static final int ANTACTIVE = 5;
35: public static final int ACTIVE = 6;
36: public static final int CANCEL = 7;
37:
38: public static NodeState make(int type, boolean anticipable) {
39: if (anticipable) {
40: if (type == hero.interfaces.Constants.Nd.AND_JOIN_NODE) {
41: return new ActivityNodeState();
42: }
43: if (type == hero.interfaces.Constants.Nd.OR_JOIN_NODE) {
44: return new ActivityNodeState();
45: }
46: if (type == hero.interfaces.Constants.Nd.AND_JOIN_AUTOMATIC_NODE) {
47: return new AutomaticNodeState();
48: }
49: if (type == hero.interfaces.Constants.Nd.OR_JOIN_AUTOMATIC_NODE) {
50: return new AutomaticNodeState();
51: }
52: if (type == hero.interfaces.Constants.Nd.SUB_PROCESS_NODE) {
53: return new AutomaticSubNodeState();
54: }
55: } else {
56: if (type == hero.interfaces.Constants.Nd.AND_JOIN_NODE) {
57: return new TraditionalNodeState();
58: }
59: if (type == hero.interfaces.Constants.Nd.OR_JOIN_NODE) {
60: return new TraditionalNodeState();
61: }
62: if (type == hero.interfaces.Constants.Nd.AND_JOIN_AUTOMATIC_NODE) {
63: return new TraditionalAutomaticNodeState();
64: }
65: if (type == hero.interfaces.Constants.Nd.OR_JOIN_AUTOMATIC_NODE) {
66: return new TraditionalAutomaticNodeState();
67: }
68: if (type == hero.interfaces.Constants.Nd.SUB_PROCESS_NODE) {
69: return new AutomaticSubNodeState();
70: }
71: }
72: return new ActivityNodeState();
73: }
74:
75: public abstract int computeState(BnNodeLocal nd, int operation);
76:
77: }
|