tmf: Axe the TmfEventTypeManager
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 22 Oct 2014 17:14:03 +0000 (13:14 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 24 Oct 2014 19:08:36 +0000 (15:08 -0400)
Track the available event types in each trace object instead. K.I.S.S.

Also removed the notion of "context" from TmfEventType, which is not
needed anymore.

Change-Id: I8dc1409abb08fd930dd1f8b01027ece488551ec1
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/35354
Reviewed-by: Genevieve Bastien <gbastien+lttng@versatic.net>
Tested-by: Genevieve Bastien <gbastien+lttng@versatic.net>
28 files changed:
org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/AllTests.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeManagerTest.java [deleted file]
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java
org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java
org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfEventTypeStub.java
org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfEventParserStub.java
org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java
org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventTypeManager.java [deleted file]
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java
org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java
org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfEventTypeTest.java
org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfTraceTest.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEvent.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEventType.java
org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java
org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java
org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java
org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java
org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java
org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java

index 551ebb0078517377f0aa91b68fabfc62d1f38b4c..54e334e6925e2871938b673af5addfd5aa8928d0 100644 (file)
@@ -84,7 +84,6 @@ import org.eclipse.tracecompass.internal.gdbtrace.core.Activator;
 import org.eclipse.tracecompass.internal.gdbtrace.core.GdbTraceCorePlugin;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEvent;
 import org.eclipse.tracecompass.internal.gdbtrace.core.event.GdbTraceEventContent;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
@@ -140,7 +139,7 @@ public class DsfGdbAdaptor {
     // breakpoint (tracepoint is a kind of breakpoint)
     private  Map<Integer, MIBreakpointDMData> fTpInfo = new HashMap<>();
 
-    private TmfEventType tmfEventType = new TmfEventType(ITmfEventType.DEFAULT_CONTEXT_ID, "GDB Tracepoint", TmfEventField.makeRoot(new String[] { "Content" })); //$NON-NLS-1$ //$NON-NLS-2$
+    private TmfEventType tmfEventType = new TmfEventType("GDB Tracepoint", TmfEventField.makeRoot(new String[] { "Content" })); //$NON-NLS-1$ //$NON-NLS-2$
 
     {
         new DsfGdbPlatformEventListener();
index 19f74e89127724ab179de4c625330364937b3a09..785af1105416993908fb2fb96ff365d5756b3354 100644 (file)
@@ -25,7 +25,6 @@ import org.junit.runners.Suite;
 @Suite.SuiteClasses({
     TmfEventFieldTest.class,
     TmfEventTest.class,
-    TmfEventTypeManagerTest.class,
     TmfEventTypeTest.class,
     TmfNanoTimestampTest.class,
     TmfSimpleTimestampTest.class,
index 625a973b69795b522dd56c3b57e759bc7a5a106d..7bec894d42a3b34717d2be48e052909a444216fd 100644 (file)
@@ -30,7 +30,6 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
@@ -55,12 +54,11 @@ public class TmfEventTest {
 
     private final String fSource = "Source";
 
-    private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
     private final String fTypeId = "TestType";
     private final String fLabel1 = "AString";
     private final String fLabel2 = "AnInteger";
     private final String[] fLabels = new String[] { fLabel1, fLabel2 };
-    private final TmfEventType fType = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels));
 
     private final Object fValue1a = "Some string";
     private final Object fValue1b = Integer.valueOf(10);
@@ -336,7 +334,7 @@ public class TmfEventTest {
 
         final String typeId = "OtherTestType";
         final String[] labels = new String[] { fLabel2, fLabel1 };
-        final TmfEventType newType = new TmfEventType(fContext, typeId, TmfEventField.makeRoot(labels));
+        final TmfEventType newType = new TmfEventType(typeId, TmfEventField.makeRoot(labels));
 
         event2 = new TmfEvent(null, 0, fTimestamp1, fSource, newType, fContent1, fReference1);
         assertFalse("equals", event1.equals(event2));
diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeManagerTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeManagerTest.java
deleted file mode 100644 (file)
index fe2b6ba..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *   Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.core.tests.event;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Set;
-
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
-import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
-import org.eclipse.tracecompass.tmf.core.event.TmfEventTypeManager;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfEventTypeManager class.
- */
-@SuppressWarnings("javadoc")
-public class TmfEventTypeManagerTest {
-
-    // ------------------------------------------------------------------------
-    // Variables
-    // ------------------------------------------------------------------------
-
-    private static final TmfEventTypeManager fInstance = TmfEventTypeManager.getInstance();
-
-    private final String fContext1 = "JUnit context 1";
-    private final String fContext2 = "JUnit context 2";
-
-    private final String fTypeId1 = "Some type";
-    private final String fTypeId2 = "Some other type";
-    private final String fTypeId3 = "Yet another type";
-    private final String fTypeId4 = "A final type";
-
-    private final String fLabel0 = "label1";
-    private final String fLabel1 = "label2";
-    private final String fLabel2 = "label3";
-
-    private final String[] fLabels0 = new String[] { };
-    private final String[] fLabels1 = new String[] { fLabel0, fLabel1 };
-    private final String[] fLabels2 = new String[] { fLabel1, fLabel0, fLabel2 };
-
-    private final TmfEventType fType0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
-    private final TmfEventType fType1 = new TmfEventType(fContext1, fTypeId2, TmfEventField.makeRoot(fLabels1));
-    private final TmfEventType fType2 = new TmfEventType(fContext2, fTypeId3, TmfEventField.makeRoot(fLabels2));
-    private final TmfEventType fType3 = new TmfEventType(fContext2, fTypeId4, TmfEventField.makeRoot(fLabels1));
-
-    // ------------------------------------------------------------------------
-    // Getters
-    // ------------------------------------------------------------------------
-
-    @Test
-    public void testGetContexts() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-        fInstance.add(fContext1, fType1);
-        fInstance.add(fContext2, fType2);
-        fInstance.add(fContext2, fType3);
-
-        final String[] contexts = fInstance.getContexts();
-        Arrays.sort(contexts);
-        assertEquals("getContexts", 2, contexts.length);
-        assertEquals("getContexts", fContext1, contexts[0]);
-        assertEquals("getContexts", fContext2, contexts[1]);
-    }
-
-    @Test
-    public void testGetTypes() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-        fInstance.add(fContext1, fType1);
-        fInstance.add(fContext2, fType2);
-        fInstance.add(fContext2, fType3);
-
-        Set<ITmfEventType> types = fInstance.getTypes(fContext1);
-        assertEquals("getTypes", 2, types.size());
-        assertTrue(types.contains(fType1));
-        assertTrue(types.contains(fType0));
-
-        types = fInstance.getTypes(fContext2);
-        assertEquals("getTypes", 2, types.size());
-        assertTrue(types.contains(fType2));
-        assertTrue(types.contains(fType3));
-    }
-
-    @Test
-    public void testGetType() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-        fInstance.add(fContext1, fType1);
-        fInstance.add(fContext2, fType2);
-        fInstance.add(fContext2, fType3);
-
-        ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
-        assertSame("getType", fType0, type);
-        type = fInstance.getType(fContext1, fType1.getName());
-        assertSame("getType", fType1, type);
-        type = fInstance.getType(fContext1, fType2.getName());
-        assertNull("getType", type);
-        type = fInstance.getType(fContext1, fType3.getName());
-        assertNull("getType", type);
-
-        type = fInstance.getType(fContext2, fType2.getName());
-        assertSame("getType", fType2, type);
-        type = fInstance.getType(fContext2, fType3.getName());
-        assertSame("getType", fType3, type);
-        type = fInstance.getType(fContext2, fType0.getName());
-        assertNull("getType", type);
-        type = fInstance.getType(fContext2, fType1.getName());
-        assertNull("getType", type);
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-
-    @Test
-    public void testClear() {
-        fInstance.clear();
-        assertEquals("clear", 0, fInstance.getContexts().length);
-        assertEquals("clear", 0, fInstance.getTypes(null).size());
-        assertNull("clear", fInstance.getType(null, null));
-        assertEquals("clear", "TmfEventTypeManager [fEventTypes={}]", fInstance.toString());
-    }
-
-    @Test
-    public void testClearContext() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-        fInstance.add(fContext1, fType1);
-        fInstance.add(fContext2, fType2);
-        fInstance.add(fContext2, fType3);
-
-        fInstance.clear(fContext1);
-
-        final String[] contexts = fInstance.getContexts();
-        assertEquals("clear context", 1, contexts.length);
-        assertEquals("clear context", fContext2, contexts[0]);
-
-        Set<ITmfEventType> types = fInstance.getTypes(fContext1);
-        assertEquals("clear context", 0, types.size());
-
-        ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
-        assertNull("clear context", type);
-        type = fInstance.getType(fContext1, fType1.getName());
-        assertNull("clear context", type);
-
-        types = fInstance.getTypes(fContext2);
-        assertEquals("clear context", 2, types.size());
-        assertTrue(types.contains(fType2));
-        assertTrue(types.contains(fType3));
-    }
-
-    @Test
-    public void testBasicAdd() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-
-        final String[] contexts = fInstance.getContexts();
-        assertEquals("add", 1, contexts.length);
-        assertEquals("add", fContext1, contexts[0]);
-
-        final Set<ITmfEventType> types = fInstance.getTypes(contexts[0]);
-        assertEquals("add", 1, types.size());
-        assertTrue(types.contains(fType0));
-
-        ITmfEventType type = fInstance.getType(contexts[0], fType0.getName());
-        assertSame("add", fType0, type);
-
-        type = fInstance.getType(contexts[0], fType1.getName());
-        assertNotSame("add", fType0, type);
-    }
-
-    @Test
-    public void testAdd() {
-        fInstance.clear();
-        fInstance.add(fContext1, fType0);
-        fInstance.add(fContext1, fType1);
-        fInstance.add(fContext2, fType2);
-        fInstance.add(fContext2, fType3);
-
-        final String[] contexts = fInstance.getContexts();
-        Arrays.sort(contexts);
-        assertEquals("add", 2, contexts.length);
-        assertEquals("add", fContext1, contexts[0]);
-        assertEquals("add", fContext2, contexts[1]);
-
-        Set<ITmfEventType> types = fInstance.getTypes(fContext1);
-        assertEquals("add", 2, types.size());
-        assertTrue(types.contains(fType0));
-        assertTrue(types.contains(fType1));
-
-        types = fInstance.getTypes(fContext2);
-        assertEquals("add", 2, types.size());
-        assertTrue(types.contains(fType2));
-        assertTrue(types.contains(fType3));
-
-        ITmfEventType type = fInstance.getType(fContext1, fType0.getName());
-        assertSame("add", fType0, type);
-        type = fInstance.getType(fContext1, fType1.getName());
-        assertSame("add", fType1, type);
-        type = fInstance.getType(fContext2, fType2.getName());
-        assertSame("add", fType2, type);
-        type = fInstance.getType(fContext2, fType3.getName());
-        assertSame("add", fType3, type);
-
-        type = fInstance.getType(fContext1, fType2.getName());
-        assertNull("add", type);
-        type = fInstance.getType(fContext2, fType0.getName());
-        assertNull("add", type);
-    }
-
-    // ------------------------------------------------------------------------
-    // Object
-    // ------------------------------------------------------------------------
-
-    @Test
-    public void testToString() {
-        fInstance.clear();
-        assertEquals("toString", "TmfEventTypeManager [fEventTypes={}]", fInstance.toString());
-
-        fInstance.add(fContext1, fType0);
-        assertEquals("toString", "TmfEventTypeManager [fEventTypes={" + fContext1 + "={" + fTypeId1 + "=" + fType0 + "}}]", fInstance.toString());
-    }
-
-}
index 4a81181d799f867c58c77bf04b4e6284f003d109..50f1f1df77f46bdd156b9ef395b6238afabab405 100644 (file)
@@ -38,9 +38,6 @@ public class TmfEventTypeTest {
     // Variables
     // ------------------------------------------------------------------------
 
-    private final String fContext1 = "JUnit context 1";
-    private final String fContext2 = "JUnit context 2";
-
     private final String fTypeId1 = "Some type";
     private final String fTypeId2 = "Some other type";
 
@@ -52,10 +49,10 @@ public class TmfEventTypeTest {
     private final String[] fLabels1 = new String[] { fLabel0, fLabel1 };
     private final String[] fLabels2 = new String[] { fLabel1, fLabel0, fLabel2 };
 
-    private final ITmfEventType fType0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
-    private final ITmfEventType fType1 = new TmfEventType(fContext1, fTypeId2, TmfEventField.makeRoot(fLabels1));
-    private final ITmfEventType fType2 = new TmfEventType(fContext2, fTypeId1, TmfEventField.makeRoot(fLabels2));
-    private final ITmfEventType fType3 = new TmfEventType(fContext2, fTypeId2, TmfEventField.makeRoot(fLabels1));
+    private final ITmfEventType fType0 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels0));
+    private final ITmfEventType fType1 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1));
+    private final ITmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels2));
+    private final ITmfEventType fType3 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels1));
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -64,7 +61,6 @@ public class TmfEventTypeTest {
     @Test
     public void testDefaultConstructor() {
         final ITmfEventType type = new TmfEventType();
-        assertEquals("getContext", ITmfEventType.DEFAULT_CONTEXT_ID, type.getContext());
         assertEquals("getName", ITmfEventType.DEFAULT_TYPE_ID, type.getName());
         assertNull("getRootField", type.getRootField());
         assertEquals("getFieldNames", 0, type.getFieldNames().size());
@@ -72,24 +68,21 @@ public class TmfEventTypeTest {
 
     @Test
     public void testFullConstructor() {
-        final ITmfEventType type0 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels0));
-        assertEquals("getContext", fContext1, type0.getContext());
+        final ITmfEventType type0 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels0));
         assertEquals("getName", fTypeId1, type0.getName());
         assertEquals("getRootField", TmfEventField.makeRoot(fLabels0), type0.getRootField());
         final Collection<String> labels0 = type0.getFieldNames();
         assertEquals("getFieldNames length", fLabels0.length, labels0.size());
         assertArrayEquals(fLabels0, labels0.toArray(new String[labels0.size()]));
 
-        final ITmfEventType type1 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
-        assertEquals("getContext", fContext1, type1.getContext());
+        final ITmfEventType type1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels1));
         assertEquals("getName", fTypeId1, type1.getName());
         assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), type1.getRootField());
         final Collection<String> labels1 = type1.getFieldNames();
         assertEquals("getFieldNames length", fLabels1.length, labels1.size());
         assertArrayEquals(fLabels1, labels1.toArray(new String[labels1.size()]));
 
-        final ITmfEventType type2 = new TmfEventType(fContext2, fTypeId2, TmfEventField.makeRoot(fLabels2));
-        assertEquals("getContext", fContext2, type2.getContext());
+        final ITmfEventType type2 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels2));
         assertEquals("getName", fTypeId2, type2.getName());
         assertEquals("getRootField", TmfEventField.makeRoot(fLabels2), type2.getRootField());
         final Collection<String> labels2 = type2.getFieldNames();
@@ -97,27 +90,16 @@ public class TmfEventTypeTest {
         assertArrayEquals(fLabels2, labels2.toArray(new String[labels2.size()]));
     }
 
-    @Test
+    @Test(expected = IllegalArgumentException.class)
     public void testConstructorCornerCases() {
-        try {
-            new TmfEventType(null, fTypeId1, null);
-            fail("TmfEventType: null context");
-        } catch (final IllegalArgumentException e) {
-        }
-
-        try {
-            new TmfEventType(fContext1, null, null);
-            fail("TmfEventType: null type");
-        } catch (final IllegalArgumentException e) {
-        }
+        new TmfEventType(null, null);
     }
 
     @Test
     public void testCopyConstructor() {
-        final TmfEventType original = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
+        final TmfEventType original = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels1));
         final TmfEventType copy = new TmfEventType(original);
 
-        assertEquals("getContext", fContext1, copy.getContext());
         assertEquals("getName", fTypeId1, copy.getName());
         assertEquals("getRootField", TmfEventField.makeRoot(fLabels1), copy.getRootField());
         final Collection<String> labels1 = copy.getFieldNames();
@@ -220,13 +202,12 @@ public class TmfEventTypeTest {
 
     @Test
     public void testToString() {
-        final String expected1 = "TmfEventType [fContext=" + ITmfEventType.DEFAULT_CONTEXT_ID +
-                ", fTypeId=" + ITmfEventType.DEFAULT_TYPE_ID + "]";
+        final String expected1 = "TmfEventType [fTypeId=" + ITmfEventType.DEFAULT_TYPE_ID + "]";
         final TmfEventType type1 = new TmfEventType();
         assertEquals("toString", expected1, type1.toString());
 
-        final String expected2 = "TmfEventType [fContext=" + fContext1 + ", fTypeId=" + fTypeId1 + "]";
-        final TmfEventType type2 = new TmfEventType(fContext1, fTypeId1, TmfEventField.makeRoot(fLabels1));
+        final String expected2 = "TmfEventType [fTypeId=" + fTypeId1 + "]";
+        final TmfEventType type2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels1));
         assertEquals("toString", expected2, type2.toString());
     }
 
index e356324e0e1c17067af6765d7ee184a537f6f2a7..81ed95de29660ef7b512060ffe7ceb9ed429d2ee 100644 (file)
@@ -108,7 +108,7 @@ class TmfMipmapStateProviderStub extends AbstractTmfMipmapStateProvider {
             value = TmfStateValue.nullValue();
         }
         ITmfTimestamp timestamp = new TmfNanoTimestamp(time);
-        ITmfEventType eventType = new TmfEventType(ITmfEventType.DEFAULT_CONTEXT_ID, MIPMAP_ID, null);
+        ITmfEventType eventType = new TmfEventType(MIPMAP_ID, null);
         ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null);
         ITmfEvent event = new TmfEvent(null, timestamp, null, eventType, content, null);
         return event;
index fe093ca3c5ae48043a7b545000c74e72c2b97352..81b6e72e83d8f8752df5f76a113237a18554ee1c 100644 (file)
@@ -19,7 +19,6 @@ import static org.junit.Assert.fail;
 
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
@@ -32,7 +31,6 @@ import org.junit.Test;
  */
 public class TmfAsyncSequenceDiagramEventTest {
 
-    private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
     private final String fTypeId  = "Some type";
     private final String fLabel0  = "label1";
     private final String fLabel1  = "label2";
@@ -41,7 +39,7 @@ public class TmfAsyncSequenceDiagramEventTest {
     private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
     private final TmfTimestamp fTimestamp2 = new TmfTimestamp(12350, (byte) 2, 5);
     private final String       fSource     = "Source";
-    private final TmfEventType fType       = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType       = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels));
     private final String       fReference  = "Some reference";
 
     private final ITmfEvent fEvent1;
index e0f1b29546711a5d0935d5016c2ddcce61777dd6..a52ca044b11c48d27c348f967fe815e2fdb2e127 100644 (file)
@@ -19,7 +19,6 @@ import static org.junit.Assert.fail;
 
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
@@ -32,7 +31,6 @@ import org.junit.Test;
  */
 public class TmfSyncSequenceDiagramEventTest {
 
-    private final String fContext = ITmfEventType.DEFAULT_CONTEXT_ID;
     private final String fTypeId  = "Some type";
     private final String fLabel0  = "label1";
     private final String fLabel1  = "label2";
@@ -40,7 +38,7 @@ public class TmfSyncSequenceDiagramEventTest {
 
     private final TmfTimestamp fTimestamp1 = new TmfTimestamp(12345, (byte) 2, 5);
     private final String       fSource     = "Source";
-    private final TmfEventType fType       = new TmfEventType(fContext, fTypeId, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType       = new TmfEventType(fTypeId, TmfEventField.makeRoot(fLabels));
     private final String       fReference  = "Some reference";
 
     private final ITmfEvent fEvent1;
index d280069ae0ef7a9d157b186e8178c09232fdc239..6bab563d8d928f504ccdca2c8223ec23fed1ba46 100644 (file)
@@ -33,6 +33,6 @@ public class TmfEventTypeStub extends TmfEventType {
     private static ITmfEventField ROOT = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, null,  FIELDS);
 
     public TmfEventTypeStub() {
-        super("UnitTest", "TmfEventTypeStub", ROOT);
+        super("TmfEventTypeStub", ROOT);
     }
 }
index 52ffb46cc878bbfc2da5e8c42a992496f6b98926..a33ffbe0c0fd9eb410251caff792737cc7c6dea6 100644 (file)
@@ -58,7 +58,7 @@ public class TmfEventParserStub implements ITmfEventParser {
             }
             final String[] fieldArray = new String[i];
             final ITmfEventField rootField = TmfEventField.makeRoot(fields.toArray(fieldArray));
-            fTypes[i] = new TmfEventType("UnitTest", "Type-" + i, rootField);
+            fTypes[i] = new TmfEventType("Type-" + i, rootField);
         }
     }
 
index 66768a24d5c94cb787acd7aacc319a9777a04b8a..e66963bd2a50e1f81ee8672ae41cc78e0562e919 100644 (file)
@@ -12,7 +12,6 @@
 
 package org.eclipse.tracecompass.tmf.tests.stubs.trace.text;
 
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
 
@@ -45,7 +44,7 @@ public class SyslogEventType extends TmfEventType {
      * Default Constructor
      */
     public SyslogEventType() {
-        super(ITmfEventType.DEFAULT_CONTEXT_ID, TYPE_ID, TmfEventField.makeRoot(LABELS));
+        super(TYPE_ID, TmfEventField.makeRoot(LABELS));
     }
 
 }
index d612b7b91f72d7cafe6d2a4562b3541faa922da9..d2b72c94b0b843c3672999a7fceec8c3486653b1 100644 (file)
@@ -240,7 +240,7 @@ public class TmfXmlTraceStub extends TmfTrace {
 
         /* Create a new event with new fields and name */
         ITmfEventType customEventType = event.getType();
-        TmfEventType eventType = new TmfEventType(customEventType.getContext(), getStringValue(content, EVENT_NAME_FIELD), customEventType.getRootField());
+        TmfEventType eventType = new TmfEventType(getStringValue(content, EVENT_NAME_FIELD), customEventType.getRootField());
         ITmfEventField eventFields = new CustomEventContent(content.getName(), content.getValue(), fieldsArray);
         TmfEvent newEvent = new TmfEvent(this, event.getTimestamp(), getStringValue(content, SOURCE_FIELD), eventType, eventFields, event.getReference());
         updateAttributes(savedContext, event.getTimestamp());
index 4a3a107d83715aa294018000b9f4c854f2588486..74b86ebadf39aded78c06a984f13df2109be4966 100644 (file)
@@ -32,11 +32,6 @@ public interface ITmfEventType {
     // Constants
     // ------------------------------------------------------------------------
 
-    /**
-     * The default event type content
-     */
-    public static final String DEFAULT_CONTEXT_ID = "TmfContext"; //$NON-NLS-1$
-
     /**
      * The default event type name
      */
@@ -46,11 +41,6 @@ public interface ITmfEventType {
     // Getters
     // ------------------------------------------------------------------------
 
-    /**
-     * @return the event type context
-     */
-    String getContext();
-
     /**
      * @return the event type ID
      */
index 342503cf4893339d172614376c6f49b7a11e4fa7..d0444e96d26558b31562a9e94960af8691bd4240 100644 (file)
@@ -31,7 +31,6 @@ public class TmfEventType implements ITmfEventType {
     // Attributes
     // ------------------------------------------------------------------------
 
-    private final String fContext;
     private final String fTypeId;
     private final ITmfEventField fRootField;
 
@@ -43,26 +42,21 @@ public class TmfEventType implements ITmfEventType {
      * Default constructor
      */
     public TmfEventType() {
-        this(DEFAULT_CONTEXT_ID, DEFAULT_TYPE_ID, null);
+        this(DEFAULT_TYPE_ID, null);
     }
 
     /**
      * Full constructor
      *
-     * @param context the type context
      * @param typeId the type name
      * @param root the root field
      */
-    public TmfEventType(final String context, final String typeId, final ITmfEventField root) {
-        if (context == null || typeId == null) {
+    public TmfEventType(final String typeId, final ITmfEventField root) {
+        if (typeId == null) {
             throw new IllegalArgumentException();
         }
-        fContext = context;
         fTypeId = typeId;
         fRootField = root;
-
-        // Register to the event type manager
-        TmfEventTypeManager.getInstance().add(context, this);
     }
 
     /**
@@ -74,7 +68,6 @@ public class TmfEventType implements ITmfEventType {
         if (type == null) {
             throw new IllegalArgumentException();
         }
-        fContext = type.getContext();
         fTypeId  = type.getName();
         fRootField = type.getRootField();
     }
@@ -83,11 +76,6 @@ public class TmfEventType implements ITmfEventType {
     // ITmfEventType
     // ------------------------------------------------------------------------
 
-    @Override
-    public String getContext() {
-        return fContext;
-    }
-
     @Override
     public String getName() {
         return fTypeId;
@@ -114,7 +102,6 @@ public class TmfEventType implements ITmfEventType {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + fContext.hashCode();
         result = prime * result + fTypeId.hashCode();
         return result;
     }
@@ -131,9 +118,6 @@ public class TmfEventType implements ITmfEventType {
             return false;
         }
         final TmfEventType other = (TmfEventType) obj;
-        if (!fContext.equals(other.fContext)) {
-            return false;
-        }
         if (!fTypeId.equals(other.fTypeId)) {
             return false;
         }
@@ -143,7 +127,7 @@ public class TmfEventType implements ITmfEventType {
     @Override
     @SuppressWarnings("nls")
     public String toString() {
-        return "TmfEventType [fContext=" + fContext + ", fTypeId=" + fTypeId + "]";
+        return "TmfEventType [fTypeId=" + fTypeId + "]";
     }
 
 }
diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventTypeManager.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventTypeManager.java
deleted file mode 100644 (file)
index 596dbfb..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tracecompass.tmf.core.event;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * A central repository for the available event types. Types are managed by
- * context space.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see ITmfEventType
- */
-public final class TmfEventTypeManager {
-
-    // ------------------------------------------------------------------------
-    // Attributes
-    // ------------------------------------------------------------------------
-
-    // The event type manager singleton
-    private static TmfEventTypeManager fEventTypeManager = null;
-
-    // The available types, per context
-    private final Map<String, HashMap<String, ITmfEventType>> fEventTypes;
-
-    // ------------------------------------------------------------------------
-    // Constructors
-    // ------------------------------------------------------------------------
-
-    /**
-     * The singleton constructor
-     */
-    private TmfEventTypeManager() {
-        fEventTypes = new HashMap<>();
-    }
-
-    /**
-     * @return the TmfEventTypeManager singleton
-     */
-    public static synchronized TmfEventTypeManager getInstance() {
-        if (fEventTypeManager == null) {
-            fEventTypeManager = new TmfEventTypeManager();
-        }
-        return fEventTypeManager;
-    }
-
-    // ------------------------------------------------------------------------
-    // Operations
-    // ------------------------------------------------------------------------
-
-    /**
-     * Add a context:type pair to the available types
-     *
-     * @param context the target context
-     * @param type the type to add
-     */
-    public synchronized void add(final String context, final ITmfEventType type) {
-        HashMap<String, ITmfEventType> types = fEventTypes.get(context);
-        if (types == null) {
-            types = new HashMap<>();
-        }
-        types.put(type.getName(), type);
-        fEventTypes.put(context, types);
-    }
-
-    /**
-     * Return the list of currently defined contexts
-     *
-     * @return the list of contexts
-     */
-    public synchronized String[] getContexts() {
-        return fEventTypes.keySet().toArray(new String[fEventTypes.size()]);
-    }
-
-    /**
-     * Return the list of types defined for a given context
-     *
-     * @param context the context to look into
-     * @return the list of types defined for that context
-     * @since 3.0
-     */
-    public synchronized Set<ITmfEventType> getTypes(final String context) {
-        final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
-        if (types != null) {
-            return ImmutableSet.copyOf(types.values());
-        }
-        return ImmutableSet.of();
-    }
-
-    /**
-     * Return an event type
-     *
-     * @param context the context to look into
-     * @param typeId the type ID
-     * @return the corresponding type
-     */
-    public synchronized ITmfEventType getType(final String context, final String typeId) {
-        final HashMap<String, ITmfEventType> types = fEventTypes.get(context);
-        if (types != null) {
-            return types.get(typeId);
-        }
-        return null;
-    }
-
-    /**
-     * Remove the types associated to a context
-     *
-     * @param context the context to remove
-     */
-    public synchronized void clear(final String context) {
-        fEventTypes.remove(context);
-    }
-
-    /**
-     * Remove all contexts and types
-     */
-    public synchronized void clear() {
-        fEventTypes.clear();
-    }
-
-    // ------------------------------------------------------------------------
-    // Object
-    // ------------------------------------------------------------------------
-
-    @Override
-    @SuppressWarnings("nls")
-    public String toString() {
-        return "TmfEventTypeManager [fEventTypes=" + fEventTypes + "]";
-    }
-
-}
index 3416dad98f73acad33173ec22887e675b398f4d7..3852968cd6ba366c6bf101f29988f3e20f6d84a8 100644 (file)
@@ -24,8 +24,6 @@ import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
  */
 public abstract class CustomEventType extends TmfEventType {
 
-    private static String CONTEXT_ID = "CustomEventType"; //$NON-NLS-1$
-
     /**
      * Constructor
      *
@@ -33,7 +31,7 @@ public abstract class CustomEventType extends TmfEventType {
      *            Trace definition
      */
     public CustomEventType(CustomTraceDefinition definition) {
-        super(CONTEXT_ID, definition.definitionName, getRootField(definition));
+        super(definition.definitionName, getRootField(definition));
     }
 
     private static ITmfEventField getRootField(CustomTraceDefinition definition) {
index 36f365bce1e90a0d2b064072c954039a28dade98..13caea6ad5d48882b89c069bd73910fab773dd93 100644 (file)
@@ -54,6 +54,6 @@ public interface ITmfTraceWithPreDefinedEvents {
      *
      * @return The set of events that might be present in the trace
      */
-    Set<ITmfEventType> getContainedEventTypes();
+    Set<? extends ITmfEventType> getContainedEventTypes();
 
 }
index 403e429a5ea9560924f0ea9294c5caefa75ef6a4..a15c6fa208fe64db30aa37d5fef5edd8afaf85e3 100644 (file)
@@ -38,7 +38,7 @@ public final class TmfEventTypeCollectionHelper {
      * @return a set of the names of these events, if some names are clashing
      *         they will only appear once
      */
-    public static Set<String> getEventNames(Iterable<ITmfEventType> eventTypes) {
+    public static Set<String> getEventNames(Iterable<? extends ITmfEventType> eventTypes) {
         Set<String> retSet = new HashSet<>();
         for (ITmfEventType eventType : eventTypes) {
             retSet.add(eventType.getName());
index 1c3ef134e5ab22d371beaedda551d75bc0084bd7..fce78a763e809117e95ca54b6a26d34f118a61cb 100644 (file)
@@ -19,7 +19,6 @@ import static org.junit.Assert.assertNotNull;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.ctf.core.CtfTmfEventType;
-import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
 import org.junit.Test;
 
 /**
@@ -38,12 +37,11 @@ public class CtfTmfEventTypeTest {
     public void testCtfTmfEventType() {
         String eventName = "";
         ITmfEventField content = new TmfEventField("", null, new ITmfEventField[] {});
-        CtfTmfEventType result = new CtfTmfEventType(eventName, new TmfTraceStub(), content);
+        CtfTmfEventType result = new CtfTmfEventType(eventName, content);
 
         assertNotNull(result);
         assertEquals("", result.toString());
         assertEquals("", result.getName());
-        assertEquals("Ctf Event/null", result.getContext());
     }
 
     /**
@@ -52,7 +50,7 @@ public class CtfTmfEventTypeTest {
     @Test
     public void testToString() {
         ITmfEventField emptyField = new TmfEventField("", null, new ITmfEventField[] {});
-        CtfTmfEventType fixture = new CtfTmfEventType("", new TmfTraceStub() , emptyField);
+        CtfTmfEventType fixture = new CtfTmfEventType("" , emptyField);
 
         String result = fixture.toString();
 
index b9eba8521a675830c91d83bc797a7afd058510f3..fafda209e51f5d6301e3fc10d0eb9207f4d997b7 100644 (file)
@@ -200,7 +200,7 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testGetContainedEventTypes() {
-        Set<ITmfEventType> result = fixture.getContainedEventTypes();
+        Set<? extends ITmfEventType> result = fixture.getContainedEventTypes();
         assertNotNull(result);
         assertFalse(result.isEmpty());
     }
@@ -365,7 +365,7 @@ public class CtfTmfTraceTest {
      */
     @Test
     public void testEventLookup() {
-        Set<ITmfEventType> eventTypes = fixture.getContainedEventTypes();
+        Set<? extends ITmfEventType> eventTypes = fixture.getContainedEventTypes();
         Set<String> eventNames = TmfEventTypeCollectionHelper.getEventNames(eventTypes);
         assertTrue(eventNames.contains("sched_switch"));
         assertFalse(eventNames.contains("Sched_switch"));
index 3cc29a08841280f4b8d06842b50f43945aeae2ac..27b03cd5d20db688744339ba0a57b2c6672fa744 100644 (file)
@@ -150,11 +150,14 @@ public class CtfTmfEvent extends TmfEvent
 
     @Override
     public ITmfEventType getType() {
-        CtfTmfEventType ctfTmfEventType = CtfTmfEventType.get(getTrace(), fEventName);
-        if (ctfTmfEventType == null) {
-            /* Should only return null the first time */
-            ctfTmfEventType = new CtfTmfEventType(fEventName, getTrace(), getContent());
+        CtfTmfEventType ctfTmfEventType = new CtfTmfEventType(fEventName, getContent());
+
+        /* Register the event type in the owning trace, but only if there is one */
+        CtfTmfTrace trace = getTrace();
+        if (trace != null) {
+            trace.registerEventType(ctfTmfEventType);
         }
+
         return ctfTmfEventType;
     }
 
index c4274188f5ce4a4f0dde8794c2bb77189f7e0007..0f8462c9c245b01a9c21a3d32cb1c3f26cccf9f7 100644 (file)
@@ -13,37 +13,25 @@ package org.eclipse.tracecompass.tmf.ctf.core;
 
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventType;
-import org.eclipse.tracecompass.tmf.core.event.TmfEventTypeManager;
-import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 
 /**
  * The CTF extension of the TMF event type
  *
- * @version 1.0
  * @author Matthew khouzam
  */
 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
      *            The event name
-     * @param trace
-     *            the parent trace
      * @param content
      *            The event field
      * @since 3.0
      */
-    public CtfTmfEventType(String eventName, ITmfTrace trace, ITmfEventField content) {
-        super(computeContextName(trace), eventName, content);
+    public CtfTmfEventType(String eventName, ITmfEventField content) {
+        super(eventName, content);
     }
 
     /**
@@ -55,30 +43,4 @@ public class CtfTmfEventType extends TmfEventType {
     public String toString() {
         return getName();
     }
-
-    /**
-     * 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 String computeContextName(ITmfTrace trace) {
-        return CONTEXT_ID + "/" + (trace == null ? UNKNOWN_TRACE : trace.getPath()); //$NON-NLS-1$
-    }
 }
index 97976f0b117e93f7cf3a23226899abbe9a8f4a02..f230470faa80cc08890f32d3d3dc38fa185f610d 100644 (file)
@@ -17,6 +17,7 @@ package org.eclipse.tracecompass.tmf.ctf.core;
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -35,9 +36,7 @@ import org.eclipse.tracecompass.ctf.core.trace.CTFTraceReader;
 import org.eclipse.tracecompass.internal.tmf.ctf.core.Activator;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
-import org.eclipse.tracecompass.tmf.core.event.TmfEventTypeManager;
 import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
@@ -84,6 +83,9 @@ public class CtfTmfTrace extends TmfTrace
     // Fields
     // -------------------------------------------
 
+    private final Map<String, CtfTmfEventType> fContainedEventTypes =
+            Collections.synchronizedMap(new HashMap<String, CtfTmfEventType>());
+
     /* Reference to the CTF Trace */
     private CTFTrace fTrace;
 
@@ -134,7 +136,7 @@ public class CtfTmfTrace extends TmfTrace
              */
             try (CtfIterator iter = CtfIteratorManager.getIterator(this, ctx)) {
                 for (IEventDeclaration ied : iter.getEventDeclarations()) {
-                    CtfTmfEventType ctfTmfEventType = CtfTmfEventType.get(this, ied.getName());
+                    CtfTmfEventType ctfTmfEventType = fContainedEventTypes.get(ied.getName());
                     if (ctfTmfEventType == null) {
                         List<ITmfEventField> content = new ArrayList<>();
                         /* Should only return null the first time */
@@ -147,7 +149,8 @@ public class CtfTmfTrace extends TmfTrace
                                 content.toArray(new ITmfEventField[content.size()])
                                 );
 
-                        ctfTmfEventType = new CtfTmfEventType(ied.getName(), this, contentTree);
+                        ctfTmfEventType = new CtfTmfEventType(ied.getName(), contentTree);
+                        fContainedEventTypes.put(ctfTmfEventType.getName(), ctfTmfEventType);
                     }
                 }
             }
@@ -388,10 +391,19 @@ public class CtfTmfTrace extends TmfTrace
      * @since 3.0
      */
     @Override
-    public Set<ITmfEventType> getContainedEventTypes() {
-        TmfEventTypeManager instance = TmfEventTypeManager.getInstance();
-        Set<ITmfEventType> eventTypes = instance.getTypes(CtfTmfEventType.computeContextName(this));
-        return ImmutableSet.copyOf(eventTypes);
+    public Set<CtfTmfEventType> getContainedEventTypes() {
+        return ImmutableSet.copyOf(fContainedEventTypes.values());
+    }
+
+    /**
+     * Register an event type to this trace.
+     *
+     * Package-visible so that {@link CtfTmfEvent#getType} can call it.
+     *
+     * FIXME This could probably be made cleaner?
+     */
+    void registerEventType(CtfTmfEventType eventType) {
+        fContainedEventTypes.put(eventType.getName(), eventType);
     }
 
     // -------------------------------------------
index e232d53b63abce438ab26492473919c57a570913..0feefb8bbbd19500bdb7eff2b9c09356307b4e1b 100644 (file)
@@ -26,12 +26,6 @@ public class PcapEventType extends TmfEventType {
 
     private static final String EMPTY_STRING = ""; //$NON-NLS-1$
 
-    /**
-     * The default Context ID for a PcapEvent
-     */
-    @SuppressWarnings("null")
-    public static final @NonNull String DEFAULT_PCAP_CONTEXT_ID = Messages.PcapEventType_DefaultContext == null ? EMPTY_STRING : Messages.PcapEventType_DefaultContext;
-
     /**
      * The default Pcap Type ID for a PcapEvent
      */
@@ -54,7 +48,7 @@ public class PcapEventType extends TmfEventType {
      *            the root field
      */
     public PcapEventType(final String typeId, final @Nullable ITmfEventField root) {
-        super(DEFAULT_PCAP_CONTEXT_ID, typeId, root);
+        super(typeId, root);
     }
 
     /**
index ff6f844028cb2ce7609f7bfcbacfa32650353c99..ab73c197e440f199645c4ee3d72545891b1de765 100644 (file)
@@ -56,8 +56,6 @@ public class TmfBaseColumnDataProviderTest {
 
     private static final String fTestName = "ColumnDataProviderTest";
 
-    private final String fContext = "UnitTest";
-
     private final String fTypeId1 = "Some type1";
     private final String fTypeId2 = "Some type2";
 
@@ -72,9 +70,9 @@ public class TmfBaseColumnDataProviderTest {
 
     private final String fSource = "Source";
 
-    private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels));
-    private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels));
-    private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType3 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels));
 
     private final String fReference = "Some reference";
 
index 7a1ea5bd19569f1ce9c7607a9341312d5dff909a..b091a48e93f7760c4b4558ce200f95142507df2a 100755 (executable)
@@ -47,7 +47,6 @@ public class TmfBaseStatisticsDataTest {
 
     private static final String fTestName = "StatisticsDataTest";
 
-    private final String fContext = "UnitTest";
     private final String fTypeId1 = "Some type1";
     private final String fTypeId2 = "Some type2";
 
@@ -62,9 +61,9 @@ public class TmfBaseStatisticsDataTest {
 
     private final String fSource = "Source";
 
-    private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels));
-    private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels));
-    private final TmfEventType fType3 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType2 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType3 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels));
 
     private final String fReference = "Some reference";
 
index 2854fdb8b74d7523937ee35c3998ff22a433ebd5..299e2d39ead9fbf50e925d462c6421c577474bd3 100755 (executable)
@@ -45,7 +45,6 @@ public class TmfTreeContentProviderTest {
 
     private static final String fTestName = "TreeContentProviderTest";
 
-    private final String fContext = "UnitTest";
     private final String fTypeId1 = "Some type1";
     private final String fTypeId2 = "Some type2";
 
@@ -58,8 +57,8 @@ public class TmfTreeContentProviderTest {
 
     private final String fSource = "Source";
 
-    private final TmfEventType fType1 = new TmfEventType(fContext, fTypeId1, TmfEventField.makeRoot(fLabels));
-    private final TmfEventType fType2 = new TmfEventType(fContext, fTypeId2, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType1 = new TmfEventType(fTypeId1, TmfEventField.makeRoot(fLabels));
+    private final TmfEventType fType2 = new TmfEventType(fTypeId2, TmfEventField.makeRoot(fLabels));
 
     private final String fReference = "Some reference";
 
index 2d0d6841c77c2c2751b52c9328102a741582d28a..549f3cda36a0d7451677add68268392db5bc78f6 100644 (file)
@@ -85,7 +85,7 @@ public class TmfUml2SDTestTrace implements ITmfEventParser {
 
             String[] labels = {"sender", "receiver", "signal"};
 
-            TmfEventType tmfEventType = new TmfEventType("UnitTest", type, TmfEventField.makeRoot(labels));
+            TmfEventType tmfEventType = new TmfEventType(type, TmfEventField.makeRoot(labels));
 
             String content = "[";
             content += sender;
This page took 0.045488 seconds and 5 git commands to generate.