import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEventType;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
import org.junit.Test;
/**
public void testCtfTmfEventType() {
String eventName = "";
ITmfEventField content = new TmfEventField("", null, new ITmfEventField[] {});
- CtfTmfEventType result = new CtfTmfEventType( eventName, content);
+ CtfTmfEventType result = new CtfTmfEventType(eventName, new TmfTraceStub(), content);
assertNotNull(result);
assertEquals("", result.toString());
assertEquals("", result.getName());
- assertEquals("Ctf Event", result.getContext());
+ assertEquals("Ctf Event/null", result.getContext());
}
/**
@Test
public void testToString() {
ITmfEventField emptyField = new TmfEventField("", null, new ITmfEventField[] {});
- CtfTmfEventType fixture = new CtfTmfEventType("", emptyField);
+ CtfTmfEventType fixture = new CtfTmfEventType("", new TmfTraceStub() , emptyField);
String result = fixture.toString();
@Override
public ITmfEventType getType() {
- CtfTmfEventType ctfTmfEventType = CtfTmfEventType.get(fEventName);
+ CtfTmfEventType ctfTmfEventType = CtfTmfEventType.get(getTrace(), fEventName);
if (ctfTmfEventType == null) {
/* Should only return null the first time */
- ctfTmfEventType = new CtfTmfEventType(fEventName, getContent());
+ ctfTmfEventType = new CtfTmfEventType(fEventName, getTrace(), getContent());
}
return ctfTmfEventType;
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfEventTypeManager;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
* The CTF extension of the TMF event type
*/
public class CtfTmfEventType extends TmfEventType {
+ /**
+ * CTFTmfEventType context for the event type manager
+ */
private static final String CONTEXT_ID = "Ctf Event"; //$NON-NLS-1$
+ private static final String UNKNOWN_TRACE = "unknown"; //$NON-NLS-1$
+
/**
* Constructor for CtfTmfEventType.
*
* @param eventName
- * String
+ * The event name
+ * @param trace
+ * the parent trace
* @param content
- * ITmfEventField
+ * The event field
+ * @since 3.0
*/
- public CtfTmfEventType(String eventName, ITmfEventField content) {
- super(CONTEXT_ID, eventName, content);
+ public CtfTmfEventType(String eventName, ITmfTrace trace, ITmfEventField content) {
+ super(computeContextName(trace), eventName, content);
}
/**
/**
* gets the event type for an event name
*
+ * @param trace
+ * the parent trace
* @param eventName
* the event name
* @return the event type
+ * @since 3.0
+ */
+ public static CtfTmfEventType get(CtfTmfTrace trace, String eventName) {
+ return (CtfTmfEventType) TmfEventTypeManager.getInstance().getType(computeContextName(trace), eventName);
+ }
+
+ /**
+ * Get the context name of a ctf trace
+ *
+ * @param trace
+ * the trace
+ * @return the context name
+ * @since 3.0
*/
- public static CtfTmfEventType get(String eventName){
- return (CtfTmfEventType) TmfEventTypeManager.getInstance().getType(CONTEXT_ID, eventName);
+ public static String computeContextName(ITmfTrace trace) {
+ return CONTEXT_ID + "/" + (trace == null ? UNKNOWN_TRACE : trace.getPath()); //$NON-NLS-1$
}
}