tmf: Generalize the support for call sites and model URIs
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfTmfCallsite.java
index e073984cc4609a329d5bb9a79ee70762acba8946..d929d6b3c867a8ef74701dafc74a2c0979a0b4a8 100644 (file)
  *
  * Contributors:
  *     Patrick Tasse - Initial API and implementation
+ *     Bernd Hufmann - Updated for new parent class
  *******************************************************************************/
 
 package org.eclipse.linuxtools.tmf.core.ctfadaptor;
 
 import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
+import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
 
 /**
- * Callsite information
+ * CTF TMF call site information for source code lookup.
+ *
+ * @author Patrick Tasse
  * @since 2.0
  */
-public class CtfTmfCallsite {
+public class CtfTmfCallsite extends TmfCallsite {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+
+    /** The event name. */
+    final private String fEventName;
+
+    /** The instruction pointer. */
+    final private long fInstructionPointer;
 
-    private String eventName;
-    private String fileName;
-    private String functionName;
-    private long lineNumber;
-    private long ip;
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
 
+    /**
+     * Standard Constructor.
+     *
+     * @param callsite
+     *              - a CTF call site
+     */
     CtfTmfCallsite(CTFCallsite callsite) {
-        eventName = callsite.getEventName();
-        fileName = callsite.getFileName();
-        functionName = callsite.getFunctionName();
-        lineNumber = callsite.getLineNumber();
-        ip = callsite.getIp();
+        super(callsite.getFileName(), callsite.getFunctionName(), callsite.getLineNumber());
+        fEventName = callsite.getEventName();
+        fInstructionPointer = callsite.getIp();
     }
 
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
     /**
+     * Returns the event name of the call site.
      * @return the event name
      */
     public String getEventName() {
-        return eventName;
+        return fEventName;
     }
 
     /**
-     * @return the file name
+     * Returns the instruction pointer of the call site.
+     * @return the instruction pointer
      */
-    public String getFileName() {
-        return fileName;
+    public long getIntructionPointer() {
+        return fInstructionPointer;
     }
 
-    /**
-     * @return the function name
-     */
-    public String getFunctionName() {
-        return functionName;
-    }
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
 
-    /**
-     * @return the line number
-     */
-    public long getLineNumber() {
-        return lineNumber;
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result + ((fEventName == null) ? 0 : fEventName.hashCode());
+        result = prime * result + (int) (fInstructionPointer ^ (fInstructionPointer >>> 32));
+        return result;
     }
 
-    /**
-     * @return the ip
-     */
-    public long getIp() {
-        return ip;
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        CtfTmfCallsite other = (CtfTmfCallsite) obj;
+        if (fEventName == null) {
+            if (other.fEventName != null) {
+                return false;
+            }
+        } else if (!fEventName.equals(other.fEventName)) {
+            return false;
+        }
+        if (fInstructionPointer != other.fInstructionPointer) {
+            return false;
+        }
+        return true;
     }
 
     @Override
     public String toString() {
-        return eventName + "@0x" + Long.toHexString(ip) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
-                fileName + ':' + Long.toString(lineNumber) + ' ' + functionName + "()"; //$NON-NLS-1$
+        return getEventName() + "@0x" + Long.toHexString(fInstructionPointer) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
+                getFileName() + ':' + Long.toString(getLineNumber()) + ' ' + getFileName() + "()"; //$NON-NLS-1$
     }
 }
This page took 0.026823 seconds and 5 git commands to generate.