From 369aca6e5bbaffa5b4a1b3f7ffedaec5a7c39a00 Mon Sep 17 00:00:00 2001 From: William Bourque Date: Mon, 19 Apr 2010 23:07:30 +0000 Subject: [PATCH] To comply with the new interface that allow to copy experiment/trace --- .../lttng/trace/LTTngTextTrace.java | 24 +++++++++-- .../linuxtools/lttng/trace/LTTngTrace.java | 40 +++++++++++++++---- 2 files changed, 53 insertions(+), 11 deletions(-) diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java index 10cd429b9a..621d03c34f 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTextTrace.java @@ -101,11 +101,28 @@ public class LTTngTextTrace extends TmfTrace implements ITmfTrace { } - private LTTngTextTrace(LTTngTrace oldStream) throws Exception { - super(LttngEvent.class, null); - throw new Exception("Copy constructor should never be use with a LTTngTrace!"); + public LTTngTextTrace(LTTngTextTrace oldTrace) throws Exception { + this(oldTrace.getPath(), true); + + // *** VERIFY *** + // Is this safe? + fCheckpoints = oldTrace.fCheckpoints; } + public LTTngTextTrace createTraceCopy() { + + LTTngTextTrace returnedTrace = null; + + try { + returnedTrace = new LTTngTextTrace(this); + } + catch (Exception e) { + System.out.println("ERROR : Could not create LTTngTextTrace copy (createTraceCopy).\nError is : " + e.getStackTrace()); + } + + return returnedTrace; + } + private boolean positionToFirstEvent() { boolean isSuccessful = true; @@ -411,7 +428,6 @@ public class LTTngTextTrace extends TmfTrace implements ITmfTrace { public int getCpuNumber() { return cpuNumber; } - } diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java index bd6a021391..c3a1cc7305 100644 --- a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java +++ b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LTTngTrace.java @@ -169,19 +169,45 @@ public class LTTngTrace extends TmfTrace { new LttngTimestamp(currentJniTrace.getEndTime().getTime()) ) ); } - } /* * Copy constructor is forbidden for LttngEvenmStream * - * Events are only valid for a very limited period of time and - * JNI library does not support multiple access at once (yet?). - * For this reason, copy constructor should NEVER be used. */ - private LTTngTrace(LTTngTrace oldStream) throws Exception { - super(LttngEvent.class, null); - throw new Exception("Copy constructor should never be use with a LTTngTrace!"); + public LTTngTrace(LTTngTrace oldTrace) throws Exception { + this(oldTrace.getPath(), false, true); + + // *** VERIFY *** + // Is this safe? + this.fCheckpoints = oldTrace.fCheckpoints; + + /* + // This would only work if the index is already done + this.fCheckpoints = new Vector( oldTrace.fCheckpoints.size() ); + for (int x = 0; x