import org.freehep.jaco.*;
import test.*;
/**
 * Main class for testing Jaco!
 */
public class TestMain
{
	public static void main(String[] argv)
	{
		// Load the library with the C++ classes
		
		System.loadLibrary("TonysTest");
		// Create the event source
		
		TestEventSource source = TestEventSourceProxy.create();
		System.out.println("source="+source);
		
		// Analyze some events
		
		for (int i=0; i<10; i++)
		{
			TestEvent e = source.nextEvent();
			if (e == null) System.out.println("e == null!");
			System.out.println("event="+e);
			System.out.println("Event "+e.getEventNumber()+" has "+e.getNTracks()+" tracks ");
			TestTrack t1 = e.getTrack(0);
			TestTrack t2 = e.getTrack(1.0);
			System.out.println("t1="+t1+" t2="+t2);
         e.printTrack(t1);
			e.delete();
		}
		source.delete();
		
		showMem();
		System.gc();
		System.runFinalization();
		showMem();
	}
	private static void showMem()
	{
		Runtime r = Runtime.getRuntime();
		long free = r.freeMemory();
		long alloc = r.totalMemory();
		System.out.println("memory="+(alloc-free));
	}
}
