Rename xxx.lttng to xxx.lttng.core
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core / src / org / eclipse / linuxtools / lttng / tracecontrol / model / config / TraceChannel.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 *******************************************************************************/
13 package org.eclipse.linuxtools.lttng.tracecontrol.model.config;
14
15 import org.eclipse.linuxtools.lttng.tracecontrol.model.config.TraceChannel;
16
17 /**
18 * <b><u>TraceChannel</u></b>
19 * <p>
20 * This models a trace channel representing a channel on a particular remote system.
21 * </p>
22 */
23 public class TraceChannel implements Cloneable {
24
25 // ------------------------------------------------------------------------
26 // Attributes
27 // -----------------------------------------------------------------------
28
29 public static final int UNKNOWN_VALUE = -1;
30 public static final String UNKNOWN_STRING = "?"; //$NON-NLS-1$
31 public static final String UST_TRACE_CHANNEL_NAME = "AUTO"; //$NON-NLS-1$
32
33 private String fName = ""; //$NON-NLS-1$
34 private boolean fIsEnabled = true;
35 private boolean fIsEnabledStatusKnown = false;
36 private boolean fIsChannelOverride = false;
37 private boolean fIsChannelOverrideStatusKnown = false;
38 private long fSubbufNum = 0;
39 private long fSubbufSize = 0;
40 private long fTimer = 0;
41
42 // ------------------------------------------------------------------------
43 // Constructors
44 // ------------------------------------------------------------------------
45
46 /**
47 * Constructor
48 *
49 * @param name The name of the channel
50 * @param subbufNum The number of sub-buffers
51 * @param subbufSize The size of the sub-buffers
52 * @param timer The Channel timer
53 */
54 public TraceChannel(String name, long subbufNum, long subbufSize, long timer) {
55 fName = name;
56 fIsEnabled = false;
57 fIsEnabledStatusKnown = false;
58 fIsChannelOverride = false;
59 fIsChannelOverrideStatusKnown = false;
60 fSubbufNum = subbufNum;
61 fSubbufSize = subbufSize;
62 fTimer = timer;
63 }
64
65 /**
66 * Constructor
67 *
68 * @param name The name of the channel
69 * @param isEnabled The state of the channel (enabled or disabled)
70 * @param issChannelOverride The state of the channel override (enabled or disabled)
71 * @param subbufNum The number of sub-buffers
72 * @param subbufSize The size of the sub-buffers
73 * @param timer The Channel timer
74 */
75 public TraceChannel(String name, boolean isEnabled, boolean issChannelOverride, long subbufNum, long subbufSize, long timer) {
76 fName = name;
77 fIsEnabled = isEnabled;
78 fIsEnabledStatusKnown = true;
79 fIsChannelOverride = issChannelOverride;
80 fIsChannelOverrideStatusKnown = true;
81 fSubbufNum = subbufNum;
82 fSubbufSize = subbufSize;
83 fTimer = timer;
84 }
85
86 public TraceChannel (String name) {
87 this(name, UNKNOWN_VALUE, UNKNOWN_VALUE, UNKNOWN_VALUE);
88 }
89
90 // ------------------------------------------------------------------------
91 // Operations
92 // ------------------------------------------------------------------------
93
94 /**
95 * Gets the name of the channel.
96 *
97 * @return name of channel.
98 */
99 public String getName () {
100 return fName;
101 }
102
103 /**
104 * Sets the name of the channel.
105 *
106 * @param name The name of channel to set
107 */
108 public void setName(String name) {
109 fName = name;
110 }
111
112 /**
113 * Returns whether the channel is enabled or not
114 *
115 * @return true if enabled, false if disabled
116 */
117 public boolean isEnabled() {
118 return fIsEnabled;
119 }
120
121 /**
122 * Sets the state of the channel.
123 *
124 * @param isEnabled
125 */
126 public void setIsEnabled(boolean isEnabled) {
127 fIsEnabled = isEnabled;
128 fIsEnabledStatusKnown = true;
129 }
130
131 /**
132 * Returns a flag to indicate whether the enabled state on the remote system is known or not.
133 *
134 * @return true if known else false
135 */
136 public boolean isEnabledStatusKnown() {
137 return fIsEnabledStatusKnown;
138 }
139
140 /**
141 * Sets a flag to indicate whether the enabled state on the remote system is known or not.
142 * @param isKnown
143 */
144 public void setIsEnabledStatusKnown(boolean isKnown) {
145 fIsEnabledStatusKnown = isKnown;
146 }
147
148 /**
149 * Returns whether the channel buffer overwrite is enabled or not
150 *
151 * @return true if enabled, false if disabled
152 */
153
154 public boolean isChannelOverride() {
155 return fIsChannelOverride;
156 }
157
158 /**
159 * Sets the state of the channel buffer overwrite.
160 * @param isChannelOverride
161 */
162 public void setIsChannelOverride(boolean isChannelOverride) {
163 this.fIsChannelOverride = isChannelOverride;
164 this.fIsChannelOverrideStatusKnown = true;
165 }
166 /**
167 * Returns a flag to indicate whether the channel overwrite state on the remote system is known or not.
168 *
169 * @return true if known else false
170 */
171 public boolean isChannelOverrideStatusKnown() {
172 return fIsChannelOverrideStatusKnown;
173 }
174
175 /**
176 * Sets a flag to indicate whether the channel overwrite state on the remote system is known or not.
177 *
178 * @param isKnown
179 */
180 public void setIsChannelOverrideStatusKnown(boolean isKnown) {
181 this.fIsChannelOverrideStatusKnown = isKnown;
182 }
183
184 /**
185 * Gets the number of sub-buffers.
186 *
187 * @return subBufNum
188 */
189 public long getSubbufNum() {
190 return fSubbufNum;
191 }
192
193 /**
194 * Sets the number of sub-buffers.
195 * @param subbufNum
196 */
197 public void setSubbufNum(long subbufNum) {
198 this.fSubbufNum = subbufNum;
199 }
200
201 /**
202 * Returns the size of the sub-buffers.
203 *
204 * @return subbufSize
205 */
206 public long getSubbufSize() {
207 return fSubbufSize;
208 }
209
210 /**
211 * Sets the size of the sub-buffers.
212 *
213 * @param subbufSize
214 */
215 public void setSubbufSize(long subbufSize) {
216 this.fSubbufSize = subbufSize;
217 }
218
219 /**
220 * Returns the channel timer.
221 *
222 * @return channel timer
223 */
224 public long getTimer() {
225 return fTimer;
226 }
227
228 /**
229 * Sets the channel timer.
230 *
231 * @param timer
232 */
233 public void setTimer(long timer) {
234 this.fTimer = timer;
235 }
236
237 /*
238 * (non-Javadoc)
239 * @see java.lang.Object#clone()
240 */
241 @Override
242 public TraceChannel clone() {
243 TraceChannel clone = null;
244 try {
245 clone = (TraceChannel)super.clone();
246 clone.fName = fName;
247 clone.fIsEnabled = fIsEnabled;
248 clone.fIsEnabledStatusKnown = fIsEnabledStatusKnown;
249 clone.fIsChannelOverride = fIsChannelOverride;
250 clone.fIsChannelOverrideStatusKnown = fIsChannelOverrideStatusKnown;
251 clone.fSubbufNum = fSubbufNum;
252 clone.fSubbufSize = fSubbufSize;
253 clone.fTimer = fTimer;
254 } catch (CloneNotSupportedException e) {
255 }
256 return clone;
257 }
258
259 /*
260 * (non-Javadoc)
261 * @see java.lang.Object#equals(java.lang.Object)
262 */
263 @Override
264 public boolean equals(Object other) {
265
266 if (this == other) {
267 return true;
268 }
269
270 if (other == null) {
271 return false;
272 }
273
274 if (!(other instanceof TraceChannel)) {
275 return false;
276 }
277
278 TraceChannel otherChannel = (TraceChannel) other;
279
280 if (!otherChannel.fName.equals(fName)) {
281 return false;
282 }
283 if (otherChannel.fIsEnabled != fIsEnabled) {
284 return false;
285 }
286 if (otherChannel.fIsEnabledStatusKnown != fIsEnabledStatusKnown) {
287 return false;
288 }
289 if (otherChannel.fIsChannelOverride != fIsChannelOverride) {
290 return false;
291 }
292 if (otherChannel.fIsChannelOverrideStatusKnown != fIsChannelOverrideStatusKnown) {
293 return false;
294 }
295 if (otherChannel.fSubbufNum != fSubbufNum) {
296 return false;
297 }
298 if (otherChannel.fSubbufSize != fSubbufSize) {
299 return false;
300 }
301 if (otherChannel.fTimer != fTimer) {
302 return false;
303 }
304
305 return true;
306 }
307
308 /*
309 * (non-Javadoc)
310 * @see java.lang.Object#hashCode()
311 */
312 @Override
313 public int hashCode() {
314 // slow algorithm
315 StringBuffer builder = new StringBuffer(fName);
316 builder.append(fIsEnabled);
317 builder.append(fIsEnabledStatusKnown);
318 builder.append(fIsChannelOverride);
319 builder.append(fIsChannelOverrideStatusKnown);
320 builder.append(fSubbufNum);
321 builder.append(fSubbufSize);
322 builder.append(fTimer);
323 return builder.toString().hashCode();
324 }
325
326 @Override
327 @SuppressWarnings("nls")
328 public String toString() {
329 return "[TraceChannel (" + fName + ")]";
330 }
331
332
333
334 }
This page took 0.037203 seconds and 5 git commands to generate.