Commit | Line | Data |
---|---|---|
a52fde77 | 1 | /******************************************************************************* |
61759503 | 2 | * Copyright (c) 2012, 2013 Ericsson |
a52fde77 AM |
3 | * Copyright (c) 2010, 2011 École Polytechnique de Montréal |
4 | * Copyright (c) 2010, 2011 Alexandre Montplaisir <alexandre.montplaisir@gmail.com> | |
5df842b3 | 5 | * |
a52fde77 AM |
6 | * All rights reserved. This program and the accompanying materials are |
7 | * made available under the terms of the Eclipse Public License v1.0 which | |
8 | * accompanies this distribution, and is available at | |
9 | * http://www.eclipse.org/legal/epl-v10.html | |
5df842b3 | 10 | * |
a52fde77 AM |
11 | *******************************************************************************/ |
12 | ||
18ab1d18 | 13 | package org.eclipse.linuxtools.tmf.core.statesystem; |
a52fde77 | 14 | |
2c2f900e AM |
15 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
16 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; | |
17 | ||
a52fde77 AM |
18 | /** |
19 | * This is the interface used to define the "state change input", which is the | |
20 | * main type of input that goes in the state system. | |
5df842b3 | 21 | * |
a52fde77 AM |
22 | * Usually a state change input, also called "state provider" is the piece of |
23 | * the pipeline which converts trace events to state changes. | |
5df842b3 | 24 | * |
2cb26548 | 25 | * @author Alexandre Montplaisir |
0fe46f2a | 26 | * @since 2.0 |
a52fde77 | 27 | */ |
0fe46f2a | 28 | public interface ITmfStateProvider { |
a52fde77 | 29 | |
a96cc6be AM |
30 | /** |
31 | * Special state provider version number that will tell the backend to | |
32 | * ignore the version check and open an existing file even if the versions | |
33 | * don't match. | |
34 | * @since 2.0 | |
35 | */ | |
cb42195c | 36 | static final int IGNORE_PROVIDER_VERSION = -42; |
a96cc6be AM |
37 | |
38 | /** | |
39 | * Event handler plugins should provide a version number. This is used to | |
40 | * determine if a potential existing file can be re-opened later (if the | |
41 | * versions in the file and in the viewer match), or if the file should be | |
42 | * rebuilt from scratch (if the versions don't match). | |
43 | * | |
44 | * @return The version number of the input plugin | |
45 | * @since 2.0 | |
46 | */ | |
57a2a5ca | 47 | int getVersion(); |
a96cc6be | 48 | |
2c2f900e AM |
49 | /** |
50 | * Get the trace with which this state input plugin is associated. | |
5df842b3 | 51 | * |
2c2f900e AM |
52 | * @return The associated trace |
53 | */ | |
57a2a5ca | 54 | ITmfTrace getTrace(); |
5df842b3 | 55 | |
a52fde77 AM |
56 | /** |
57 | * Return the start time of this "state change input", which is normally the | |
58 | * start time of the originating trace (or it can be the time of the first | |
59 | * state-changing event). | |
5df842b3 | 60 | * |
a52fde77 AM |
61 | * @return The start time |
62 | */ | |
57a2a5ca | 63 | long getStartTime(); |
a52fde77 | 64 | |
2c2f900e AM |
65 | /** |
66 | * Method for the input plugin to specify which type of events it expects. | |
67 | * This will guarantee that all events it receives via processEvent() are | |
68 | * indeed of the given type, so it should be safe to cast to that type. | |
5df842b3 | 69 | * |
79044a66 AM |
70 | * @return The expected Class of the event. Only events of this class (and |
71 | * valid subclasses) will be handled. | |
72 | * @since 2.0 | |
2c2f900e | 73 | */ |
57a2a5ca | 74 | Class<? extends ITmfEvent> getExpectedEventType(); |
2c2f900e | 75 | |
a52fde77 AM |
76 | /** |
77 | * Assign the target state system where this SCI will insert its state | |
78 | * changes. Because of dependencies issues, this can normally not be done at | |
79 | * the constructor. | |
5df842b3 | 80 | * |
a52fde77 | 81 | * This needs to be called before .run()! |
5df842b3 | 82 | * |
d26f90fd | 83 | * @param ssb |
5df842b3 AM |
84 | * Target state system for the state changes generated by this |
85 | * input plugin | |
f1f86dfb | 86 | * @since 2.0 |
a52fde77 | 87 | */ |
57a2a5ca | 88 | void assignTargetStateSystem(ITmfStateSystemBuilder ssb); |
2c2f900e | 89 | |
7e634be6 AM |
90 | /** |
91 | * Return the currently assigned target state system. | |
92 | * | |
93 | * @return Reference to the currently assigned state system, or null if no | |
94 | * SS is assigned yet | |
95 | * @since 2.0 | |
96 | */ | |
57a2a5ca | 97 | ITmfStateSystem getAssignedStateSystem(); |
7e634be6 | 98 | |
2c2f900e AM |
99 | /** |
100 | * Send an event to this input plugin for processing. The implementation | |
101 | * should check the contents, and call the state-modifying methods of its | |
102 | * IStateSystemBuilder object accordingly. | |
5df842b3 | 103 | * |
2c2f900e AM |
104 | * @param event |
105 | * The event (which should be safe to cast to the | |
106 | * expectedEventType) that has to be processed. | |
107 | */ | |
57a2a5ca | 108 | void processEvent(ITmfEvent event); |
2c2f900e | 109 | |
e96ab5c4 AM |
110 | /** |
111 | * Provide a non-initialized copy of this state input plugin. You will need | |
112 | * to call {@link #assignTargetStateSystem} on it to assign its target. | |
113 | * | |
114 | * @return A new state change input object, of the same type, but without an | |
115 | * assigned target state system | |
116 | * @since 2.0 | |
117 | */ | |
57a2a5ca | 118 | ITmfStateProvider getNewInstance(); |
e96ab5c4 | 119 | |
2c2f900e AM |
120 | /** |
121 | * Indicate to the state history building process that we are done (for now), | |
122 | * and that it should close its current history. | |
123 | */ | |
57a2a5ca | 124 | void dispose(); |
a52fde77 | 125 | } |