-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNamedSimProcess.java
More file actions
95 lines (84 loc) · 2.98 KB
/
NamedSimProcess.java
File metadata and controls
95 lines (84 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package cambio.simulator.entities;
import cambio.simulator.models.MiSimModel;
import desmoj.core.simulator.SimProcess;
/**
* Class that adds further options for the retrieving of names of {@link SimProcess}'s. Specifically, it provides a
* plain name for each process, that does not contain the number assigned by DESMO-J. However, these plain names are not
* guaranteed to be unique.
*
* <p>
* Also pre-computes the names of the entity so the strings are not generated on every method call. This gives a
* performance improvement over the default implementation when read a large amount of names.
* </p>
*
* <p>
* Plain names should be used when it comes to generating new entity names based on other entity names to prevent chains
* of unique identifiers.
*
* @author Lion Wagner
*/
public abstract class NamedSimProcess extends SimProcess {
private final MiSimModel model;
private String plainName;
private String quotedName;
private String quotedPlainName;
/**
* Constructs a new named non-repeating simulation process.
*
* @param model The model this process belongs to.
* @param name The name of this process.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedSimProcess(MiSimModel model, String name, boolean showInTrace) {
this(model, name, false, showInTrace);
}
/**
* Constructs a new named simulation process.
*
* @param model The model this process belongs to.
* @param name The name of this process.
* @param repeating If this process is automatically restart its lifecycle.
* @param showInTrace Flag indicating whether the entity should be shown in the trace.
*/
public NamedSimProcess(MiSimModel model, String name, boolean repeating, boolean showInTrace) {
super(model, name, repeating, showInTrace);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();
this.model = model;
}
public String getPlainName() {
return this.plainName;
}
/**
* Renames this entity.
*/
@Override
public void rename(String name) {
super.rename(name);
this.plainName = name;
this.quotedPlainName = "'" + name + "'";
this.quotedName = super.getQuotedName();
}
/**
* Gets a quoted version of the plain name of this object.
*
* @return the plain name of this entity surrounded with ' quotes.
*/
public String getQuotedPlainName() {
return this.quotedPlainName;
}
/**
* Gets a quoted version of the name of this object. The name will include the object number assigned by DESMO-J.
*
* @return the name of this entity surrounded with ' quotes.
*/
@Override
public String getQuotedName() {
return this.quotedName;
}
@Override
public MiSimModel getModel() {
return this.model;
}
}