/*******************************************************************************
 *  Copyright 2017-2018 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *   http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.dcm30_04.services.dicomnetcommons;

import java.io.IOException;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomStream;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataSetException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ParseException;
import cdac.medinfo.sdk.dcm30_04.exceptions.SerializeException;

// TODO: Auto-generated Javadoc
/**
 * This interface needs to be implemented by all classes which implements the
 * CommandSet alongwith iterability.
 */
public interface ICommandSet 
{
	
	/**
	 * The implementation of this method parses the CommandSet from the given
	 * Stream.
	 * 
	 * @param objIDicomStream  Stream on which the DICOM data is available.
	 * 
	 * @return int - shows status as success or failure.
	 * 
	 * @throws ParseException  If parsing fails.
	 * @throws IOException  If Input/Output operation fails.
	 */
	int parse(IDicomStream objIDicomStream) throws ParseException,IOException;

	/**
	 * The implementation of this method serialize the CommandSet from the given
	 * Stream.
	 * 
	 * @param objIDicomStream  Stream on which the DICOM data is available.
	 * 
	 * @return int - shows status as success or failure.
	 * 
	 * @throws IOException   If Input/Output operation fails.
	 * @throws SerializeException the serialize exception
	 */
	int serialize(IDicomStream objIDicomStream) throws SerializeException,IOException;

	/**
	 * The implementation of this method retrieves the CommandElement for the
	 * specified tag.
	 * 
	 * @param iGroupNumber  integer value of group number.
	 * @param iElementNumber integer value of element number.
	 * 
	 * @return IDataElement - instance of DataElement.
	 */
	ICommandElement getDataForTag(int iGroupNumber, int iElementNumber);

	/**
	 * The implementation of this method retrieves the DictionaryReader.
	 * 
	 * @return IDictionaryReader - instance of DictionaryReader.
	 */
	IDictionaryReader getDictionaryReader();

	/**
	 * The implementation of this method adds the CommandElement to the command set.
	 * 
	 * @param objICommandElement the command element to be added to command set.
	 * 
	 * @return int - shows status as success or failure.
	 */
	int addCommandElement(ICommandElement objICommandElement);

	/**
	 * The implementation of this method retrieves the TransferSyntax set in the
	 * DataSet.
	 * 
	 * @return ITransferSyntax - instance of TransferSyntax.
	 */
	ITransferSyntax getTransferSyntax();

	/**
	 * The implementation of this method checks that element is present in
	 * Command set or not.
	 * 
	 * @param iGroupNumber integer value of group number.
	 * @param iElementNumber integer value of element number.
	 * 
	 * @return boolean - shows status as success or failure.
	 */
	boolean isPresent(int iGroupNumber,int iElementNumber);

	/**
	 * The implementation of this method checks that Command set is empty or
	 * not.
	 * 
	 * @return boolean - shows status as success or failure.
	 */
	boolean isEmpty();

	/**
	 * The implementation of this method validates the CommandSet according to
	 * the DICOM Rules.
	 * 
	 * @return boolean - shows status as success or failure.
	 * 
	 * @throws InvalidDataSetException if validation of DataSet fails.
	 * @throws InvalidCommandSetException  the invalid command set exception
	 */
	boolean validate() throws InvalidCommandSetException;

	/**
	 * This function returns the length of Command Set.
	 * 
	 * @return int - Length of Command Set.
	 */
	public int getCommandSetLength();

	/**
	 * Checks if command set bytes is available.
	 * 
	 * @return boolean- true if command set bytes is available
	 * false if command set bytes is not available
	 */
	public boolean isAvailable() ;

	/**
	 * Gets the bytes of Comamnd Set.
	 * 
	 * @param iNumberOfBytes the number of bytes required.
	 * 
	 * @return byte[] byte array containing iNumber of bytes if available,
	 * else the no of bytes available with Command Set.
	 * 
	 * @throws IOException   Signals that an I/O exception has occurred.
	 */
	public byte[] getBytes(int iNumberOfBytes) throws IOException;

	/**
	 * This method returns value of DicomValue.
	 * 
	 * @param iGroupNumber Group Number of the Command Element
	 * @param iElementNumber Element Number of the Command Element
	 * 
	 * @return Object - instance of IDicomValue.
	 */
	public Object getValue(int iGroupNumber, int iElementNumber);
}
