1 package net.sf.openrocket.masscalc;
3 import net.sf.openrocket.rocketcomponent.Configuration;
6 * Abstract base for mass calculators. Provides functionality for cacheing mass data.
8 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
10 public abstract class AbstractMassCalculator implements MassCalculator {
12 private int rocketMassModID = -1;
13 private int stageCount = -1;
17 * Check the current cache consistency. This method must be called by all
18 * methods that may use any cached data before any other operations are
19 * performed. If the rocket has changed since the previous call to
20 * <code>checkCache()</code>, then {@link #voidMassCache()} is called.
22 * This method performs the checking based on the rocket's modification IDs,
23 * so that these method may be called from listeners of the rocket itself.
25 * @param configuration the configuration of the current call
27 protected final void checkCache(Configuration configuration) {
28 if (rocketMassModID != configuration.getRocket().getMassModID() ||
29 stageCount != configuration.getStageCount()) {
30 rocketMassModID = configuration.getRocket().getMassModID();
31 stageCount = configuration.getStageCount();
39 * Void cached mass data. This method is called whenever a change occurs in
40 * the rocket structure that affects the mass of the rocket and when a new
41 * Rocket is used. This method must be overridden to void any cached data
42 * necessary. The method must call <code>super.voidMassCache()</code> during
45 protected void voidMassCache() {