/**
 *  Component manager interface for handling ports and component creation
 *  
 *  @author     ETSI / STF424
 *  @version    $URL$
 *              $Id$
 *
 */

package org.etsi.its.adapter;

import org.etsi.its.adapter.ports.IPort;
import org.etsi.ttcn.tri.TriComponentId;
import org.etsi.ttcn.tri.TriPortId;

/** 
 * Component manager interface for handling ports and component creation
 */
public interface IComponentMgr {

	/** 
	 * Adds a new component
	 * If the component was already added, nothing is done
	 * @param  component   The component to add
	 */
	public void addComponent(final TriComponentId component);

	/** 
	 * Gets the component reference from its name
	 * @param  componentName   The component name
	 * @return The component reference if the component exists, null otherwise
	 */
	public TriComponentId getComponent(final String componentName);

	/**
	 * Adds a new port to the specified component
	 * @param  componentName   The component name
	 * @param  ttcnPort        The TTCN port ID
	 * @param  port            The port to add
	 */
	public void addPort(final String componentName, final TriPortId ttcnPort, final IPort port);

	/** 
	 * Retrieves the TTCN-3 port identifier (TriPortId) from component/port names 
	 * @param  componentName   The component reference
	 * @param  portName        The port name
	 * @return The TTCN-3 port identifier if the component and the port exists, null otherwise
	 */
	public TriPortId getPortId(String componentName, String portName);

	/** 
	 * Retrieves the test adapter port identifier (Port or IAdapterPort) from component/port names
	 * @param  componentName   The component owner
	 * @param  portName        The port name
	 * @return The port reference if the component and the port exists, null otherwise
	 * 
	 * @see Port
	 * @see IAdapterPort
	 */
	public IPort getPort(final String componentName, final String portName);

	/**
	 * Removes the specified port
	 * 
	 * Note that after the port removal, if the component has no more port, it will be removed also
	 * 
	 * @param  componentName   The component name
	 * @param  portName        The port to remove
	 */
	public void removePort(final String componentName, final String portName);

	/** 
	 * Removes the specified component
	 * Note that all ports attached to this component will be removed also
	 * 
	 * @param  componentName   The component name to remove
	 */
	public void removeComponent(final String componentName);

	/** 
	 * Removes all ports
     */
    void removeAllPorts();

} // End of interface IComponentMgr
