/*
 * Created on 2004-11-20
 *
 * Part of the Symbian development plug-in for Eclipse
 * Copyright (C) Mikołaj Zalewski, 2004
 */
package pl.zalewski.mikolaj.symbdev.core.mmpmodel;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.widgets.Listener;

/**
 * A MMP file contains the build information for a specific output file.
 * This interface provides access to the information in the MMP file.
 *  
 * @author mikolaj
 */
public interface IMMPModel {
    public final int CHANGE_TARGET_NAME=1;
    public final int CHANGE_TARGET_PATH=2;
    public final int CHANGE_TARGET_TYPE=3;
    public final int CHANGE_UID2=4;
    public final int CHANGE_UID3=5;
    public final int CHANGE_LANG=6;
    public final int CHANGE_MACRO=7;
    public final int CHANGE_OPTION=8;
    public final int CHANGE_HEAPSIZE=9;
    public final int CHANGE_STACKSIZE=10;
    public final int CHANGE_PRIORITY=11;
    public final int CHANGE_NO_STRICT_DEF=12;
    public final int CHANGE_SRC_DBG=13;
    public final int CHANGE_STRICT_DEPEND=14;
    public final int CHANGE_LINK_AS=15;
    public final int CHANGE_LIBRARIES=16;
    public final int CHANGE_DEBUG_LIBRARIES=17;
    public final int CHANGE_USER_INCLUDES=18;
    public final int CHANGE_SYSTEM_INCLUDES=19;
    public final int CHANGE_RESOURCES=20;
    public final int CHANGE_SYSTEM_RESOURCES=21;
    public final int CHANGE_AIF=22;
    public final int CHANGE_SOURCE=23;
    public final int CHANGE_SOURCE_DIR=24;
    public final int CHANGE_MAX=24;
    
    /**
     * Legal priorities values
     */
    static final public String[] fPriorities=new String[]{
            "LOW",
            "BACKGROUND",
            "FOREGROUND",
            "HIGH",
            "WINDOWSERVER",
            "FILESERVER",
            "REALTIMESERVER",
            "SUPERVISOR"
    };
    
    public String getTargetFilename();
    public void setTargetFilename(String name) throws CoreException;
    
    public String getTargetPath();
    public void setTargetPath(String path) throws CoreException;
    
    public String getTargetType();
    public void setTargetType(String type) throws CoreException;
    
    public int getUID2();
    public int getUID3();
    public void setUID2(int uid) throws CoreException;
    public void setUID3(int uid) throws CoreException;
    
    public ILanguage[] getLanguages();
    public void addLanguages(String[] codes) throws CoreException;
    public void removeLanguage(int pos) throws CoreException;
    
    public String[] getMacros();
    public void addMacro(String macro) throws CoreException;
    public void setMacro(int pos, String newMacro) throws CoreException;
    public void removeMacro(int pos) throws CoreException;
    
    public ICompilerOptions[] getCompilerOptions();
    public void addCompilerOptions(String id, String options) throws CoreException;
    public void setCompilerOptions(int pos, String id, String options) throws CoreException;
    public void removeCompilerOptions(int pos) throws CoreException;
    
    /**
     * @return The minimum heap size set in the MMP file or 0 if default
     */
    public int getHeapMin();
    
    /**
     * Sets the minimum heap size
     * @param heapMin The new heap size or 0 if default. Note that if
     * heapMin!=0 but heapMax==0 the default heap size will be stored
     * int the MMP file 
     * @throws CoreException If something goes wrong
     */
    public void setHeapMin(int heapMin) throws CoreException;
    
    /**
     * @return The maxiumum heap size set in the MMP file or 0 if default
     */
    public int getHeapMax();
    
    /**
     * Sets the maximum heap size
     * @param heapMax The new heap size or 0 if default. Note that if
     * heapMax!=0 but heapMin==0 the default heap size will be stored
     * int the MMP file 
     * @throws CoreException If something goes wrong
     */
    public void setHeapMax(int heapMax) throws CoreException;
    
    
    /**
     * @return The stack size set in the MMP file or 0 if default
     */
    public int getStackSize();
    
    /**
     * Sets the new stack size in the MMP file
     * @param stackSize The new stack size or <code>0</code> if default
     * @throws CoreException If something goes wrong
     */
    public void setStackSize(int stackSize) throws CoreException;

    /**
     * @return The process priority. Should be one of fPriorities
     * however the class doesn't enforce it
     */
    public String getPriority();
    /**
     * 
     * @param priority The process priority. Should be one of fPriorities
     * however the class doesn't enforce it
     * @throws CoreException If something goes wrong
     */
    public void setPriority(String priority) throws CoreException;
    
    public boolean getNoStrictDef();
    public void setNoStrictDef(boolean noStrictDef) throws CoreException;
    
    public boolean getSrcDbg();
    public void setSrcDbg(boolean srcDbg) throws CoreException;
    
    public boolean getStrictDepend();
    public void setStrictDepend(boolean strictDepend) throws CoreException;
    
    /**
     * @return The LINKAS field or an empty string if not set (i.e.
     * the interanal link name is the same as the external)
     */
    public String getLinkAs();
    /**
     * Sets the LINKAS field
     * @param linkAs The new value. Use <code>null</code> or "" if you
     * want to set to default.
     * @throws CoreException If something goes wrong
     */
    public void setLinkAs(String linkAs) throws CoreException;
    
    public String[] getLibraries();
    /**
     * Adds a new library
     * @param name The name of the library
     * @throws CoreException If someting goes wrong. E.g. if this library already
     * exist, MMPModelException(ITEM_EXISTS) is thrown 
     */
    public void addLibrary(String name) throws CoreException;
    public void removeLibrary(int pos) throws CoreException;

    public String[] getDebugLibraries();
    /**
     * Adds a new debug library
     * @param name The name of the library
     * @throws CoreException If someting goes wrong. E.g. if this library already
     * exist, MMPModelException(ITEM_EXISTS) is thrown 
     */
    public void addDebugLibrary(String name) throws CoreException;
    public void removeDebugLibrary(int pos) throws CoreException;
    
    public String[] getSystemIncludes();
    public void addSystemInclude(String name) throws CoreException;
    public void removeSystemInclude(int pos) throws CoreException;
    public void setSystemInclude(int pos, String name) throws CoreException;

    public String[] getUserIncludes();
    public void addUserInclude(String name) throws CoreException;
    public void removeUserInclude(int pos) throws CoreException;
    public void setUserInclude(int pos, String name) throws CoreException;
    
    public MMPFileReference[] getResources();
    /**
     * Adds a resource file
     * @param file The path to the file. It must be absolute.
     * @throws CoreException It something goes wrong
     */
    public void addResource(IPath file) throws CoreException;
    public void removeResource(int pos) throws CoreException;
    /**
     * Sets the resource on position pos to a new file. The position
     * of the resource after addition might change.
     * @param pos The position of the resource reference to change
     * @param path The path to the file
     * @throws CoreException If anything goes wrong
     */
    public void setResource(int pos, IPath path) throws CoreException;

    public MMPFileReference[] getSystemResources();
    /**
     * Adds a system resource file (installed by default in
     * \system\data)
     * @param file The path to the file. It must be absolute.
     * @throws CoreException It something goes wrong
     */
    public void addSystemResource(IPath file) throws CoreException;
    public void removeSystemResource(int pos) throws CoreException;
    /**
     * Sets the system resource on position pos to a new file. The
     * position of the resource after addition might change.
     * @param pos The position of the resource reference to change
     * @param path The path to the file
     * @throws CoreException If anything goes wrong
     */
    public void setSystemResource(int pos, IPath path) throws CoreException;
    
    /**
     * @return The AIF Declaration model or <code>null</code> if no AIF
     * command in this MMP file
     */
    public IAIFDeclaration getAIFDeclaration();
    public void createAIFDeclaration(IPath resourceFile, String tagetname) throws CoreException;
    public void removeAIFDeclaration() throws CoreException;
    
    public MMPSourceFileReference[] getSourceFiles();
    public IPath[] getSourceDirs() throws CoreException;
    public IPath[] getAllSourceAutoDirs() throws CoreException;
    public void addSourceFile(IPath path) throws CoreException;
    /**
     * Adds a source directory. The files in this directory will
     * be added to the sources list (unless they are on the "don't
     * add" list)
     * @param path A filesystem, canonical path of the directory
     * @throws CoreException If something goes wrong
     */
    public void addSourceDir(IPath path) throws CoreException;
    public void removeSourceFile(IPath path, IPath rootPath) throws CoreException;
    public void removeSourceDir(IPath path) throws CoreException;
    public void removeSourceFile(int pos) throws CoreException;
    
    public void addChangeListener(int type, Listener listener);
    public void removeChangeListener(int type, Listener listener);
}
