1 /*******************************************************************************
2 * Copyright (c) 2013, 2015 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.analysis
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import org
.eclipse
.jdt
.annotation
.NonNull
;
18 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystemBuilder
;
19 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.AttributeNotFoundException
;
20 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateValueTypeException
;
21 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.TimeRangeException
;
22 import org
.eclipse
.tracecompass
.statesystem
.core
.statevalue
.TmfStateValue
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.event
.TmfEvent
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.AbstractTmfStateProvider
;
26 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.ITmfStateProvider
;
27 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
30 * Stub test provider for test state system analysis module
32 * @author Geneviève Bastien
34 public class TestStateSystemProvider
extends AbstractTmfStateProvider
{
36 private static final int VERSION
= 1;
37 private final String fString
= "[]";
38 private int fCount
= 0;
44 * The LTTng 2.0 kernel trace directory
46 public TestStateSystemProvider(@NonNull ITmfTrace trace
) {
47 super(trace
, TmfEvent
.class, "Stub State System");
51 public int getVersion() {
56 public ITmfStateProvider
getNewInstance() {
57 return new TestStateSystemProvider(this.getTrace());
61 protected void eventHandle(ITmfEvent event
) {
62 ITmfStateSystemBuilder ss
= checkNotNull(getStateSystemBuilder());
64 /* Just need something to fill the state system */
65 if (fString
.equals(event
.getContent().getValue())) {
67 int quarkId
= ss
.getQuarkAbsoluteAndAdd("String");
68 int quark
= ss
.getQuarkRelativeAndAdd(quarkId
, fString
);
69 ss
.modifyAttribute(event
.getTimestamp().getValue(), TmfStateValue
.newValueInt(fCount
++), quark
);
70 } catch (TimeRangeException e
) {
72 } catch (AttributeNotFoundException e
) {
74 } catch (StateValueTypeException e
) {