From e600c338533841d2697a47d10892c0708c7fa7ce Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Wed, 22 Oct 2014 13:14:03 -0400 Subject: [PATCH] tmf: Axe the TmfEventTypeManager 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 Reviewed-on: https://git.eclipse.org/r/35354 Reviewed-by: Genevieve Bastien Tested-by: Genevieve Bastien --- .../gdbtrace/core/trace/DsfGdbAdaptor.java | 3 +- .../tmf/core/tests/event/AllTests.java | 1 - .../tmf/core/tests/event/TmfEventTest.java | 6 +- .../tests/event/TmfEventTypeManagerTest.java | 242 ------------------ .../core/tests/event/TmfEventTypeTest.java | 45 +--- .../mipmap/TmfMipmapStateProviderStub.java | 2 +- .../TmfAsyncSequenceDiagramEventTest.java | 4 +- .../TmfSyncSequenceDiagramEventTest.java | 4 +- .../tests/stubs/event/TmfEventTypeStub.java | 2 +- .../tests/stubs/trace/TmfEventParserStub.java | 2 +- .../stubs/trace/text/SyslogEventType.java | 3 +- .../stubs/trace/xml/TmfXmlTraceStub.java | 2 +- .../tmf/core/event/ITmfEventType.java | 10 - .../tmf/core/event/TmfEventType.java | 24 +- .../tmf/core/event/TmfEventTypeManager.java | 147 ----------- .../core/parsers/custom/CustomEventType.java | 4 +- .../trace/ITmfTraceWithPreDefinedEvents.java | 2 +- .../trace/TmfEventTypeCollectionHelper.java | 2 +- .../ctf/core/tests/CtfTmfEventTypeTest.java | 6 +- .../tmf/ctf/core/tests/CtfTmfTraceTest.java | 4 +- .../tmf/ctf/core/CtfTmfEvent.java | 11 +- .../tmf/ctf/core/CtfTmfEventType.java | 42 +-- .../tmf/ctf/core/CtfTmfTrace.java | 28 +- .../tmf/pcap/core/event/PcapEventType.java | 8 +- .../TmfBaseColumnDataProviderTest.java | 8 +- .../statistics/TmfBaseStatisticsDataTest.java | 7 +- .../TmfTreeContentProviderTest.java | 5 +- .../uml2sd/trace/TmfUml2SDTestTrace.java | 2 +- 28 files changed, 73 insertions(+), 553 deletions(-) delete mode 100644 org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeManagerTest.java delete mode 100644 org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventTypeManager.java diff --git a/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java b/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java index 551ebb0078..54e334e692 100644 --- a/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java +++ b/org.eclipse.tracecompass.gdbtrace.core/src/org/eclipse/tracecompass/internal/gdbtrace/core/trace/DsfGdbAdaptor.java @@ -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 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(); diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/AllTests.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/AllTests.java index 19f74e8912..785af11054 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/AllTests.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/AllTests.java @@ -25,7 +25,6 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ TmfEventFieldTest.class, TmfEventTest.class, - TmfEventTypeManagerTest.class, TmfEventTypeTest.class, TmfNanoTimestampTest.class, TmfSimpleTimestampTest.class, diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java index 625a973b69..7bec894d42 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTest.java @@ -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 index fe2b6ba51b..0000000000 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeManagerTest.java +++ /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 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 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 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 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()); - } - -} diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java index 4a81181d79..50f1f1df77 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/event/TmfEventTypeTest.java @@ -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 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 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 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 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()); } diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java index e356324e0e..81ed95de29 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/statesystem/mipmap/TmfMipmapStateProviderStub.java @@ -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; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java index fe093ca3c5..81b6e72e83 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfAsyncSequenceDiagramEventTest.java @@ -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; diff --git a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java index e0f1b29546..a52ca044b1 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java +++ b/org.eclipse.tracecompass.tmf.core.tests/src/org/eclipse/tracecompass/tmf/core/tests/uml2sd/TmfSyncSequenceDiagramEventTest.java @@ -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; diff --git a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfEventTypeStub.java b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfEventTypeStub.java index d280069ae0..6bab563d8d 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfEventTypeStub.java +++ b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/event/TmfEventTypeStub.java @@ -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); } } diff --git a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfEventParserStub.java b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfEventParserStub.java index 52ffb46cc8..a33ffbe0c0 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfEventParserStub.java +++ b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfEventParserStub.java @@ -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); } } diff --git a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java index 66768a24d5..e66963bd2a 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java +++ b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/text/SyslogEventType.java @@ -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)); } } diff --git a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java index d612b7b91f..d2b72c94b0 100644 --- a/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java +++ b/org.eclipse.tracecompass.tmf.core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/xml/TmfXmlTraceStub.java @@ -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()); diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java index 4a3a107d83..74b86ebadf 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/ITmfEventType.java @@ -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 */ diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java index 342503cf48..d0444e96d2 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventType.java @@ -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 index 596dbfb6d3..0000000000 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/TmfEventTypeManager.java +++ /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> 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 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 getTypes(final String context) { - final HashMap 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 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 + "]"; - } - -} diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java index 3416dad98f..3852968cd6 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/parsers/custom/CustomEventType.java @@ -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) { diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java index 36f365bce1..13caea6ad5 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/ITmfTraceWithPreDefinedEvents.java @@ -54,6 +54,6 @@ public interface ITmfTraceWithPreDefinedEvents { * * @return The set of events that might be present in the trace */ - Set getContainedEventTypes(); + Set getContainedEventTypes(); } diff --git a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java index 403e429a5e..a15c6fa208 100644 --- a/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java +++ b/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/trace/TmfEventTypeCollectionHelper.java @@ -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 getEventNames(Iterable eventTypes) { + public static Set getEventNames(Iterable eventTypes) { Set retSet = new HashSet<>(); for (ITmfEventType eventType : eventTypes) { retSet.add(eventType.getName()); diff --git a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfEventTypeTest.java b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfEventTypeTest.java index 1c3ef134e5..fce78a763e 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfEventTypeTest.java +++ b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfEventTypeTest.java @@ -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(); diff --git a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfTraceTest.java b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfTraceTest.java index b9eba8521a..fafda209e5 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfTraceTest.java +++ b/org.eclipse.tracecompass.tmf.ctf.core.tests/src/org/eclipse/tracecompass/tmf/ctf/core/tests/CtfTmfTraceTest.java @@ -200,7 +200,7 @@ public class CtfTmfTraceTest { */ @Test public void testGetContainedEventTypes() { - Set result = fixture.getContainedEventTypes(); + Set result = fixture.getContainedEventTypes(); assertNotNull(result); assertFalse(result.isEmpty()); } @@ -365,7 +365,7 @@ public class CtfTmfTraceTest { */ @Test public void testEventLookup() { - Set eventTypes = fixture.getContainedEventTypes(); + Set eventTypes = fixture.getContainedEventTypes(); Set eventNames = TmfEventTypeCollectionHelper.getEventNames(eventTypes); assertTrue(eventNames.contains("sched_switch")); assertFalse(eventNames.contains("Sched_switch")); diff --git a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEvent.java b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEvent.java index 3cc29a0884..27b03cd5d2 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEvent.java +++ b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEvent.java @@ -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; } diff --git a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEventType.java b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEventType.java index c4274188f5..0f8462c9c2 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEventType.java +++ b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfEventType.java @@ -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$ - } } diff --git a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java index 97976f0b11..f230470faa 100644 --- a/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java +++ b/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/CtfTmfTrace.java @@ -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 fContainedEventTypes = + Collections.synchronizedMap(new HashMap()); + /* 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 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 getContainedEventTypes() { - TmfEventTypeManager instance = TmfEventTypeManager.getInstance(); - Set eventTypes = instance.getTypes(CtfTmfEventType.computeContextName(this)); - return ImmutableSet.copyOf(eventTypes); + public Set 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); } // ------------------------------------------- diff --git a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java index e232d53b63..0feefb8bbb 100644 --- a/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java +++ b/org.eclipse.tracecompass.tmf.pcap.core/src/org/eclipse/tracecompass/internal/tmf/pcap/core/event/PcapEventType.java @@ -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); } /** diff --git a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index ff6f844028..ab73c197e4 100644 --- a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -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"; diff --git a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java index 7a1ea5bd19..b091a48e93 100755 --- a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java @@ -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"; diff --git a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java index 2854fdb8b7..299e2d39ea 100755 --- a/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/src/org/eclipse/tracecompass/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java @@ -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"; diff --git a/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java b/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java index 2d0d6841c7..549f3cda36 100644 --- a/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java +++ b/org.eclipse.tracecompass.tmf.ui.tests/widgetStubs/org/eclipse/tracecompass/tmf/ui/tests/uml2sd/trace/TmfUml2SDTestTrace.java @@ -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; -- 2.34.1