| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2009, 2011, 2012 Ericsson |
| 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 | * Francois Chouinard - Initial API and implementation |
| 11 | * Francois Chouinard - Updated as per TMF Trace Model 1.0 |
| 12 | *******************************************************************************/ |
| 13 | |
| 14 | package org.eclipse.linuxtools.tmf.core.trace; |
| 15 | |
| 16 | import java.io.FileNotFoundException; |
| 17 | |
| 18 | import org.eclipse.core.resources.IProject; |
| 19 | import org.eclipse.core.resources.IResource; |
| 20 | import org.eclipse.linuxtools.tmf.core.component.ITmfComponent; |
| 21 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
| 22 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
| 23 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; |
| 24 | |
| 25 | /** |
| 26 | * <b><u>ITmfTrace</u></b> |
| 27 | * <p> |
| 28 | * The basic event trace structure in the TMF. |
| 29 | */ |
| 30 | public interface ITmfTrace<T extends ITmfEvent> extends ITmfComponent { |
| 31 | |
| 32 | // ------------------------------------------------------------------------ |
| 33 | // Constants |
| 34 | // ------------------------------------------------------------------------ |
| 35 | |
| 36 | // ------------------------------------------------------------------------ |
| 37 | // Initializers |
| 38 | // ------------------------------------------------------------------------ |
| 39 | |
| 40 | // initTrace variants |
| 41 | public void initTrace(String name, String path, Class<T> eventType, int pageSize) throws FileNotFoundException; |
| 42 | |
| 43 | public void indexTrace(boolean waitForCompletion); |
| 44 | |
| 45 | // Trace type validation |
| 46 | public boolean validate(IProject project, String path); |
| 47 | |
| 48 | // ------------------------------------------------------------------------ |
| 49 | // Getters |
| 50 | // ------------------------------------------------------------------------ |
| 51 | |
| 52 | /** |
| 53 | * @return the trace path |
| 54 | */ |
| 55 | public String getPath(); |
| 56 | |
| 57 | /** |
| 58 | * @return the trace name |
| 59 | */ |
| 60 | @Override |
| 61 | public String getName(); |
| 62 | |
| 63 | /** |
| 64 | * @return the cache size |
| 65 | */ |
| 66 | public int getCacheSize(); |
| 67 | |
| 68 | /** |
| 69 | * @return the number of events in the trace |
| 70 | */ |
| 71 | public long getNbEvents(); |
| 72 | |
| 73 | /** |
| 74 | * Trace time range accesses |
| 75 | */ |
| 76 | public TmfTimeRange getTimeRange(); |
| 77 | |
| 78 | public ITmfTimestamp getStartTime(); |
| 79 | |
| 80 | public ITmfTimestamp getEndTime(); |
| 81 | |
| 82 | /** |
| 83 | * @return the streaming interval in ms (0 if not streaming) |
| 84 | */ |
| 85 | public long getStreamingInterval(); |
| 86 | |
| 87 | // ------------------------------------------------------------------------ |
| 88 | // Seek operations |
| 89 | // ------------------------------------------------------------------------ |
| 90 | |
| 91 | /** |
| 92 | * Positions the trace at the first event with the specified timestamp or index (i.e. the nth event in the trace). |
| 93 | * |
| 94 | * Returns a context which can later be used to read the event. |
| 95 | * |
| 96 | * @param location |
| 97 | * @return a context object for subsequent reads |
| 98 | */ |
| 99 | public ITmfContext seekLocation(ITmfLocation<?> location); |
| 100 | |
| 101 | public ITmfContext seekEvent(ITmfTimestamp timestamp); |
| 102 | |
| 103 | public ITmfContext seekEvent(long rank); |
| 104 | |
| 105 | /** |
| 106 | * Positions the trace at the event located at the specified ratio. |
| 107 | * |
| 108 | * Returns a context which can later be used to read the event. |
| 109 | * |
| 110 | * @param ratio |
| 111 | * a floating-point number between 0.0 (beginning) and 1.0 (end) |
| 112 | * @return a context object for subsequent reads |
| 113 | */ |
| 114 | public ITmfContext seekLocation(double ratio); |
| 115 | |
| 116 | // ------------------------------------------------------------------------ |
| 117 | // Read operations |
| 118 | // ------------------------------------------------------------------------ |
| 119 | |
| 120 | /** |
| 121 | * Return the event pointed by the supplied context (or null if no event left) and updates the context to the next |
| 122 | * event. |
| 123 | * |
| 124 | * @return the next event in the stream |
| 125 | */ |
| 126 | public ITmfEvent getNextEvent(ITmfContext context); |
| 127 | |
| 128 | /** |
| 129 | * Return the event pointed by the supplied context (or null if no event left) and *does not* update the context. |
| 130 | * |
| 131 | * @return the next event in the stream |
| 132 | */ |
| 133 | public ITmfEvent parseEvent(ITmfContext context); |
| 134 | |
| 135 | |
| 136 | // ------------------------------------------------------------------------ |
| 137 | // misc |
| 138 | // ------------------------------------------------------------------------ |
| 139 | |
| 140 | /** |
| 141 | * Returns the ratio corresponding to the specified location. |
| 142 | * |
| 143 | * @param location |
| 144 | * a trace location |
| 145 | * @return a floating-point number between 0.0 (beginning) and 1.0 (end) |
| 146 | */ |
| 147 | public double getLocationRatio(ITmfLocation<?> location); |
| 148 | |
| 149 | public ITmfLocation<?> getCurrentLocation(); |
| 150 | |
| 151 | /** |
| 152 | * Returns the rank of the first event with the requested timestamp. If none, returns the index of the next event |
| 153 | * (if any). |
| 154 | * |
| 155 | * @param timestamp the requested event timestamp |
| 156 | * @return the corresponding event rank |
| 157 | */ |
| 158 | public long getRank(ITmfTimestamp timestamp); |
| 159 | |
| 160 | /** |
| 161 | * Set the resource used for persistent properties on this trace |
| 162 | * @param resource the properties resource |
| 163 | */ |
| 164 | public void setResource(IResource resource); |
| 165 | |
| 166 | /** |
| 167 | * Get the resource used for persistent properties on this trace |
| 168 | * @return the properties resource or null if none is set |
| 169 | */ |
| 170 | public IResource getResource(); |
| 171 | |
| 172 | } |