/*
 * BurnSource.java
 *
 * Copyright (c) 2007  Vreixo Formoso
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * See COPYING file for details.
 */

package org.pykix.libburnia.libburn;

/**
 * Data source for tracks on disc.
 * 
 * FIXME think about design of this object. being an interface any user
 * can create its own implementation and pass it to libburn, and this will
 * not work.
 *  
 * @author Vreixo Formoso
 * @since 0.1
 */
public interface BurnSource {
	
	/**
	 * Read data from the source.
	 * 
	 * @param buffer
	 * 		Buffer where data is to be read. Must have at least size bytes.
	 * @param size
	 * 		Number of bytes to be read.
	 * @return
	 * 		Number of bytes actually read.
	 * @throws IndexOutOfBoundsException
	 * 		If size bigger than buffer length
	 * @throws NullPointerException
	 * 		If buffer is <code>null</code>
	 */
	int read(byte[] buffer, int size);
	
	/**
	 * Read subchannel data from the source.
	 * 
	 * @param buffer
	 * 		Buffer where data is to be read. Must have at least size bytes.
	 * @param size
	 * 		Number of bytes to be read.
	 * @return
	 * 		Number of bytes actually read.
	 * @throws IndexOutOfBoundsException
	 * 		If size bigger than buffer length
	 * @throws NullPointerException
	 * 		If buffer is <code>null</code>
	 */
	int readSub(byte[] buffer, int size);

	/**
	 * Get the size of the source's data.
	 * @return
	 */
	long getSize();
	
	/**
	 * Set the size of the source's data.
	 * @param bytes
	 * @return
	 */
	int setSize(long bytes);
	
}
