|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbcds.phison.sim.SimStatsCollector
public class SimStatsCollector
This class offers a synchronized map to store statistical collectors for Sim (and related classes). The simulator can share one instance among all the execution threads, and each of these can add/update variables to the common instance. At the end, the simulator driver (Sim.java) can print the accumulated results.
Collectors can be organized in groups based on their class. This is useful for reporting purposes: those that belong to exactly the same class can be "pretty-printed" in tabular form. Additionally, there is a group, whose name is the empty string, that can hold any collector and does not enfoce membership to a specific class.
Practically all methods in this class are syncrhonized.
Constructor Summary | |
---|---|
SimStatsCollector()
Creates a new instance and registers the default group, whose name is the empty string. |
Method Summary | ||
---|---|---|
boolean |
add(Collector var)
Adds the collector var to the default group, where
membership does not require being an instance of a specific class. |
|
|
add(T var,
java.lang.String grp_name,
java.lang.Class<T> grp_class)
Adds a new collector and associates it to a group. |
|
boolean |
addGroup(java.lang.String grp_name,
java.lang.Class<? extends Collector> grp_class)
Registers a new group and declares that its members should have the class grp_class to be admitted. |
|
void |
collect(java.lang.String var_name,
double value)
Locates the collector with the name var_name and calls
its Collector.collect(double) method. |
|
void |
collect(java.lang.String var_name,
double at,
double value)
Locates the collector with the name var_name and calls
its collect method under the assumption that the
collector object is an instance of Series . |
|
Collector |
get(java.lang.String var_name)
Returns the collector object with the given name, or null if such collector is not registered. |
|
java.util.Set<Collector> |
getGroupMembers(java.lang.String grp_name)
Returns a set containing the collectors of a given group. |
|
java.util.Set<java.lang.String> |
getGroupNames()
Returns a set containing the group names, including the default group. |
|
java.lang.String |
getGroupOf(java.lang.String var_name)
Returns the group name of the collector var_name , or null
if var_name is not registered. |
|
java.util.Set<java.lang.String> |
keySet()
Returns an unmodifiable set view of the collector names registered. |
|
boolean |
remove(java.lang.String var_name)
Removes a collector. |
|
int |
size()
Returns the number of collectors present. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimStatsCollector()
Method Detail |
---|
public <T extends Collector> boolean add(T var, java.lang.String grp_name, java.lang.Class<T> grp_class)
The actual type of the collector must match that of the group to which is to be added. Otherwise, a runtime exception is thrown.
java.lang.IllegalArgumentException
- if code var is null or
the collector's class and that of its desired group
are not the same.
Note that they must point to the same class reference (as in a.getClass()==b.getClass()), not just be class-compatible.
This exception may also be thrown in addGroup(java.lang.String, java.lang.Class extends bcds.tools.stat.Collector>)
,
which is called from there.
public boolean add(Collector var)
var
to the default group, where
membership does not require being an instance of a specific class.
public java.lang.String getGroupOf(java.lang.String var_name)
var_name
, or null
if var_name is not registered. The running time of this
method is proportional to the number of collectors present.
public int size()
public Collector get(java.lang.String var_name)
public java.util.Set<java.lang.String> keySet()
public boolean remove(java.lang.String var_name)
public boolean addGroup(java.lang.String grp_name, java.lang.Class<? extends Collector> grp_class)
grp_class
to be admitted. Groups must be unique.
only the first call to add a given group succeeds.
java.lang.IllegalArgumentException
- if code grp_name or
code grp_class is null.public void collect(java.lang.String var_name, double value)
var_name
and calls
its Collector.collect(double)
method. Calling this method with
a var_name that does not correspond to any registered
collector results in an NullPointerException.
public void collect(java.lang.String var_name, double at, double value)
var_name
and calls
its collect method under the assumption that the
collector object is an instance of Series
.
Calling this method with
a var_name that does not correspond to any registered
collector results in an NullPointerException.
public java.util.Set<java.lang.String> getGroupNames()
public java.util.Set<Collector> getGroupMembers(java.lang.String grp_name)
grp_name
is not registered, an empty set is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |