/*******************************************************************************
* Copyright (c)                                                                *
*           2005   Tristan Allwood,                                            *
*           2005   Daniel Burke,                                               *
*           2005   Marc Hull,                                                  *
*           2005   Ekaterina Itskova,                                          *
*           2005   Steve Zymler                                                *
*                                                                              *
* Permission is hereby granted, free of charge, to any person obtaining a      *
* copy of this software and associated documentation files (the                *
* "Software"), to deal in the Software without restriction, including          *
* without limitation the rights to use, copy, modify, merge, publish,          *
* distribute, sublicense, and/or sell copies of the Software, and to           *
* permit persons to whom the Software is furnished to do so, subject to        *
* the following conditions:                                                    *
*                                                                              *
* The above copyright notice and this permission notice shall be included      *
* in all copies or substantial portions of the Software.                       *
*                                                                              *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS      *
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF                   *
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.       *
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY         *
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,         *
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE            *
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                       *
*******************************************************************************/
/*
 * Created on 02-Nov-2004 by toa02
 *
 */
package uk.ac.ic.doc.kevlar.api.programs.framework.internal;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Set;

import uk.ac.ic.doc.kevlar.publicInterfaces.IInputPipe;
import uk.ac.ic.doc.kevlar.publicInterfaces.IOutputPipe;

/**
 * Holding class to manage all the data for a group of pipes for a program
 * 
 * @author toa02
 *  
 */
interface IPipeGroup {

    /**
     * Return the InputStream that drives the OutputPipes (twisted).
     * 
     * @return An ObjectInputStream that drives the OutputPipes
     */
    ObjectInputStream getInputStream();

    /**
     * Return the OutputStream that drives the InputPipes (twisted).
     * 
     * @return An ObjectInputStream that drives the InputPipes
     */
    ObjectOutputStream getOutputStream();

    /**
     * @return The set of all the InputPipe names that are known not to be
     *         closed. This is a non-live pointer
     */
    Set<String> getInputPipeNames();

    /**
     * @return The set of all the OutputPipe names that are known not to be
     *         closed. This is a non-live pointer
     */
    Set<String> getOutputPipeNames();

    /**
     * @param name
     *            The name of a pipe that is now known to be closed.
     */
    void registerClosedInput(String name);

    /**
     * @param name
     *            The name of a pipe that is now known to be closed.
     */
    void registerClosedOutput(String name);

    /**
     * @param name
     *            The name of an InputPipe
     * @return the IInputPipe instance for that pipe name or null if it is not
     *         known
     */
    IInputPipe getInputPipe(String name);

    /**
     * @param name
     *            The name of an OutputPipe
     * @return the IOutputPipe instance for that pipe name or null if it is not
     *         known
     *  
     */
    IOutputPipe getOutputPipe(String name);

    /**
     * @return The InputStream that debuginng information comes across from.
     *         This may be null if there is no debugging stream.
     */
    InputStream getDebugStream();
    
    /**
     * @param value The value to register on this pipe group
     */
    public void registerReciept( Long value );
    
    /**
     * @return The next reciept value for this group
     */
    public long getNextReciept();
    
    /**
     * @return True iff this group is missing reciepts
     */
    public boolean missingReciepts();
}
