package vermilion;

/**
 * This is a base class for all parameter types, such as switches, sliders, and
 * notes. The class can be extended to provide functionality to work as a
 * particular type.
 *
 * The class has 3 responsibilities:
 * 1 - Act as a parameter on a machine, ie hold the value of the parameter and
 * interpret events from the composer, expose a type, have a name etc.
 * 2 - Act as a command in a pattern, ie hold the value of the command and
 * interpret events from the tracker panel.
 * 3 - Act as a command in the document, ie serialise and deserialise.
 */
public abstract class ParameterBase extends UsefulFileObject
{
    /**
     * Defines the parameter type 'slider', a continuous value between 0 and 1.
     */
    public static final int PARAMETER_TYPE_SLIDER = 1;

    /**
     * Defines the parameter type 'switch', a discrete value of 0 or 1.
     */
    public static final int PARAMETER_TYPE_SWITCH = 2;

    /**
     * Defines the parameter type 'command', structure to be decided.
     */
    public static final int PARAMETER_TYPE_COMMAND = 3;

    /**
     * Defines the parameter type 'note', a pitch value with note, octave and
     * finetune.
     */
    public static final int PARAMETER_TYPE_NOTE = 4;

    /**
     * Defines the parameter type 'pattern', a pattern cueing parameter.
     */
    public static final int PARAMETER_TYPE_PATTERN = 99;

    /**
     * The name of the parameter as shown on screen.
     */
    public String parameterName;

    /**
     * The type of the parameter, a PARAMETER_TYPE_ constant.
     */
    public int parameterType;

    /**
     * Indicates that this parameter is part of the machine's 'tracks'. Later
     * a group number this parameter belongs to, for multi-tracktype machines.
     * The group number 0 will be reserved for ungrouped or 'global' parameters.
     */
    public boolean isTrackParam;

    /**
     * The base constructor accepts basic information about the parameter. This
     * is copied to local public vars for later access.
     */
    public ParameterBase(String name, int pType, boolean isTrack)
    {
        parameterName = name;
        parameterType = pType;
        isTrackParam = isTrack;
    }

    /**
     * Returns the name of the parameter, for displaying in lists or labels.
     */
    @Override
    public String toString()
    {
        return parameterName;
    }

    /**
     * Copies the value of a parameter, used to set machine parameter values.
     */
    public abstract void copyValue(ParameterBase source);
}
