| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2014 É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.tracecompass.tmf.analysis.xml.core.model; |
| 14 | |
| 15 | import java.util.List; |
| 16 | |
| 17 | import org.eclipse.jdt.annotation.Nullable; |
| 18 | import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException; |
| 19 | import org.eclipse.tracecompass.statesystem.core.exceptions.StateValueTypeException; |
| 20 | import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException; |
| 21 | import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue; |
| 22 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; |
| 23 | |
| 24 | /** |
| 25 | * Interface that describe operations on a state value described in an XML |
| 26 | * element |
| 27 | * |
| 28 | * @author Geneviève Bastien |
| 29 | */ |
| 30 | public interface ITmfXmlStateValue { |
| 31 | |
| 32 | /** |
| 33 | * Get the current {@link ITmfStateValue} of this state value for an event. |
| 34 | * It does not increment the value and does not any other processing of the |
| 35 | * value. |
| 36 | * |
| 37 | * @param event |
| 38 | * The current event or <code>null</code> if no event is |
| 39 | * available. |
| 40 | * @return the {@link ITmfStateValue} |
| 41 | * @throws AttributeNotFoundException |
| 42 | * May be thrown by the state system during the query |
| 43 | */ |
| 44 | ITmfStateValue getValue(@Nullable ITmfEvent event) throws AttributeNotFoundException; |
| 45 | |
| 46 | /** |
| 47 | * Get the value of the event field that is the path of this state value |
| 48 | * |
| 49 | * @param event |
| 50 | * The current event |
| 51 | * @return the value of the event field |
| 52 | */ |
| 53 | ITmfStateValue getEventFieldValue(ITmfEvent event); |
| 54 | |
| 55 | /** |
| 56 | * Get the list of state attributes, the path to the state value |
| 57 | * |
| 58 | * @return the list of Attribute to have the path in the State System |
| 59 | */ |
| 60 | List<ITmfXmlStateAttribute> getAttributes(); |
| 61 | |
| 62 | /** |
| 63 | * Handles an event, by setting the value of the attribute described by the |
| 64 | * state attribute path in the state system. |
| 65 | * |
| 66 | * @param event |
| 67 | * The event to process |
| 68 | * @throws AttributeNotFoundException |
| 69 | * Pass through the exception it received |
| 70 | * @throws TimeRangeException |
| 71 | * Pass through the exception it received |
| 72 | * @throws StateValueTypeException |
| 73 | * Pass through the exception it received |
| 74 | */ |
| 75 | void handleEvent(ITmfEvent event) throws AttributeNotFoundException, StateValueTypeException, TimeRangeException; |
| 76 | |
| 77 | } |