Map<String, String> retMap = new LinkedHashMap<String, String>();
if (event instanceof ControlFlowEvent) {
ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
int tid = entry.getThreadId();
try {
return;
}
ControlFlowEntry entry = (ControlFlowEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
int status = ((ControlFlowEvent) event).getStatus();
if (status != StateValues.PROCESS_STATUS_RUN_SYSCALL) {
return;
}
if (trace instanceof CtfKernelTrace) {
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) trace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
if (time >= ssq.getStartTime() && time <= ssq.getCurrentEndTime()) {
List<Integer> currentThreadQuarks = ssq.getQuarks(Attributes.CPUS, "*", Attributes.CURRENT_THREAD); //$NON-NLS-1$
for (int currentThreadQuark : currentThreadQuarks) {
if (aTrace instanceof CtfKernelTrace) {
ArrayList<ControlFlowEntry> entryList = new ArrayList<ControlFlowEntry>();
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
}
private void buildStatusEvents(ITmfTrace trace, ControlFlowEntry entry, IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
long start = ssq.getStartTime();
long end = ssq.getCurrentEndTime() + 1;
long resolution = Math.max(1, (end - start) / fDisplayWidth);
if (realEnd <= realStart) {
return null;
}
- ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
List<ITimeEvent> eventList = null;
try {
int statusQuark = ssq.getQuarkRelative(entry.getThreadQuark(), Attributes.STATUS);
if (status == StateValues.CPU_STATUS_IRQ) {
// In IRQ state get the IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
int cpu = entry.getId();
try {
} else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
// In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
int cpu = entry.getId();
try {
} else if (status == StateValues.CPU_STATUS_RUN_USERMODE || status == StateValues.CPU_STATUS_RUN_SYSCALL){
// In running state get the current tid
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
try {
retMap.put(Messages.ResourcesView_attributeHoverTime, Utils.formatTime(hoverTime, TimeFormat.CALENDAR, Resolution.NANOSEC));
return;
}
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
- ITmfStateSystem ss = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ss = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
long time = event.getTime();
try {
while (time < event.getTime() + event.getDuration()) {
}
long resolution = Math.max(1, (fZoomEndTime - fZoomStartTime) / fDisplayWidth);
for (TraceEntry traceEntry : fZoomEntryList) {
- if (!traceEntry.fKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID).waitUntilBuilt()) {
+ if (!traceEntry.fKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID).waitUntilBuilt()) {
return;
}
for (ITimeGraphEntry child : traceEntry.getChildren()) {
}
if (aTrace instanceof CtfKernelTrace) {
CtfKernelTrace ctfKernelTrace = (CtfKernelTrace) aTrace;
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
if (!ssq.waitUntilBuilt()) {
return;
}
return;
}
CtfKernelTrace ctfKernelTrace = traceEntry.getTrace();
- ITmfStateSystem ssq = ctfKernelTrace.getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = ctfKernelTrace.getStateSystems().get(CtfKernelTrace.STATE_ID);
long startTime = ssq.getStartTime();
long endTime = ssq.getCurrentEndTime() + 1;
long resolution = (endTime - startTime) / fDisplayWidth;
private static List<ITimeEvent> getEventList(ResourcesEntry entry,
long startTime, long endTime, long resolution, boolean includeNull,
IProgressMonitor monitor) {
- ITmfStateSystem ssq = entry.getTrace().getStateSystem(CtfKernelTrace.STATE_ID);
+ ITmfStateSystem ssq = entry.getTrace().getStateSystems().get(CtfKernelTrace.STATE_ID);
final long realStart = Math.max(startTime, ssq.getStartTime());
final long realEnd = Math.min(endTime, ssq.getCurrentEndTime() + 1);
if (realEnd <= realStart) {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.Collection;
import java.util.Vector;
import org.eclipse.core.resources.IFile;
@Test
public void testGetStateSystem() {
/* There should not be any experiment-specific state system */
- ITmfStateSystem ss = fExperiment.getStateSystem("something");
+ ITmfStateSystem ss = fExperiment.getStateSystems().get("something");
assertNull(ss);
}
- @Test
- public void testListStateSystem() {
- Collection<String> sss = fExperiment.listStateSystems();
- assertNotNull(sss);
- assertEquals(0, sss.size());
- }
-
// ------------------------------------------------------------------------
// seekEvent by location
// ------------------------------------------------------------------------
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.Collection;
+import java.util.Map;
import java.util.Vector;
import org.eclipse.core.runtime.FileLocator;
@Test
public void testGetStateSystem() {
/* There should be no state system registered so far */
- ITmfStateSystem ss = fTrace.getStateSystem("something");
+ ITmfStateSystem ss = fTrace.getStateSystems().get("something");
assertNull(ss);
}
- @Test
- public void testListStateSystem() {
- Collection<String> sss = fTrace.listStateSystems();
- assertNotNull(sss);
- assertEquals(0, sss.size());
+ /**
+ * Make sure the returned map is unmodifiable.
+ */
+ @Test(expected=UnsupportedOperationException.class)
+ public void testGetStateSystem_readOnly() {
+ Map<String, ITmfStateSystem> sss = fTrace.getStateSystems();
+ sss.put("something", null);
}
// ------------------------------------------------------------------------
package org.eclipse.linuxtools.tmf.core.trace;
-import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
public ITmfStatistics getStatistics();
/**
- * Retrieve a state system that belongs to this trace
+ * Return the map of state systems associated with this trace.
*
- * @param id
- * The ID of the state system to retrieve.
- * @return The state system that is associated with this trace and ID, or
- * 'null' if such a match doesn't exist.
- * @since 2.0
- */
- public ITmfStateSystem getStateSystem(String id);
-
- /**
- * Return the list of existing state systems registered with this trace.
+ * This view should be read-only (implementations should use
+ * {@link Collections#unmodifiableMap}).
*
- * @return A Collection view of the available state systems. The collection
- * could be empty, but should not be null.
+ * @return The map of state systems
* @since 2.0
*/
- public Collection<String> listStateSystems();
+ public Map<String, ITmfStateSystem> getStateSystems();
/**
* If a state system is not build by the trace itself, it's possible to
package org.eclipse.linuxtools.tmf.core.trace;
import java.io.File;
-import java.util.Collection;
-import java.util.HashMap;
+import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.Map;
import org.eclipse.core.resources.IResource;
* @since 2.0
*/
protected final Map<String, ITmfStateSystem> fStateSystems =
- new HashMap<String, ITmfStateSystem>();
+ new LinkedHashMap<String, ITmfStateSystem>();
// ------------------------------------------------------------------------
// Construction
* @since 2.0
*/
@Override
- public final ITmfStateSystem getStateSystem(String id) {
- return fStateSystems.get(id);
- }
-
- /**
- * @since 2.0
- */
- @Override
- public final Collection<String> listStateSystems() {
- return fStateSystems.keySet();
+ public final Map<String, ITmfStateSystem> getStateSystems() {
+ return Collections.unmodifiableMap(fStateSystems);
}
/**