// file: $ISIP_IFC/util/demo/isip_demo_selector/DemoArgParser.java
// version: $Id: DemoArgParser.java 10233 2005-09-13 14:46:42Z stanley $ 
//

// import necessary java libraries
//
// none

// import galaxy libraries
// 
import galaxy.util.ArgParser;

/**
 * The argument parser processes an array of arguments (key/values
 * pairs). This class gets the port numbers and ip addresses.
 */
public class DemoArgParser extends ArgParser {

    //-------------------------------------------------------------------------
    //
    // public constants
    //
    //-------------------------------------------------------------------------

    // Default values
    //
    /**
     * Default working mode.
     */
    public static final String DEFAULT_WORKING_MODE = "client";
    
    /**
     * Default process manager port number
     */
    public static final int DEFAULT_DEMO_MANAGER_PORT = 9000;

    /**
     * Default process manager IP address
     */
    public static final String DEFAULT_DEMO_MANAGER_IP_ADDRESS
	=  "130.18.14.185";
    
    /**
     * Default hub ip address when working mode is client.
     */
    public static final String DEFAULT_HUB_IP_ADDRESS =  "130.18.14.185";

    /**
     * This is the port that the client listens to when starting
     * a demo by default.
     */
    public static final int DEFAULT_CLIENT_PORT = 25010;

    // Parameter names
    //
    /**
     * Args for working mode (can take values "server or client").
     */
    public static final String WORKING_MODE_ARG = "-mode";
    
    /**
     * Args for working mode (can take values "server or client").
     */
    public static final String CLIENT_PORT_ARG = "-client_port";

    /**
     * Args for hub ip address when working mode is client.
     */
    public static final String HUB_IP_ADDRESS_ARG = "-hub_ip";

    /**
     * Args for hub port when working mode is client.
     */
    public static final String HUB_PORT_ARG = "-hub_port";

    /**
     * Default args for demo\process manager port number
     */
    public static final String DEMO_MANAGER_PORT_ARG
	= "-demo_manager_port";

    /**
     * Default args for demo\process manager ip address
     */
    public static final String DEMO_MANAGER_IP_ADDRESS_ARG
	= "-demo_manager_ip_address";
    
    //------------------------------------------------------------------------
    //
    // protected data
    //
    //-----------------------------------------------------------------------
    
    // none
    
    //-------------------------------------------------------------------------
    //
    // public methods
    //
    //-------------------------------------------------------------------------

    /**
     * Constructor, call the super class's constructor
     *
     * @param args_a arguments from the command line.
     */
    public DemoArgParser (String args_a[]) {
	super(args_a);
    }
    
    //-------------------------------------------------------------------------
    //
    // class-specific public methods:
    //  set methods
    //
    //-------------------------------------------------------------------------

    // none

    //-------------------------------------------------------------------------
    //
    // class-specific public methods:
    //  get methods
    //
    //-------------------------------------------------------------------------

    /**
     * Return an integer value according to the parameter
     *
     * @return the value of the argument or the default value if it
     * has no value.
     */
    public int getClientPort() {

        // return the integer value of the specified argument
        //
        return getIntegerArg(CLIENT_PORT_ARG,
                             DEFAULT_CLIENT_PORT);
    }

    /**
     * Return the string value of the specified argument.
     *
     * @return the value of the argument or the default value if it
     * has no value or the argument does not exist
     */
    public String getHubIPAddress() {

	// return the string value of the specified argument
	//
	return getStringArg(HUB_IP_ADDRESS_ARG,
			    DEFAULT_HUB_IP_ADDRESS);
    }

    /**
     * Return the string value of the specified argument.
     *
     * @return the value of the argument or the default value if it
     * has no value or the argument does not exist
     */
    public String getMode() {

	// return the string value of the specified argument
	//
	return getStringArg(WORKING_MODE_ARG,
			    DEFAULT_WORKING_MODE);
    }

    /**
     * Return the string value of the specified argument.
     *
     * @return the value of the argument or the default value if it
     * has no value or the argument does not exist
     */
    public String getDemoManagerIPAddress() {

	// return the string value of the specified argument
	//
	return getStringArg(DEMO_MANAGER_IP_ADDRESS_ARG,
			    DEFAULT_DEMO_MANAGER_IP_ADDRESS);
    }

    /**
     * Return the string value of the specified argument.
     *
     * @return the value of the argument or the default value if it
     * has no value or the argument does not exist
     */
    public int getDemoManagerPort() {

	// return the string value of the specified argument
	//
	return getIntegerArg(DEMO_MANAGER_PORT_ARG,
			    DEFAULT_DEMO_MANAGER_PORT);
    }

} // end of DemoArgParser






