View Javadoc

1   package org.lcsim.detector;
2   
3   import org.lcsim.detector.identifier.IIdentifier;
4   
5   /**
6    * 
7    * This class is the global store of {@link org.lcsim.detector.IDetectorElement}
8    * objects and can be accessed as a singleton.
9    * 
10   * @author Jeremy McCormick <jeremym@slac.stanford.edu>
11   *
12   */
13  public class DetectorElementStore 
14  extends DetectorElementContainer
15  implements IDetectorElementStore
16  {
17  	private static DetectorElementStore store = null;
18  
19  	//DetectorElementMap cache = new DetectorElementMap();
20  	DetectorElementIdentifierHash cache = new DetectorElementIdentifierHash();	
21      
22  	public static IDetectorElementStore getInstance()
23  	{
24  		if ( store == null )
25  		{
26  			store = new DetectorElementStore();
27  		}
28  		return store;
29  	}
30      
31      public boolean add(IDetectorElement de)
32      {   
33      	super.add(de);    	
34      	cache.put(de);    	    
35      	return true;
36      }
37  
38      public IDetectorElementContainer find(IIdentifier id)
39      {  
40      	return cache.get(id);
41      }      
42      
43      public void clear()
44      {
45          cache.clear();
46          super.clear();
47      }
48  }