Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui.tests / src / org / eclipse / linuxtools / tmf / ui / tests / views / uml2sd / impl / Uml2SDSignalValidator.java
1 /*******************************************************************************
2 * Copyright (c) 2011 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.linuxtools.tmf.ui.tests.views.uml2sd.impl;
13
14 import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
15 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
16 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
17 import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
18 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
19 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
20 import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
21 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
22
23 /**
24 * Class to implement that certain signals are sent as well as are sent with correct content.
25 */
26 public class Uml2SDSignalValidator extends TmfComponent implements IUml2SdSignalValidator {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 private int fSignalDepth = 0;
32 private boolean fIsSignalReceived = false;
33 private boolean fIsSignalError = false;
34 private boolean fIsSourceError = false;
35 private boolean fIsCurrentTimeError = false;
36 private boolean fIsRangeError = false;
37
38 private Object fSource = null;
39 private TmfTimestamp fCurrentTimestamp = null;
40 private TmfTimeRange fCurrentTimeRange = null;
41
42 // ------------------------------------------------------------------------
43 // Constructor
44 // ------------------------------------------------------------------------
45 public Uml2SDSignalValidator() {
46 }
47
48 // ------------------------------------------------------------------------
49 // Operations
50 // ------------------------------------------------------------------------
51 @TmfSignalHandler
52 public void synchToTime(TmfTimeSynchSignal signal) {
53 // Set results so that it can be validated in the test case
54 setSignalReceived(true);
55 setSourceError(getSource() != signal.getSource());
56 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
57 }
58
59 @TmfSignalHandler
60 public void synchToTimeRange(TmfRangeSynchSignal signal) {
61 // Set results so that it can be validated in the test case
62 setSignalReceived(true);
63 setSourceError(getSource() != signal.getSource());
64 setCurrentTimeError(!getCurrentTime().equals(signal.getCurrentTime()));
65 setRangeError(!getCurrentRange().equals(signal.getCurrentRange()));
66 }
67
68 @TmfSignalHandler
69 public void startSynch(TmfStartSynchSignal signal) {
70 fSignalDepth++;
71 // make sure that the signal which is send by the loader class is not handled by the loader class
72 // after receiving it. i.e. it must not trigger a another signal
73
74 // Set results so that it can be validated in the test case
75 setSignalError(fSignalDepth > 1);
76 }
77
78 @TmfSignalHandler
79 public void endSynch(TmfEndSynchSignal signal) {
80 fSignalDepth = fSignalDepth > 0 ? fSignalDepth - 1 : 0;
81 }
82
83 @Override
84 public boolean isSignalReceived() {
85 return fIsSignalReceived;
86 }
87
88 @Override
89 public void setSignalReceived(boolean received) {
90 fIsSignalReceived = received;
91 }
92
93 @Override
94 public boolean isSourceError() {
95 return fIsSourceError;
96 }
97
98 @Override
99 public void setSourceError(boolean fIsSourceError) {
100 this.fIsSourceError = fIsSourceError;
101 }
102
103 @Override
104 public boolean isCurrentTimeError() {
105 return fIsCurrentTimeError;
106 }
107
108 @Override
109 public void setCurrentTimeError(boolean fIsCurrentTimeError) {
110 this.fIsCurrentTimeError = fIsCurrentTimeError;
111 }
112
113 @Override
114 public boolean isRangeError() {
115 return fIsRangeError;
116 }
117
118 @Override
119 public void setRangeError(boolean fIsRangeError) {
120 this.fIsRangeError = fIsRangeError;
121 }
122
123 @Override
124 public boolean isSignalError() {
125 return fIsSignalError;
126 }
127
128 @Override
129 public void setSignalError(boolean fIsSignalError) {
130 this.fIsSignalError = fIsSignalError;
131 }
132
133 @Override
134 public Object getSource() {
135 return fSource;
136 }
137
138 @Override
139 public void setSource(Object source) {
140 fSource = source;
141 }
142
143 @Override
144 public TmfTimestamp getCurrentTime() {
145 return fCurrentTimestamp;
146 }
147
148 @Override
149 public void setCurrentTime(TmfTimestamp currentTime) {
150 fCurrentTimestamp = currentTime == null ? null : new TmfTimestamp(currentTime);
151 }
152
153 @Override
154 public TmfTimeRange getCurrentRange() {
155 return fCurrentTimeRange;
156 }
157
158 @Override
159 public void setCurrentRange(TmfTimeRange currentRange) {
160 fCurrentTimeRange = currentRange == null ? null : new TmfTimeRange(currentRange);
161 }
162 };
163
This page took 0.035536 seconds and 5 git commands to generate.