1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.config
;
15 import org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.config
.TraceChannel
;
18 * <b><u>TraceChannel</u></b>
20 * This models a trace channel representing a channel on a particular remote system.
23 public class TraceChannel
implements Cloneable
{
25 // ------------------------------------------------------------------------
27 // -----------------------------------------------------------------------
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$
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;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
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
54 public TraceChannel(String name
, long subbufNum
, long subbufSize
, long timer
) {
57 fIsEnabledStatusKnown
= false;
58 fIsChannelOverride
= false;
59 fIsChannelOverrideStatusKnown
= false;
60 fSubbufNum
= subbufNum
;
61 fSubbufSize
= subbufSize
;
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
75 public TraceChannel(String name
, boolean isEnabled
, boolean issChannelOverride
, long subbufNum
, long subbufSize
, long timer
) {
77 fIsEnabled
= isEnabled
;
78 fIsEnabledStatusKnown
= true;
79 fIsChannelOverride
= issChannelOverride
;
80 fIsChannelOverrideStatusKnown
= true;
81 fSubbufNum
= subbufNum
;
82 fSubbufSize
= subbufSize
;
86 public TraceChannel (String name
) {
87 this(name
, UNKNOWN_VALUE
, UNKNOWN_VALUE
, UNKNOWN_VALUE
);
90 // ------------------------------------------------------------------------
92 // ------------------------------------------------------------------------
95 * Gets the name of the channel.
97 * @return name of channel.
99 public String
getName () {
104 * Sets the name of the channel.
106 * @param name The name of channel to set
108 public void setName(String name
) {
113 * Returns whether the channel is enabled or not
115 * @return true if enabled, false if disabled
117 public boolean isEnabled() {
122 * Sets the state of the channel.
126 public void setIsEnabled(boolean isEnabled
) {
127 fIsEnabled
= isEnabled
;
128 fIsEnabledStatusKnown
= true;
132 * Returns a flag to indicate whether the enabled state on the remote system is known or not.
134 * @return true if known else false
136 public boolean isEnabledStatusKnown() {
137 return fIsEnabledStatusKnown
;
141 * Sets a flag to indicate whether the enabled state on the remote system is known or not.
144 public void setIsEnabledStatusKnown(boolean isKnown
) {
145 fIsEnabledStatusKnown
= isKnown
;
149 * Returns whether the channel buffer overwrite is enabled or not
151 * @return true if enabled, false if disabled
154 public boolean isChannelOverride() {
155 return fIsChannelOverride
;
159 * Sets the state of the channel buffer overwrite.
160 * @param isChannelOverride
162 public void setIsChannelOverride(boolean isChannelOverride
) {
163 this.fIsChannelOverride
= isChannelOverride
;
164 this.fIsChannelOverrideStatusKnown
= true;
167 * Returns a flag to indicate whether the channel overwrite state on the remote system is known or not.
169 * @return true if known else false
171 public boolean isChannelOverrideStatusKnown() {
172 return fIsChannelOverrideStatusKnown
;
176 * Sets a flag to indicate whether the channel overwrite state on the remote system is known or not.
180 public void setIsChannelOverrideStatusKnown(boolean isKnown
) {
181 this.fIsChannelOverrideStatusKnown
= isKnown
;
185 * Gets the number of sub-buffers.
189 public long getSubbufNum() {
194 * Sets the number of sub-buffers.
197 public void setSubbufNum(long subbufNum
) {
198 this.fSubbufNum
= subbufNum
;
202 * Returns the size of the sub-buffers.
206 public long getSubbufSize() {
211 * Sets the size of the sub-buffers.
215 public void setSubbufSize(long subbufSize
) {
216 this.fSubbufSize
= subbufSize
;
220 * Returns the channel timer.
222 * @return channel timer
224 public long getTimer() {
229 * Sets the channel timer.
233 public void setTimer(long timer
) {
239 * @see java.lang.Object#clone()
242 public TraceChannel
clone() {
243 TraceChannel clone
= null;
245 clone
= (TraceChannel
)super.clone();
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
) {
261 * @see java.lang.Object#equals(java.lang.Object)
264 public boolean equals(Object other
) {
274 if (!(other
instanceof TraceChannel
)) {
278 TraceChannel otherChannel
= (TraceChannel
) other
;
280 if (!otherChannel
.fName
.equals(fName
)) {
283 if (otherChannel
.fIsEnabled
!= fIsEnabled
) {
286 if (otherChannel
.fIsEnabledStatusKnown
!= fIsEnabledStatusKnown
) {
289 if (otherChannel
.fIsChannelOverride
!= fIsChannelOverride
) {
292 if (otherChannel
.fIsChannelOverrideStatusKnown
!= fIsChannelOverrideStatusKnown
) {
295 if (otherChannel
.fSubbufNum
!= fSubbufNum
) {
298 if (otherChannel
.fSubbufSize
!= fSubbufSize
) {
301 if (otherChannel
.fTimer
!= fTimer
) {
310 * @see java.lang.Object#hashCode()
313 public int hashCode() {
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();
327 @SuppressWarnings("nls")
328 public String
toString() {
329 return "[TraceChannel (" + fName
+ ")]";