/*
 * ConnectionXMLGenerator 
 *
 *
 * Copyright (c) 2003 Kansas State University, Laboratory for the Specification,
 * Analysis, and Transformation of Software
 *
 * This software is licensed under the SAnToS Laboratory Open Academic License.  You
 * should have received a copy of the license with the distribution.  A copy can be
 * found at:
 * http://www.cis.ksu.edu/santos/license.html
 * or you can contact the lab at:
 * SAnToS Laboratory
 * 234 Nichols Hall
 * Manhattan, KS 66506, USA
 */
package edu.ksu.cis.cadena.xmlgen;

import edu.ksu.cis.cadena.frontend.cad.parser.*;

import org.eclipse.core.runtime.IPath;


/**
 * This class starts to generate connection.xml and Scenario.java
 * @author Sue Li
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class ConnectionXMLGenerator {
    Scenario scenario;
    String directory;
    String projectName;

    /**
	 * @param sc the scenario
	 * @param outputPath the path of output file 
	 * @param projectName the name of project
	 */
	public ConnectionXMLGenerator(Scenario sc, String outputPath,
        String projectName) {
        scenario = sc;
        directory = outputPath;
        this.projectName = projectName;
    }

    public void start() {
        if (scenario == null) {
            System.out.println("scenario is null");
            System.exit(0);
        }

        ConnectionSpecXMLGenerator connection =
            new ConnectionSpecXMLGenerator(directory + IPath.SEPARATOR);
        scenario.apply(connection, "");

        Visitor visitor =
            new Visitor(directory + IPath.SEPARATOR, projectName,
                connection.getInstancePortsMap());
        scenario.apply(visitor, "");
    }
}


syntax highlighted by Code2HTML, v. 0.9.1