X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=org.eclipse.linuxtools.tmf.core%2Fsrc%2Forg%2Feclipse%2Flinuxtools%2Ftmf%2Fcore%2Fctfadaptor%2FCtfLocation.java;h=7ca9fb0ac9be811eee957c875cb776517a5c12a6;hb=9a47bdf1564b806956fc15ae4a5e3790f8a0d4be;hp=fcb2b2bf407427b44c153b7bb00f9df4e7d19bc2;hpb=0879b6b99259ae5e8edbdd6e522ef9e26ff24c21;p=deliverable%2Ftracecompass.git diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java index fcb2b2bf40..7ca9fb0ac9 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfLocation.java @@ -14,59 +14,99 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation; /** - * The ctflocation is the nugget of information that is unique to a location in a trace. - * it can be copied and used to restore a position in a given trace. + * The nugget of information that is unique to a location in a CTF trace. + * + * It can be copied and used to restore a position in a given trace. + * + * @version 1.0 + * @author Matthew Khouzam */ -public class CtfLocation implements ITmfLocation, Cloneable { +public class CtfLocation implements ITmfLocation, Cloneable { - public static final Long INVALID_LOCATION = -1L; + private CtfLocationData fLocation; /** - * Constructor for CtfLocation. - * @param location Long + * An invalid location */ - public CtfLocation(Long location) { - setLocation(location); - } + public static final CtfLocationData INVALID_LOCATION = new CtfLocationData(-1, -1); /** - * Constructor for CtfLocation. - * @param timestamp ITmfTimestamp + * Constructor for CtfLocation. Uses a default index of 0. + * + * @param timestamp + * The timestamp of this location */ public CtfLocation(ITmfTimestamp timestamp) { - setLocation(timestamp.getValue()); + setLocation(new CtfLocationData(timestamp.getValue(), 0)); } - private Long fTimestamp; + /** + * Standard constructor + * + * @param timestamp + * The timestamp of this location + * @param index + * The index of this location for this timestamp + * @since 2.0 + */ + public CtfLocation(ITmfTimestamp timestamp, long index) { + setLocation(new CtfLocationData(timestamp.getValue(), index)); + } /** - * Method setLocation. - * @param location Long + * Copy constructor + * + * @param location + * Other location to copy + * @since 2.0 */ - public void setLocation(Long location) { - this.fTimestamp = location; + public CtfLocation(CtfLocationData location) { + setLocation(location); } /** - * Method getLocation. - * @return Long - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocation() + * Move this location to another location's position. + * + * @param location + * The location to seek to + * @since 2.0 */ - @Override - public Long getLocation() { - return this.fTimestamp; + public void setLocation(CtfLocationData location) { + this.fLocation = location; } /** - * Method clone. - * @return CtfLocation - * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#clone() + * Change this location's timestamp and index values. + * + * @param timestampValue + * The new timestamp + * @param index + * The new index + * @since 2.0 + */ + public void setLocation(long timestampValue, long index) { + this.fLocation = new CtfLocationData(timestampValue, index); + } + + + /** + * Get the Location Data of this location + * + * @return The CtfLocationData + * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo() + * @since 2.0 */ + @Override + public CtfLocationData getLocationInfo() { + return fLocation; + } + @Override public CtfLocation clone() { - return new CtfLocation(getLocation()); + return new CtfLocation(new CtfLocationData(fLocation.getTimestamp(), fLocation.getIndex())); } + /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @@ -75,7 +115,7 @@ public class CtfLocation implements ITmfLocation, Cloneable { final int prime = 31; int result = 1; result = (prime * result) - + ((fTimestamp == null) ? 0 : fTimestamp.hashCode()); + + ((fLocation == null) ? 0 : fLocation.hashCode()); return result; } @@ -94,11 +134,11 @@ public class CtfLocation implements ITmfLocation, Cloneable { return false; } CtfLocation other = (CtfLocation) obj; - if (fTimestamp == null) { - if (other.fTimestamp != null) { + if (fLocation == null) { + if (other.fLocation != null) { return false; } - } else if (!fTimestamp.equals(other.fTimestamp)) { + } else if (!fLocation.equals(other.fLocation)) { return false; } return true; @@ -109,10 +149,11 @@ public class CtfLocation implements ITmfLocation, Cloneable { */ @Override public String toString() { - if( this.getLocation().equals(CtfLocation.INVALID_LOCATION )) { + if( this.getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) { return "CtfLocation: INVALID"; //$NON-NLS-1$ } - return "CtfLocation: " + getLocation().toString(); //$NON-NLS-1$ + return "CtfLocation: " + getLocationInfo().toString(); //$NON-NLS-1$ } + }