/*******************************************************************************
 *  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.commoninterface;

import java.io.IOException;
import java.io.Serializable;

import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataElementException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataSetException;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterable;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;


// TODO: Auto-generated Javadoc
/**
 * This interface needs to be implemented by all classes which implements the DataSet along with iterability.
 */
public interface IDataSet extends ICollectionIterable<IDataElement>, Serializable
{
	/**
	 * Retrieves the DataElement for the specified tag.
	 * @param iGroupNumber integer value of group number.
	 * @param iElementNumber integer value of element number.
	 * @return IDataElement - instance of DataElement.
	 */
	IDataElement getDataForTag(int iGroupNumber, int iElementNumber);

	/**
	 * Retrieves the DictionaryReader.
	 * 
	 * @return IDictionaryReader - instance of DictionaryReader.
	 */
	IDictionaryReader getDictionaryReader();

	/**
	 * Adds the DataElement to the DataSet
	 * @param objIDataElement instance of DataElement.
	 * @return int - shows status as success or failure.
	 */
	int addDataElement(IDataElement objIDataElement)throws InvalidDataElementException;

	/**
	 * Retrieves the TransferSyntax set in the DataSet.
	 * 
	 * @return ITransferSyntax - instance of TransferSyntax.
	 */
	ITransferSyntax getTransferSyntax();

	/**
	 * Checks that element is present in dataset 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);

	/**
	 * Checks that dataset is empty or not.
	 * @return boolean - shows status as success or failure.
	 */
	boolean isEmpty();

	/**
	 * Retrieves the unique identifier for SOP class.
	 * 
	 * @return String - String value of UID.
	 */
	String getSOPClassUID();

	/**
	 * Validates the DataSet according to the DICOM Rules
	 * @return boolean - shows status as success or failure.
	 * @throws InvalidDataSetException if validation of DataSet fails.
	 */
	boolean validate() throws InvalidDataSetException;

	/**
	 * Check for the equality of two objects.
	 * @param objObject the object to compare with. 
	 * @return boolean - true if the objects are the same false otherwise.
	 */
	public boolean equals(Object objObject);


	/**
	 * The implementation of this method returns iNumberOfBytes in a byte array.
	 * @param iNumberOfBytes No of bytes required.
	 * @return byte[] - byte array containing iNumberOfBytes.
	 * @throws IOException if IOException occurs.
	 */
	public byte[] getBytes(int iNumberOfBytes) throws IOException;

	/**
	 * The implementation of this method returns true is data is available in Data set.
	 * @return boolean - true if data is available in Data set.
	 					 false if data is not available in Data set.
	 * @throws IOException if IO Operation fails.
	 */
	public boolean isAvailable() throws IOException;

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

	/**
	 * This method removes the data element from the data set.
	 * @param objIDataElement Object of Data Element which is to be removed.
	 */
	public void removeDataElement(IDataElement objIDataElement);
	
	/**
	 * This method removes the data element from the data set.
	 * @param objITag Tag of data element which is to be removed.
	 */
	public void removeDataElement(ITag objITag);

	/**
	 * Validates DataSet for all DataElements and retrieves collection of invalid DataElements.
	 * 
	 * @return ISingleCollection<IDataElement> - collection of DataElements.
	 */
	public ISingleCollection<IDataElement> getInvalidDataElements();

	/**
	 * This function disposes the DataSet.
	 * @throws IOException Signals if IO operation fails.
	 */
	public void dispose() throws IOException;
	
	/**
	 * Create similar object of this class.
	 * This does the deep copy and create a new instance of this class and return it.
	 * @return IDataSet- object of IDataSet.
	 */
	public Object clone();
	
	/**
	 * Dumps the contents of Data Set in readable form to the specified stream.
	 * Contents such as Group Number, Element Number, VR, Value Length, and Value are dumped.
	 * @param objIDicomStream   the Stream on which the Data is to be written.
	 * @throws IOException - Exception is thrown indicating runtime failure of writing operation.
	 */
	public void dumpDICOMInfo(IDicomStream objIDicomStream) throws IOException;
}