/*
 * Created on Apr 3, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package edu.clemson.aadl.modifiability;

import edu.cmu.sei.aadl.model.component.DataType;
import edu.cmu.sei.aadl.model.component.SystemType;
import edu.cmu.sei.aadl.model.component.util.ComponentSwitch;
import edu.cmu.sei.aadl.model.core.Feature;
import edu.cmu.sei.aadl.model.feature.PortGroupType;
import edu.cmu.sei.aadl.model.feature.util.FeatureSwitch;
import edu.cmu.sei.aadl.model.util.AadlProcessingSwitch;

/**
 * @author ken
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class ModelAnalysis extends AadlProcessingSwitch
{
    int featureCount = 0;
    int systemCount = 0;
    
    int componentTypeCount = 0;
   
    public float getAverage(){
        if(systemCount == 0 ) return -1;
        else return ((float) featureCount / (float) systemCount);
    }
    
    public float getModifiabiltyMeasure(){
        return (float) (1 / getAverage());
    }
    
    protected void initSwitches()
    {
    
        componentSwitch = new ComponentSwitch()
        {
            public Object caseSystemType(SystemType obj)
            {
                systemCount++;
                featureSwitch = new FeatureSwitch()
                {
                    public Object caseFeature(Feature obj)
                    {
                        featureCount++;

                        if (!(obj instanceof DataType || obj instanceof PortGroupType))
                            componentTypeCount++;
                        return DONE;

                    }//End caseComponentType()
                    
                	};

                //if (!(obj instanceof DataType || obj instanceof PortGroupType))
                //    componentTypeCount++;
                return DONE;

            }//End caseComponentType()
        };
        
    }//End initSwitches()

}//End class definition
