View Javadoc

1   package org.lcsim.recon.tracking.trfutil;
2   import java.util.List;
3   import java.util.Iterator;
4   
5   /**
6    * This is an abtract class to be used as a base for any class which will
7    * hold random generators.  It provides an interface for fetching all the
8    * generators and for registering their states.
9    *
10   * @author Norman A. Graf
11   * @version 1.0
12   */
13  public abstract class RandomSimulator
14  {
15      
16      /**
17       * Return the List of random generators.
18       * This <b> must </b> be implemented in subclasses.
19       *
20       * @return  List of RandomGenerators.
21       */
22      public abstract List generators();
23      /**
24       * Register the generators.
25       * This <b>should not</b> be overridden in subclasses.
26       *
27       * @param   reg RandomRegistry to be registered
28       */
29      public void registerGenerators(RandomRegistry reg)
30      {
31          
32          // Fetch the list of generators.
33          List gens = generators();
34          
35          // Register them.
36          Iterator igen;
37          for ( igen=gens.iterator(); igen.hasNext(); )
38              reg.addGenerator( (RandomGenerator) igen.next() );
39          
40      }
41      
42      /**
43       * String representation of this class
44       * @return short description of this class
45       */
46      public String toString()
47      {
48          String className = getClass().getName();
49          int lastDot = className.lastIndexOf('.');
50          if(lastDot!=-1)className = className.substring(lastDot+1);
51          
52          return className;
53      }
54      
55  }
56  
57  
58