| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2013 École Polytechnique de Montréal |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Geneviève Bastien - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.tmf.tests.stubs.analysis; |
| 14 | |
| 15 | import org.eclipse.linuxtools.statesystem.core.exceptions.AttributeNotFoundException; |
| 16 | import org.eclipse.linuxtools.statesystem.core.exceptions.StateValueTypeException; |
| 17 | import org.eclipse.linuxtools.statesystem.core.exceptions.TimeRangeException; |
| 18 | import org.eclipse.linuxtools.statesystem.core.statevalue.TmfStateValue; |
| 19 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
| 20 | import org.eclipse.linuxtools.tmf.core.event.TmfEvent; |
| 21 | import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider; |
| 22 | import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider; |
| 23 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
| 24 | |
| 25 | /** |
| 26 | * Stub test provider for test state system analysis module |
| 27 | * |
| 28 | * @author Geneviève Bastien |
| 29 | */ |
| 30 | public class TestStateSystemProvider extends AbstractTmfStateProvider { |
| 31 | |
| 32 | private static final int VERSION = 1; |
| 33 | private final String fString = "[]"; |
| 34 | private int fCount = 0; |
| 35 | |
| 36 | /** |
| 37 | * Constructor |
| 38 | * |
| 39 | * @param trace |
| 40 | * The LTTng 2.0 kernel trace directory |
| 41 | */ |
| 42 | public TestStateSystemProvider(ITmfTrace trace) { |
| 43 | super(trace, TmfEvent.class, "Stub State System"); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public int getVersion() { |
| 48 | return VERSION; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public ITmfStateProvider getNewInstance() { |
| 53 | return new TestStateSystemProvider(this.getTrace()); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | protected void eventHandle(ITmfEvent event) { |
| 58 | /* Just need something to fill the state system */ |
| 59 | if (fString.equals(event.getContent().getValue())) { |
| 60 | try { |
| 61 | int quarkId = ss.getQuarkAbsoluteAndAdd("String"); |
| 62 | int quark = ss.getQuarkRelativeAndAdd(quarkId, fString); |
| 63 | ss.modifyAttribute(event.getTimestamp().getValue(), TmfStateValue.newValueInt(fCount++), quark); |
| 64 | } catch (TimeRangeException e) { |
| 65 | |
| 66 | } catch (AttributeNotFoundException e) { |
| 67 | |
| 68 | } catch (StateValueTypeException e) { |
| 69 | |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | } |