1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.experiment;
11
12 import java.io.Serializable;
13 import java.util.Collection;
14 import java.util.HashMap;
15 import java.util.Iterator;
16 import java.util.Map;
17
18 import nl.tudelft.simulation.jstats.streams.StreamInterface;
19
20
21 /***
22 * The replication of a runcontrol.
23 * <p>
24 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
25 * University of Technology </a>, the Netherlands. <br>
26 * See for project information <a
27 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
28 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
29 * License (GPL) </a>, no warranty <br>
30 *
31 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
32 * Jacobs </a>
33 * @version 1.7 Apr 7, 2004
34 * @since 1.4
35 */
36 public class Replication implements Serializable
37 {
38
39 /***
40 * streams used in the replication
41 *
42 * @uml.property name="streams"
43 */
44 private Map streams = new HashMap();
45
46 /***
47 * description the description of the replication
48 *
49 * @uml.property name="description"
50 */
51 private String description = "rep_no_description";
52
53 /***
54 * runControl reflects the RunControl
55 *
56 * @uml.property name="runControl"
57 */
58 private RunControl runControl;
59
60 /***
61 * the number of the replication
62 *
63 * @uml.property name="number"
64 */
65 private int number = 0;
66
67
68 /***
69 * constructs a new Replication
70 *
71 * @param runControl reflects the RunControl
72 * @param number the number
73 */
74 public Replication(final RunControl runControl, final int number)
75 {
76 super();
77 this.runControl = runControl;
78 this.number = number;
79 }
80
81 /***
82 * gets the description of this replication
83 *
84 * @return String the description of this replication
85 *
86 * @uml.property name="description"
87 */
88 public String getDescription()
89 {
90 return this.description;
91 }
92
93 /***
94 * returns the number of this replication
95 *
96 * @return int the number
97 *
98 * @uml.property name="number"
99 */
100 public int getNumber()
101 {
102 return this.number;
103 }
104
105 /***
106 * returns the parental RunControl
107 *
108 * @return RunControl the runcontrol
109 *
110 * @uml.property name="runControl"
111 */
112 public RunControl getRunControl()
113 {
114 return this.runControl;
115 }
116
117 /***
118 * returns the streams
119 *
120 * @return Map the streams of this replication
121 *
122 * @uml.property name="streams"
123 */
124 public Map getStreams()
125 {
126 return this.streams;
127 }
128
129
130 /***
131 * returns a specific stream
132 *
133 * @param name the name of the stream
134 * @return StreamInterface the stream
135 */
136 public StreamInterface getStream(final String name)
137 {
138 return (StreamInterface) this.streams.get(name);
139 }
140
141 /***
142 * resets the RunControl
143 */
144 public synchronized void reset()
145 {
146 for (Iterator i = this.streams.values().iterator(); i.hasNext();)
147 {
148 StreamInterface stream = (StreamInterface) i.next();
149 stream.reset();
150 }
151 }
152
153 /***
154 * Sets the description of this replication
155 *
156 * @param description the description of this replication
157 *
158 * @uml.property name="description"
159 */
160 public void setDescription(final String description)
161 {
162 this.description = description;
163 }
164
165 /***
166 * sets the stream for this replication
167 *
168 * @param streams the map of stream,name tuples
169 *
170 * @uml.property name="streams"
171 */
172 public void setStreams(final Map streams)
173 {
174 this.streams = streams;
175 }
176
177 /***
178 * @see java.lang.Object#toString()
179 */
180 public String toString()
181 {
182 String result = super.toString() + " ; " + this.getDescription()
183 + " ; streams=[";
184 Collection values = this.streams.values();
185 for (Iterator i = values.iterator(); i.hasNext();)
186 {
187 result = result + i.next().toString() + " ; ";
188 }
189 result = result.substring(0, result.length() - 2) + "]";
190 return result;
191 }
192 }