View Javadoc

1   /*
2    * Copyright 2006 - 2012 Christina Bohk and Roland Ewald
3    *  
4    * Licensed under the Apache License, Version 2.0 (the "License"); 
5    * you may not use this file except in compliance with the License. 
6    * You may obtain a copy of the License at 
7    *  
8    *  http://www.apache.org/licenses/LICENSE-2.0
9    *  
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13   * See the License for the specific language governing permissions and 
14   * limitations under the License. 
15   */
16  package p3j.simulation;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  import java.util.logging.Level;
21  
22  import org.jamesii.SimSystem;
23  import org.jamesii.core.distributed.partition.Partition;
24  import org.jamesii.core.experiments.tasks.IComputationTask;
25  import org.jamesii.core.model.IModel;
26  import org.jamesii.core.parameters.ParameterBlock;
27  import org.jamesii.core.processor.IProcessor;
28  import org.jamesii.core.processor.ProcessorInformation;
29  import org.jamesii.core.processor.plugintype.ProcessorFactory;
30  
31  import p3j.pppm.IProjectionModel;
32  import p3j.pppm.ProjectionModel;
33  import p3j.simulation.assignments.plugintype.AbstractParamAssignmentGenFactory;
34  import p3j.simulation.assignments.plugintype.ParamAssignmentGenFactory;
35  
36  /**
37   * Factory for a simple {@link PPPMProcessor}.
38   * 
39   * @author Christina Bohk
40   * @author Roland Ewald
41   * 
42   */
43  public class PPPMProcessorFactory extends ProcessorFactory {
44  
45  	/** Serialization ID. */
46  	private static final long serialVersionUID = -7552093170636960651L;
47  
48  	@Override
49  	public IProcessor create(IModel model, IComputationTask computationTask,
50  	    Partition partition, ParameterBlock params) {
51  		if (!(model instanceof ProjectionModel)) {
52  			return null;
53  		}
54  		ParameterBlock pagfp = params.getSubBlock(ParamAssignmentGenFactory.class
55  		    .getName());
56  		ParamAssignmentGenFactory pagf = SimSystem.getRegistry().getFactory(
57  		    AbstractParamAssignmentGenFactory.class, pagfp);
58  		SimSystem.report(Level.INFO,
59  		    "Using parameter assignment generator:" + pagf.getClass());
60  		PPPMProcessor processor = new PPPMProcessor((ProjectionModel) model,
61  		    pagf.create(pagfp));
62  		processor.setComputationTask(computationTask);
63  		ProcessorInformation pi = new ProcessorInformation();
64  		pi.setLocal(processor);
65  		computationTask.setProcessorInfo(pi);
66  		return processor;
67  	}
68  
69  	/*
70  	 * (non-Javadoc)
71  	 * 
72  	 * @see james.core.processor.plugintype.ProcessorFactory#getEfficencyIndex()
73  	 */
74  	@Override
75  	public double getEfficencyIndex() {
76  		return 1;
77  	}
78  
79  	/*
80  	 * (non-Javadoc)
81  	 * 
82  	 * @see
83  	 * james.core.processor.plugintype.ProcessorFactory#getSupportedInterfaces()
84  	 */
85  	@Override
86  	public List<Class<?>> getSupportedInterfaces() {
87  		ArrayList<Class<?>> suppInterfaces = new ArrayList<Class<?>>();
88  		suppInterfaces.add(IProjectionModel.class);
89  		return suppInterfaces;
90  	}
91  
92  	/*
93  	 * (non-Javadoc)
94  	 * 
95  	 * @see
96  	 * james.core.processor.plugintype.ProcessorFactory#supportsSubPartitions()
97  	 */
98  	@Override
99  	public boolean supportsSubPartitions() {
100 		return false;
101 	}
102 
103 }