/*******************************************************************************
 *  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 cdac.medinfo.sdk.dcm30_04.exceptions.InvalidHeaderException;
import cdac.medinfo.sdk.dcm30_04.utils.ICollectionIterable;


/**
 * This interface needs to be implemented by all classes which implements the necessary functionality for the Dicom File Header.
 */
public interface IDicomFileHeader extends ICollectionIterable<IDataElement>
{
	/**
	 * Sets the Preamble value for file.
	 * Preamble is the 128 bytes value contains information about user,company and etc.  
	 * @param bytePreamble byte array containing preamble value. 
	 * @return int - shows status as success or failure.
	 */
	void setPreAmble(byte[] bytePreamble);

	/**
	 * Retrieves Preamble value for file.
	 * @return byte[] - byte array containing preamble value. 
	 */
	byte[] getPreAmble();

	/**
	 * Populate the header value.
	 * @param header byte array containing header value.
	 * @throws InvalidHeaderException if validation of header fails.
	 * @throws IOException if Input/Output operation fails.
	 */
	void populate(byte[] header) throws InvalidHeaderException, IOException;

	/**
	 * Retrieves the TransferSyntax for file. 
	 * @return ITransferSyntax - instance of TransferSyntax. 
	 */
	ITransferSyntax getTransferSyntax();

	/**
	 * Retrieves the header value for the file.
	 * @return byte[] - Byte array containing header value.
	 * @throws InvalidHeaderException if Header validation fails.
	 * @throws IOException if Input/Output operation fails.
	 */
	byte[] getHeader() throws InvalidHeaderException, IOException;

	/**
	 * Retrieves the data for given tag.
	 * @param iGroupNumber integer value of group number.
	 * @param iElementNumber integer value of element number.
	 * @return IDataElement - instance of DataElement.
	 */
	IDataElement getDataFromTag(int iGroupNumber,int iElementNumber);

	/**
	 * Creates the default header.
	 * @throws InvalidHeaderException if Header validation fails.
	 */
	void createDefaultHeader() throws InvalidHeaderException;

	/**
	 * Serializes the Data Element 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.
	 */
	int serialize(IDicomStream objIDicomStream) throws IOException;

	/**
	 * Sets the TransferSyntax unique ID.
	 * @param strTransferSyntaxUID string value of TransferSyntax.
	 * @return int - shows status as success or failure.
	 */
	void setTransferSyntaxUID(String strTransferSyntaxUID);

	/**
	 * Retrieves the TransferSyntax unique ID.
	 * @return String - string value of TransferSyntax unique ID
	 */
	String getTransferSyntaxUID();

	/**
	 * Adds the Data element in the header.
	 * @param objIDataElement instance of DataElement.
	 * @return int - shows status as success or failure.
	 */
	int addDataElement(IDataElement objIDataElement);
}
