tmf: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core / src / org / eclipse / linuxtools / tmf / core / synchronization / SynchronizationAlgorithm.java
1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 implementation and API
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.core.synchronization;
14
15 import java.io.Serializable;
16 import java.util.Map;
17
18 import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventDependency;
19 import org.eclipse.linuxtools.tmf.core.event.matching.TmfEventMatches;
20 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
21
22 /**
23 * Abstract class for synchronization algorithm
24 *
25 * @author Geneviève Bastien
26 * @since 3.0
27 */
28 public abstract class SynchronizationAlgorithm extends TmfEventMatches implements Serializable {
29
30 private static final long serialVersionUID = -3083906749528872196L;
31
32 /**
33 * Quality of the result obtained by the synchronization algorithm
34 */
35 public enum SyncQuality {
36 /**
37 * Algorithm returned a result satisfying all hypothesis for the
38 * algorithm
39 */
40 ACCURATE,
41 /**
42 * Best effort of the algorithm
43 */
44 APPROXIMATE,
45 /**
46 * There is communication only in one direction
47 */
48 INCOMPLETE,
49 /**
50 * No communication between two traces
51 */
52 ABSENT,
53 /**
54 * Hypothesis of the algorithm are not satisfied for some reason
55 */
56 FAIL
57 }
58
59 @Override
60 public void addMatch(TmfEventDependency match) {
61 super.addMatch(match);
62 processMatch(match);
63 }
64
65 /**
66 * Function for synchronization algorithm to do something with the received
67 * match
68 *
69 * @param match
70 * The match of events
71 */
72 protected abstract void processMatch(TmfEventDependency match);
73
74 /**
75 * Returns a map of staticstics relating to this algorithm. Those stats
76 * could be used to be displayed in a view for example.
77 *
78 * @return A map of statistics for this algorithm
79 */
80 public abstract Map<String, Map<String, Object>> getStats();
81
82 /**
83 * Returns a timestamp transformation algorithm
84 *
85 * @param trace
86 * The trace to get the transform for
87 * @return The timestamp transformation formula
88 */
89 public abstract ITmfTimestampTransform getTimestampTransform(ITmfTrace trace);
90
91 /**
92 * Returns a timestamp transformation algorithm
93 *
94 * @param hostId
95 * The host ID of the trace to get the transform for
96 * @return The timestamp transformation formula
97 */
98 public abstract ITmfTimestampTransform getTimestampTransform(String hostId);
99
100 /**
101 * Gets the quality of the synchronization between two given traces
102 *
103 * @param trace1
104 * First trace
105 * @param trace2
106 * Second trace
107 * @return The synchronization quality
108 */
109 public abstract SyncQuality getSynchronizationQuality(ITmfTrace trace1, ITmfTrace trace2);
110
111 /**
112 * Returns whether a given trace has a synchronization formula that is not
113 * identity. This function returns true if the synchronization algorithm has
114 * failed for some reason
115 *
116 * @param hostId
117 * The host ID of the trace
118 * @return true if trace has formula
119 */
120 public abstract boolean isTraceSynced(String hostId);
121
122 }
This page took 0.035619 seconds and 5 git commands to generate.