/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM; if not, write to the Free Software Foundation,
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Class
    FoamX

Description
    IDL definitions for FoamX pre-processor.

SourceFiles
    FoamX.H
    FoamX.C

\*---------------------------------------------------------------------------*/

#ifndef FoamX_IDL
#define FoamX_IDL

module FoamXServer
{
    // Forward declare all interfaces in this module.
    interface ITypeDescriptor;
    interface IDictionaryEntry;

    // -------------------------------------------------------------------------
    // - Enums -----------------------------------------------------------------
    // -------------------------------------------------------------------------

    enum FoamXType
    {
        Type_Undefined,
        Type_Boolean,
        Type_Label,
        Type_Scalar,
        Type_Char,
        Type_Word,
        Type_String,
        Type_RootDir,       // Any directory in caseRoots
        Type_RootAndCase,   // Path to valid case
        Type_CaseName,      // Valid case directory
        Type_HostName,      // Valid license host
        Type_File,          // Generic file (not directory)
        Type_Directory,     // Generic directory
        Type_Time,          // Time (as string)
        Type_DimensionSet,
        Type_FixedList,
        Type_List,
        Type_Dictionary,
        Type_Selection,
        Type_Compound,
        Type_Field          // Special type for late-bound field types.
    };

    enum ErrorCode
    {
        S_OK,
        E_FAIL,
        E_FOAM,
        E_INVALID_ARG,
        E_INVALID_PTR,
        E_INVALID_REF,
        E_INDEX_OUT_OF_BOUNDS,
        E_UNKNOWN_NAME,
        E_UNEXPECTED
    };

    enum JobStatus
    {
        JOB_UNDEFINED,
        JOB_LAUNCHING,
        JOB_RUNNING,
        JOB_STOPPING,
        JOB_SUSPENDED,
        JOB_FINISHED,
        JOB_ABORTED
    };

    enum MessageType
    {
        M_DIAGNOSTIC,    // Diagnostic and informational messages.
        M_WARNING,       // Warning messages.
        M_ERROR          // Error messages.
    };


    // -------------------------------------------------------------------------
    // - General Typedefs-------------------------------------------------------
    // -------------------------------------------------------------------------

    typedef sequence<string> StringList;
    typedef sequence<ITypeDescriptor> TypeDescriptorList;
    typedef sequence<IDictionaryEntry> DictionaryEntryList;
    typedef sequence<double> DoubleList;
    typedef sequence<float> FloatList;
    typedef sequence<long> LongList;
    typedef float Point3[3];


    // -------------------------------------------------------------------------
    // - Structs----------------------------------------------------------------
    // -------------------------------------------------------------------------

    struct FoamXAny
    {
        FoamXType type;
        any value;
    };
    typedef sequence<FoamXAny> FoamXAnyList;

    struct StringPair
    {
        string name;
        string value;
    };
    typedef sequence<StringPair> StringPairList;

    // Host descriptor structure.
    struct HostDescriptor
    {
        string  name;
        boolean alive;
    };
    typedef sequence<HostDescriptor> HostDescriptorList;

    // Application descriptor structure.
    struct ApplicationDescriptor
    {
        string  name;
        string  category;
        string  path;
        boolean systemClass;         // System defined application class.
    };
    typedef sequence<ApplicationDescriptor> ApplicationDescriptorList;

    // Case descriptor structure.
    struct CaseDescriptor
    {
        string rootDir;     // rootDir (after expansion)
        string rawRootDir;  // rootDir (before expansion)
        string caseName;
        string app;
        long nProcs;        // 1 or number of subdomains in parallel
        boolean managed;    // True if this is a FoamX managed case.
        boolean locked;     // True if this case is locked by another user.
        boolean error;      // True if this case is in error.
    };
    typedef sequence<CaseDescriptor> CaseDescriptorList;

    // Job ID.
    struct JobID
    {
        string hostName;    // Host name.
        long   processID;   // Process ID.
    };
    typedef sequence<JobID> JobIDList;

    // Job descriptor structure.
    struct JobDescriptor
    {
        JobID  jobID;           // Job ID.
        long   ppid;            // Parent pid.
        long   pgid;            // Group pid.
        string startDate;       // Start date.
        string startTime;       // Start time.
        string userName;        // Username.
        string foamVersion;     // Software version.
        string code;            // Code.
        string argList;         // Argument list.
        string currentDir;      // Current working directory.
        string rootDir;         // Case root.
        string caseName;        // Case name.
        long   nProcs;          // Number of processes.
        JobIDList slaves;       // slave JobIDs
        long   nCountedProcs;   // Number of licences taken up.
        double cpuTime;         // Used cpuTime.
        string endDate;         // End date.
        string endTime;         // End time.
        JobStatus status;       // Job status.
    };
    typedef sequence<JobDescriptor> JobDescriptorList;

    struct DimensionSet
    {
        double mass;                // Kilogramme Kg.
        double length;              // meter      m.
        double time;                // second     s.
        double temperature;         // Kelvin     K.
        double moles;               // mole       mol.
        double current;             // Ampere     Amp.
        double luminousIntensity;   // Candela    Cd.
    };
    typedef sequence<DimensionSet> DimensionSetList;


    // -------------------------------------------------------------------------
    // - Exceptions-------------------------------------------------------------
    // -------------------------------------------------------------------------

    // Standard exception
    exception FoamXError
    {
        ErrorCode errorCode;
        string errorMessage;

        string methodName;
        string fileName;
        long lineNo;
    };

    // Invalid remote system invocation (e.g. machine can't be reached)
    exception FoamXSYSError
    {
        ErrorCode errorCode;
        string errorMessage;
        string hostName;

        string methodName;
        string fileName;
        long lineNo;
    };

    // Invalid dictionary
    exception ValidationError
    {
        ErrorCode errorCode;
        string errorMessage;
        string itemPath;
    };

    // Exception from error on file
    exception FoamXIOError
    {
        string errorMessage;
        string ioFileName;
        long ioStartLineNo;
        long ioEndLineNo;

        string methodName;
        string fileName;
        long lineNo;
    };


    // -------------------------------------------------------------------------
    // - Interfaces ------------------------------------------------------------
    // -------------------------------------------------------------------------

    interface ITypeDescriptor
    {
        // Properties common to all types.
    
        //- The type of this parameter.
        attribute FoamXType type;
    
        //- Primitive type flag.
        readonly attribute boolean isPrimitiveType;

        //- Compound type flag.
        readonly attribute boolean isCompoundType;
    
        //- Path of this parameter relative to root dictionary.
        attribute string path;
    
        //- Foam parameter name.
        attribute string name;
    
        //- Short display name.
        attribute string displayName;
    
        //- Long descriptive name.
        attribute string description;
    
        //- Dictionary comment.
        attribute string comment;
    
        //- GUI category.
        attribute string category;
    
        //- URL to relevant help file.
        attribute string helpURL;
    
        //- URL to a nice icon for this entry.
        attribute string iconURL;
    
        //- Flag indicating whether this parameter is optional.
        //  Defaults to false.
        attribute boolean optional;
    
        //- Flag indicating whether this parameter is visible within FoamX.
        //  Defaults to true.
        attribute boolean visible;
    
        // Properties for non-compound types.
    
        //- Flag indicating whether this parameter is editable within FoamX.
        //  Defaults to true.
        attribute boolean editable;
    
        //- Minimum value for this parameter.
        attribute FoamXAny minValue;
    
        //- Maximum value for this parameter.
        attribute FoamXAny maxValue;
    
        //- Name of dictionary to use as a lookup table.
        attribute string lookupDict;
    
        //- List of permissible values for this parameter.
        attribute FoamXAnyList valueList;
    
        // Properties for compound types.
    
        //- Top-level dictionary location relative to case root.
        attribute string dictionaryPath;
    
        //- Number of vector space elements.
        attribute long numElements;
    
        //- Labels of vector space elements (eg, x, y, z).
        attribute StringList elementLabels;

        //- List of sub-types for compound types.
        readonly attribute TypeDescriptorList subTypes;

        //- Element type in List of elements.
        readonly attribute ITypeDescriptor elementType;


        boolean hasDefaultValue();

        void getDefaultValue
        (
            out IDictionaryEntry defaultValue
        ) raises(FoamXError, FoamXIOError);

        //- Compound sub-type methods.
        void addSubType
        (
            in FoamXType type,
            out ITypeDescriptor subEntry
        ) raises(FoamXError, FoamXIOError);
    
        void removeSubType(in ITypeDescriptor subEntry)
            raises(FoamXError, FoamXIOError);
    
        //- Validation.
        //  Checks that this type and all sub-types are valid.
        //  Returns the path to the offending type if any invalid entries
        //  are found.
        void validate()      
            raises(FoamXError, FoamXIOError, ValidationError);
    };
    
    // -------------------------------------------------------------------------

    interface IDictionaryEntry
    {
        // ---- Common attributes --------------------------------------
        // Reference to the type descriptor object for this entry.
        readonly attribute ITypeDescriptor typeDescriptor;
    
        // ---- Non-compound attributes --------------------------------
        // Current value for this (non compound) entry.
        attribute FoamXAny value;

        void setValue(in FoamXAny value)
           raises(FoamXError);

        // ---- Compound attributes ------------------------------------
        // Sub-elements for compound types.
        readonly attribute DictionaryEntryList subElements;
        long nSubElements() raises(FoamXError);
        boolean packedList() raises(FoamXError);

        // ---- Selection attributes -----------------------------------
        // The current selection index
        attribute long selection;
    
        // Add a new element to the list and return the new dictionary
        // entry object.
        void addElement(out IDictionaryEntry subEntry)
            raises(FoamXError);
    
        // Remove element from list.
        void removeElement(in IDictionaryEntry subEntry)
            raises(FoamXError);
    
        // ---- Recursive state methods --------------------------------
        // Returns true if this entry, and all sub-entries are valid.
        // Returns the path to the offending entry if any invalid entries
        // are found.
        void validate()
            raises(FoamXError, ValidationError);
    
        // Returns true if this entry, or any sub-entries have been modified.
        boolean modified()
            raises(FoamXError);

        // ---- Persistence methods ------------------------------------
        // Save method for root (dictionary) objects.
        void save()
            raises(FoamXError, FoamXIOError);
    };


    // -------------------------------------------------------------------------
    // - FoamX CaseServer Module -----------------------------------------------
    // -------------------------------------------------------------------------

    module CaseServer
    {
        // Forward declare all interfaces in this module.
        interface ICaseServer;
        interface IFoamProperties;
        interface IApplication;
        interface IGeometricFieldDescriptor;
        interface IPatchDescriptor;
        interface IGeometryDescriptor;
        interface IPatchPhysicalTypeDescriptor;
        interface IGeometricField;


        // ---------------------------------------------------------------------
        // - Interfaces --------------------------------------------------------
        // ---------------------------------------------------------------------

        interface ICaseServer
        {
            // Attributes.
            attribute boolean managed;
            readonly attribute string caseRoot;
            readonly attribute string caseName;

            // Application class for this case (read only).
            readonly attribute IApplication application;

            // Foam system properties (read only).
            readonly attribute IFoamProperties foamProperties;

            // Time-steps.
            readonly attribute StringList availableTimeSteps;

            // Get current time
            string getTime()
                raises(FoamXError, FoamXIOError);

            // Set time
            void setTime(in string timeName, in long timeIndex)
                raises(FoamXError, FoamXIOError);

            // Mesh.
            readonly attribute boolean meshDefined;

            void readMesh()
                raises(FoamXError, FoamXIOError);

            void importMesh
            (
                in string hostName,
                in string rootDir,
                in string caseName
            ) raises(FoamXError, FoamXIOError);

            // Field values.
            void getFieldValues
            (
                in string fieldName,
                out IGeometricField fieldValues
            ) raises(FoamXError, FoamXIOError);

            // Patches.
            readonly attribute StringList patchNames;

            void addPatch(in string patchName, in string patchPhysicalType)
                raises(FoamXError, FoamXIOError);

            void deletePatch(in string patchName)
                raises(FoamXError, FoamXIOError);

            void deleteAllPatches() raises(FoamXError, FoamXIOError);

            // Patch physical type
            void setPatchPhysicalType
            (
                in string patchName,
                in string patchPhysicalType
            ) raises(FoamXError, FoamXIOError);

            void getPatchPhysicalType
            (
                in string patchName,
                out string patchPhysicalType
            ) raises(FoamXError, FoamXIOError);

            // Dictionaries.
            void getDictionary
            (
                in string dictionaryName,
                in boolean forceRead,           // Do not use cache
                out IDictionaryEntry dictRoot
            ) raises(FoamXError, FoamXIOError);

            void readFile
            (
                in string name,
                out string contents
            ) raises(FoamXError, FoamXIOError);

            void writeFile
            (
                in string name,
                in string contents
            ) raises(FoamXError, FoamXIOError);

            // Get modification date
            long fileModificationDate
            (
                in string fileName
            ) raises(FoamXIOError);

            //- Calculation control.
            long runCase(in string arguments) raises(FoamXError, FoamXIOError);
            void killCase() raises(FoamXError);

            //- Validation.
            void validate() raises(FoamXError, FoamXIOError, ValidationError);

            // Returns true if this has been modified
            boolean modified();

            //- Persistence.
            void save() raises(FoamXError, FoamXIOError, ValidationError);

            //- Lifetime management.
            oneway void close();
        };

        // ---------------------------------------------------------------------

        interface IFoamProperties
        {
            //- Attributes.
            readonly attribute StringList availableModules; // Defined modules.

            //- Root directories to search for cases.

                readonly attribute StringList rootDirectories;

                //- Unexpanded form of rootDirectories.
                readonly attribute StringList rawRootDirectories;

                void addRootDirectory(in string rawRootDir)
                    raises(FoamXError, FoamXIOError);

                void deleteRootDirectory(in string rawRootDir)
                   raises(FoamXError, FoamXIOError);


            // Foam types.

                readonly attribute StringList foamTypes;

                void getFoamType
                (
                    in string foamTypeName,
                    out ITypeDescriptor typeDesc
                ) raises(FoamXError, FoamXIOError);


            // Geometry types.

                readonly attribute StringList geometryTypes;

                void getGeometryType
                (
                   in string geometryTypeName,
                    out IGeometryDescriptor geometryDesc
                ) raises(FoamXError, FoamXIOError);


            // Patch types.

                readonly attribute StringList patchTypes;

                void getPatchType
                (
                    in string patchTypeName,
                    out IPatchDescriptor patchDesc
                ) raises(FoamXError, FoamXIOError);

                void findPatchType
                (
                    in string patchTypeName,
                    out IPatchDescriptor patchDesc
                ) raises(FoamXError, FoamXIOError);
 

            // Patch field types.

                readonly attribute StringList patchFieldTypes;

                void getPatchFieldType
                (
                    in string patchFieldTypeName,
                    out ITypeDescriptor patchFieldDesc
                ) raises(FoamXError, FoamXIOError);

                void findPatchFieldType
                (
                    in string patchFieldTypeName,
                    out ITypeDescriptor patchFieldDesc
                ) raises(FoamXError, FoamXIOError);


            // FOAM controlDict

                void getFoamControlDict
                (
                    out IDictionaryEntry controlDict
                ) raises(FoamXError, FoamXIOError);


            // Application classes.

                readonly attribute ApplicationDescriptorList
                    applicationes;

                void getApplication
                (
                    in string appName,
                    out IApplication app
                ) raises(FoamXError, FoamXIOError);

                void addApplication
                (
                    in string appName,
                    out IApplication app
                ) raises(FoamXError, FoamXIOError);

                void deleteApplication(in string appName) 
                    raises(FoamXError, FoamXIOError);

                void cloneApplication
                (
                    in string appNameSrc,
                    in string appNameDest,
                    in string appDestPath,
                    out IApplication app
                ) raises(FoamXError, FoamXIOError);


            // Foam utilities.

                readonly attribute ApplicationDescriptorList utilities;

                void getUtilityControlDict
                (
                    in string utilityName,
                    in string rootDir,
                    in string caseName,
                    out IDictionaryEntry controlDict
                ) raises(FoamXError, FoamXIOError);


            //- Validation.
            void validate()
                raises(FoamXError, FoamXIOError, ValidationError);

            //- Persistence.
            void saveSystemProperties()
                raises(FoamXError, FoamXIOError, ValidationError);

            void saveUserProperties()
                raises(FoamXError, FoamXIOError, ValidationError);
        };

        // ---------------------------------------------------------------------

        interface IApplication
        {
            //- Short name for this application class.
            attribute string name;

            //- Application class description.
            attribute string description;

            //- Application class category.
            attribute string category;

            //- List of modules required to pre-process this application class.
            attribute StringList modules;

            //- System or user defined application class.
            readonly attribute boolean systemClass;

            // Fields.

            //- List of defined fields.
            readonly attribute StringList fields;
            void getField
            (
                in string fieldName,
                out IGeometricFieldDescriptor fieldDescriptor
            ) raises(FoamXError, FoamXIOError);

            void findField
            (
                in string fieldName,
                out IGeometricFieldDescriptor fieldDescriptor
            ) raises(FoamXError, FoamXIOError);

            void addField
            (
                in string fieldName,
                out IGeometricFieldDescriptor fieldDescriptor
            ) raises(FoamXError, FoamXIOError);

            void deleteField(in string fieldName)
                raises(FoamXError, FoamXIOError);

            // Patch physical types.
            readonly attribute StringList patchPhysicalTypes;

            // List of defined patch physical types.
            void getPatchPhysicalType
            (
                in string patchPhysicalTypeName,
                out IPatchPhysicalTypeDescriptor patchPhysicalTypeDescriptor
            ) raises(FoamXError, FoamXIOError);

            void findPatchPhysicalType
            (
                in string patchPhysicalTypeName,
                out IPatchPhysicalTypeDescriptor patchPhysicalTypeDescriptor
            ) raises(FoamXError, FoamXIOError);

            void addPatchPhysicalType
            (
                in string patchPhysicalTypeName,
                out IPatchPhysicalTypeDescriptor patchPhysicalTypeDescriptor
            ) raises(FoamXError, FoamXIOError);

            void deletePatchPhysicalType(in string patchPhysicalTypeName)
                raises(FoamXError, FoamXIOError);

            // Dictionaries.
            readonly attribute StringList dictionaries; 

            // List of defined dictionaries.
            void getDictionary
            (
                in string dictName,
                out ITypeDescriptor dictTypeDescriptor
            ) raises(FoamXError, FoamXIOError);
            
            void addDictionary
            (
                in string dictName,
                out ITypeDescriptor dictTypeDescriptor
            ) raises(FoamXError, FoamXIOError);

            void deleteDictionary(in string dictName)
                raises(FoamXError, FoamXIOError);

            // Validation.
            void validate()
                raises(FoamXError, FoamXIOError, ValidationError);

            // Persistence.
            void save()
                raises(FoamXError, FoamXIOError, ValidationError);
        };

        // ---------------------------------------------------------------------

        interface IPatchDescriptor
        {
            //- Name of patch type (eg, "wall").
            attribute string name;

            //- Display name (eg, "Wall").
            attribute string displayName;

            //- Description (eg, "Solid Wall").
            attribute string description;
        };

        // ---------------------------------------------------------------------

        interface IGeometryDescriptor
        {
            //- Name of geometry type (eg, "volume").
            attribute string name;

            //- Display name (eg, "Volume").
            attribute string displayName;

            //- Description (eg, "Finite Volume Geometry").
            attribute string description;
        };

        // ---------------------------------------------------------------------

        interface IGeometricFieldDescriptor
        {
            readonly attribute ITypeDescriptor typeDescriptor;
            readonly attribute ITypeDescriptor fieldTypeDescriptor;
            readonly attribute IGeometryDescriptor geometryDescriptor;

            //- Field name (eg, "p").
            attribute string name;

            //- Field description (eg, "Pressure").
            attribute string description;

            //- Field type name (eg, "scalar").
            attribute string fieldTypeName;

            //- Geometry type name (eg, "vol").
            attribute string geometryTypeName;

            //- Field dimensions.
            attribute DimensionSet dimensions;
        };

        // ---------------------------------------------------------------------

        interface IPatchPhysicalTypeDescriptor
        {
            //- Patch physical type name (eg, "inlet").
            attribute string name;

            attribute string displayName;
            attribute string description;
            attribute string patchType;
            attribute string parentType;
            attribute StringPairList patchFieldTypes;
        };

        // ---------------------------------------------------------------------

        interface IGeometricField
        {
            readonly attribute string name;

            void getInternalFieldValue
            (
                out IDictionaryEntry internalFieldValue
            ) raises(FoamXError, FoamXIOError);

            void getPatchFieldParameters
            (
                in string patchName,
                out IDictionaryEntry patchFieldValue
            ) raises(FoamXError, FoamXIOError);

            // Returns true if this has been modified
            boolean modified();
        };
    };


    // -------------------------------------------------------------------------
    // - FoamX CasePostServer Module -----------------------------------------------
    // -------------------------------------------------------------------------

    module CasePostServer
    {
        // Forward declare all interfaces in this module.
        interface ICasePostServer;


        // ---------------------------------------------------------------------
        // - Interfaces --------------------------------------------------------
        // ---------------------------------------------------------------------

        interface ICasePostServer
        {
            // Attributes.
            readonly attribute string caseRoot;
            readonly attribute string caseName;
            readonly attribute long nProcs;

            //
            // Database
            //

            // Time-steps.
            readonly attribute StringList availableTimeSteps;

            // Set database
            void setTime(in string timeName, in long timeIndex)
                raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void setTimeSlave();

            // Get patchnames over all domains
            StringList getPatchNames()
                raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void getPatchNamesSlave();

            // Get fieldNames
            StringList getFieldNames(in string type)
                raises(FoamXError, FoamXIOError);


            //
            // Mesh
            //

            // Bounding box
            void getMeshBb(out Point3 min, out Point3 max)
                raises(FoamXError);
            // Slave variant
            oneway void getMeshBbSlave();

            // Patch mesh
            void getPatchMesh
            (
                in string patchName,
                in double creaseAngle,
                out FloatList points,
                out LongList edges                
            ) raises(FoamXError);
            // Slave variant
            oneway void getPatchMeshSlave();

            // Cut mesh
            void getCutMesh
            (
                in Point3 basePoint,
                in Point3 normal,
                out FloatList points,
                out LongList edges                
            ) raises(FoamXError);
            // Slave variant
            oneway void getCutMeshSlave();

            // Cut mesh outline
            void getCutMeshOutline
            (
                in Point3 basePoint,
                in Point3 normal,
                out FloatList points,
                out LongList edges                
            ) raises(FoamXError);
            // Slave variant
            oneway void getCutMeshOutlineSlave();


            //
            // Cut , sample
            //


            //
            // OLD
            //

            // Triangulate and sample patch
            void getTriPatch
            (
                in string fieldName,
                in string patchName,
                out FloatList points,
                out LongList triFaces,
                out FloatList values
            ) raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void getTriPatchSlave();

            // Triangulate and sample patch
            void getTriPatchVec
            (
                in string fieldName,
                in string patchName,
                out FloatList points,
                out LongList triFaces,
                out FloatList values
            ) raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void getTriPatchVecSlave();

            // Cutplane and sample
            void cutPlane
            (
                in string fieldName,
                in Point3 basePoint,
                in Point3 normal,
                out FloatList points,
                out LongList triFaces,
                out FloatList values
            ) raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void cutPlaneSlave();

            // Cutplane and sample
            void cutPlaneVec
            (
                in string fieldName,
                in Point3 basePoint,
                in Point3 normal,
                out FloatList points,
                out LongList triFaces,
                out FloatList values
            ) raises(FoamXError, FoamXIOError);
            // Slave variant
            oneway void cutPlaneVecSlave();

            //- Lifetime management.
            oneway void close();
        };
    };

    // -------------------------------------------------------------------------
    // - FoamX CaseBrowser Module ----------------------------------------------
    // -------------------------------------------------------------------------

    module CaseBrowser
    {
        // Forward declare all interfaces in this module.
        interface ICaseBrowser;

        // ---------------------------------------------------------------------
        // - Interfaces---------------------------------------------------------
        // ---------------------------------------------------------------------

        interface ICaseBrowser
        {
            // Foam system properties (user data editable).
            readonly attribute CaseServer::IFoamProperties
                foamProperties;

            // Managed cases list.
            readonly attribute CaseDescriptorList cases;

            // Running jobs list.
            readonly attribute JobDescriptorList runningJobs;

            // Finished jobs list.
            readonly attribute JobDescriptorList finishedJobs;

            // Get environment variable
            void getEnv
            (
                in string envName,
                out string hostName
            ) raises(FoamXError);

            // Get the machines hostName
            void getHostName
            (
                out string hostName
            ) raises(FoamXError);

            // Get userName
            void getUserName
            (
                out string userName
            ) raises(FoamXError);

            // Get modification date
            long fileModificationDate
            (
                in string fileName
            ) raises(FoamXIOError);

            // Read file and store contents in string
            void readFile(in string fileName, out string contents)
                raises(FoamXError, FoamXIOError);

            // Write contents of string as a file
            void writeFile(in string fileName, in string contents)
                raises(FoamXError, FoamXIOError);

            // Utility execution.
            long invokeUtility
            (
                in string hostName,
                in string utilityName,
                in StringList arguments,
                in string logName,
                in boolean backGround
            ) raises(FoamXError);

            void refreshCaseList()
                raises(FoamXError, FoamXIOError);

            void addToCaseList(in string rootDir)
                raises(FoamXError, FoamXIOError);

            // Case manipulation.
            void openCase(in CaseDescriptor caseDesc)
                raises(FoamXError, FoamXIOError);

            void newCase
            (
                in string rootDir,
                in string caseName,
                in string app
            ) raises(FoamXError, FoamXIOError);

            void importCase
            (
                in string rootDir,
                in string caseName,
                in string app
            ) raises(FoamXError, FoamXIOError);

            void deleteCase(in CaseDescriptor caseDesc)
                raises(FoamXError, FoamXIOError);

            void cloneCase
            (
                in CaseDescriptor caseDesc,
                in string newCaseRootDir,
                in string newCaseName,
                in string newAppClassName,
                in string timeSel
            ) raises(FoamXError, FoamXIOError);

            // Try to resolve NameServer entry for caseServer
            boolean getCaseServerReference
            (
                in string rootDir,
                in string caseName,
                out CaseServer::ICaseServer caseObj
            ) raises(FoamXError, FoamXSYSError);

            // start casePostServer
            void openCasePost(in CaseDescriptor caseDesc, in long nProcs)
                raises(FoamXError, FoamXIOError);

            // Try to resolve NameServer entry for casePostServer
            boolean getCasePostServerReference
            (
                in string rootDir,
                in string caseName,
                in long nProcs,
                out CasePostServer::ICasePostServer caseObj
            ) raises(FoamXError, FoamXSYSError);

            boolean caseLocked(in CaseDescriptor caseDesc)
                raises(FoamXError);

            void unlockCase
            (
                in string rootDir,
                in string caseName
            ) raises(FoamXError, FoamXIOError);

            void unlockCaseDescriptor(in CaseDescriptor caseDesc)
                raises(FoamXError, FoamXIOError);

            void addCase
            (
                in string rootDir,
                in string rawRootDir,
                in string caseName,
                in string app
            ) raises(FoamXError);

            void caseOpen
            (
                in string rootDir,
                in string caseName
            ) raises(FoamXError);

            boolean isCaseInError(in CaseDescriptor caseDesc)
                raises(FoamXError);

            void caseIsInError(in CaseDescriptor caseDesc)
                raises(FoamXError);



        // Process control

            void refreshJobsLists()
                raises(FoamXError, FoamXIOError);

            void checkRunningJobs()
                raises(FoamXError, FoamXSYSError);

            void purgeRunningJobs()
                raises(FoamXError, FoamXIOError);

            void purgeFinishedJob(in JobID jobID)
                raises(FoamXError, FoamXIOError);

            void purgeFinishedJobs(in long nDays)
                raises(FoamXError, FoamXIOError);

            // Kill process.
            void kill(in JobID jobID)
                raises(FoamXError, FoamXSYSError);

            // Suspend process
            void suspend(in JobID jobID)
                raises(FoamXError, FoamXSYSError);

            // Continue process
            void cont(in JobID jobID)
                raises(FoamXError, FoamXSYSError);

            // Nicely end process (with dump) in 
            //      now=true:  iteration after next
            //      now=false: next natural dump
            void end
            (
                in JobID jobID,
                in string rootDir,
                in string caseName,
                in boolean now
            )   raises(FoamXError, FoamXSYSError);

            // Reset the job status
            void setStatus(in JobID jobID, in JobStatus jobStatus)
                raises(FoamXError);


       // IO

            // Validation.
            void validate()
                raises(FoamXError, ValidationError);

            // Persistence.
            void save() 
                raises(FoamXError, FoamXIOError, ValidationError);

            // Lifetime management.
            oneway void close();
        };
    };


    // -------------------------------------------------------------------------
    // - FoamX Host Browser Module ---------------------------------------------
    // -------------------------------------------------------------------------

    module HostBrowser
    {
        // Forward declare all interfaces in this module.
        interface IHostBrowser;

        // ---------------------------------------------------------------------
        // - Interfaces---------------------------------------------------------
        // ---------------------------------------------------------------------

        interface IHostBrowser
        {
            readonly attribute HostDescriptorList hosts;

            void refreshHostList()
                raises(FoamXError);

            boolean isHostAlive(in string hostName)
                raises(FoamXError);

            void hostIsAlive(in string hostName)
                raises(FoamXError);

            void hostIsDead(in string hostName)
                raises(FoamXError);

            void openCaseBrowser
            (
                in string hostName
            ) raises(FoamXError, FoamXSYSError);

            boolean getCaseBrowserReference
            (
                in string hostName,
                out CaseBrowser::ICaseBrowser browserObj
            ) raises(FoamXError, FoamXSYSError);
            

            // Validation.
            void validate()
                raises(FoamXError, FoamXIOError, ValidationError);

            // Persistence.
            void save()
                raises(FoamXError, FoamXIOError, ValidationError);

            // Lifetime management.
            oneway void close();
        };
    };
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
