package org.eclipse.scanning.example.malcolm;

/**
 * A model describing a dataset that should be written by a {@link DummyMalcolmDevice}.
 * 
 * @author Matthew Dickie
 */
public class DummyMalcolmDatasetModel {
	
	private String name;
	
	private Class<?> dtype; // type of element in the dataset, e.g. String or Double
	
	private int rank;
	
	private int[] shape = null;
	
	public DummyMalcolmDatasetModel() {
		// no args constructor for spring instantiation
	}
	
	public DummyMalcolmDatasetModel(String name, int rank, Class<?> dtype) {
		this.name = name;
		this.rank = rank;
		this.dtype = dtype;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * The rank of the data for this dataset at each point in the scan, e.g. 2 for images.
	 * In the Nexus file this dataset will have a rank of scan rank plus this value. 
	 * @return rank of data at each scan point
	 */
	public int getRank() {
		return rank;
	}

	public void setRank(int rank) {
		this.rank = rank;
	}

	public Class<?> getDtype() {
		return dtype;
	}

	public void setDtype(Class<?> dtype) {
		this.dtype = dtype;
	}
	
	public void setShape(int[] shape) {
		if (shape.length != rank) {
			throw new IllegalArgumentException("size of shape array must equal rank " + rank);
		}
		
		this.shape = shape;
	}
	
	public int[] getShape() {
		return shape;
	}

}

@@ -40,16 +40,42 @@
 lcolm;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * A
@@ -1409,10 +1409,192 @@
 pe;%0A%09%7D%0A%0A
+%09@Override%0A%09public String toString() %7B%0A%09%09return %22DummyMalcolmDatasetModel %5Bname=%22 + name + %22, dtype=%22 + dtype + %22, rank=%22 + rank + %22, shape=%22%0A%09%09%09%09+ Arrays.toString(shape) + %22%5D%22;%0A%09%7D%0A%0A
 %7D%0A

add toString()