Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6ad18a345f341d313b973d87b82f088cad67fa54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
/*******************************************************************************
 * Copyright (c) 2011 Ericsson
 * 
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *   Bernd Hufmann - Initial API and implementation
 *   
 *******************************************************************************/
package org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config;

import org.eclipse.linuxtools.internal.lttng.core.tracecontrol.model.config.TraceChannel;

/**
 * <b><u>TraceChannel</u></b>
 * <p>
 *  This models a trace channel representing a channel on a particular remote system.
 * </p>
 */
public class TraceChannel implements Cloneable {
    
    // ------------------------------------------------------------------------
    // Attributes
    // -----------------------------------------------------------------------

    public static final int UNKNOWN_VALUE = -1;
    public static final String UNKNOWN_STRING = "?";  //$NON-NLS-1$
    public static final String UST_TRACE_CHANNEL_NAME = "AUTO"; //$NON-NLS-1$
    
    private String  fName = ""; //$NON-NLS-1$
    private boolean fIsEnabled = true;
    private boolean fIsEnabledStatusKnown = false;
    private boolean fIsChannelOverride = false;
    private boolean fIsChannelOverrideStatusKnown = false;
    private long    fSubbufNum = 0;
    private long    fSubbufSize = 0;
    private long    fTimer = 0;
    
    // ------------------------------------------------------------------------
    // Constructors
    // ------------------------------------------------------------------------

    /**
     * Constructor
     *  
     * @param name The name of the channel
     * @param subbufNum The number of sub-buffers
     * @param subbufSize The size of the sub-buffers
     * @param timer The Channel timer
     */
    public TraceChannel(String name, long subbufNum, long subbufSize, long timer) {
        fName = name;
        fIsEnabled = false;
        fIsEnabledStatusKnown = false;
        fIsChannelOverride = false;
        fIsChannelOverrideStatusKnown = false;
        fSubbufNum = subbufNum;
        fSubbufSize = subbufSize;
        fTimer = timer;
    }
    
    /**
     * Constructor
     * 
     * @param name The name of the channel
     * @param isEnabled The state of the channel (enabled or disabled)
     * @param issChannelOverride The state of the channel override (enabled or disabled)
     * @param subbufNum The number of sub-buffers
     * @param subbufSize The size of the sub-buffers
     * @param timer The Channel timer
     */
    public TraceChannel(String name, boolean isEnabled, boolean issChannelOverride, long subbufNum, long subbufSize, long timer) {
        fName = name;
        fIsEnabled = isEnabled;
        fIsEnabledStatusKnown = true;
        fIsChannelOverride = issChannelOverride;
        fIsChannelOverrideStatusKnown = true;
        fSubbufNum = subbufNum;
        fSubbufSize = subbufSize;
        fTimer = timer;
    }       
    
    public TraceChannel (String name) {
        this(name, UNKNOWN_VALUE, UNKNOWN_VALUE, UNKNOWN_VALUE);
    }
    
    // ------------------------------------------------------------------------
    // Operations
    // ------------------------------------------------------------------------
    
    /**
     * Gets the name of the channel.
     * 
     * @return name of channel.
     */
    public String getName () {
        return fName;
    }
    
    /**
     * Sets the name of the channel.
     * 
     * @param name The name of channel to set
     */
    public void setName(String name) {
        fName = name;
    }
    
    /**
     * Returns whether the channel is enabled or not
     * 
     * @return true if enabled, false if disabled
     */
    public boolean isEnabled() {
        return fIsEnabled;
    }

    /**
     * Sets the state of the channel.
     * 
     * @param isEnabled
     */
    public void setIsEnabled(boolean isEnabled) {
        fIsEnabled = isEnabled;
        fIsEnabledStatusKnown = true;
    }

    /**
     * Returns a flag to indicate whether the enabled state on the remote system is known or not.
     * 
     * @return true if known else false
     */
    public boolean isEnabledStatusKnown() {
        return fIsEnabledStatusKnown;
    }

    /**
     * Sets a flag to indicate whether the enabled state on the remote system is known or not.
     * @param isKnown
     */
    public void setIsEnabledStatusKnown(boolean isKnown) {
        fIsEnabledStatusKnown = isKnown;
    }

    /**
     * Returns whether the channel buffer overwrite is enabled or not
     * 
     * @return true if enabled, false if disabled
     */

    public boolean isChannelOverride() {
        return fIsChannelOverride;
    }

    /**
     * Sets the state of the channel buffer overwrite.
     * @param isChannelOverride
     */
    public void setIsChannelOverride(boolean isChannelOverride) {
        this.fIsChannelOverride = isChannelOverride;
        this.fIsChannelOverrideStatusKnown = true;
    }
    /**
     * Returns a flag to indicate whether the channel overwrite state on the remote system is known or not.
     * 
     * @return true if known else false
     */
    public boolean isChannelOverrideStatusKnown() {
        return fIsChannelOverrideStatusKnown;
    }
    
    /**
     * Sets a flag to indicate whether the channel overwrite state on the remote system is known or not.
     * 
     * @param isKnown
     */
    public void setIsChannelOverrideStatusKnown(boolean isKnown) {
        this.fIsChannelOverrideStatusKnown = isKnown;
    }

    /**
     * Gets the number of sub-buffers.
     * 
     * @return subBufNum
     */
    public long getSubbufNum() {
        return fSubbufNum;
    }

    /**
     * Sets the number of sub-buffers.
     * @param subbufNum
     */
    public void setSubbufNum(long subbufNum) {
        this.fSubbufNum = subbufNum;
    }

    /**
     * Returns the size of the sub-buffers.
     * 
     * @return subbufSize
     */
    public long getSubbufSize() {
        return fSubbufSize;
    }

    /**
     * Sets the size of the sub-buffers.
     * 
     * @param subbufSize
     */
    public void setSubbufSize(long subbufSize) {
        this.fSubbufSize = subbufSize;
    }

    /** 
     * Returns the channel timer.
     * 
     * @return channel timer
     */
    public long getTimer() {
        return fTimer;
    }

    /**
     * Sets the channel timer.
     * 
     * @param timer
     */
    public void setTimer(long timer) {
        this.fTimer = timer;
    }
    
    /*
     * (non-Javadoc)
     * @see java.lang.Object#clone()
     */
    @Override
    public TraceChannel clone() {
        TraceChannel clone = null;
        try {
            clone = (TraceChannel)super.clone();
            clone.fName = fName;
            clone.fIsEnabled = fIsEnabled;
            clone.fIsEnabledStatusKnown = fIsEnabledStatusKnown;
            clone.fIsChannelOverride = fIsChannelOverride;
            clone.fIsChannelOverrideStatusKnown = fIsChannelOverrideStatusKnown;
            clone.fSubbufNum = fSubbufNum;
            clone.fSubbufSize = fSubbufSize;
            clone.fTimer = fTimer;            
        } catch (CloneNotSupportedException e) {
        }
        return clone;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override 
    public boolean equals(Object other) {
        
        if (this == other) {
            return true;
        }

        if (other == null) {
            return false;
        }

        if (!(other instanceof TraceChannel)) {
            return false;
        }

        TraceChannel otherChannel = (TraceChannel) other;

        if (!otherChannel.fName.equals(fName)) {
            return false;
        }
        if (otherChannel.fIsEnabled != fIsEnabled) {
            return false;
        }
        if (otherChannel.fIsEnabledStatusKnown != fIsEnabledStatusKnown) {
            return false;
        }
        if (otherChannel.fIsChannelOverride != fIsChannelOverride) {
            return false;
        }
        if (otherChannel.fIsChannelOverrideStatusKnown != fIsChannelOverrideStatusKnown) { 
            return false;
        }
        if (otherChannel.fSubbufNum != fSubbufNum) {
            return false;
        }
        if (otherChannel.fSubbufSize != fSubbufSize) {
            return false;
        }
        if (otherChannel.fTimer != fTimer) {
            return false;
        }

        return true;
    }

    /*
     * (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override 
    public int hashCode() {
        // slow algorithm
        StringBuffer builder = new StringBuffer(fName);
        builder.append(fIsEnabled);
        builder.append(fIsEnabledStatusKnown);
        builder.append(fIsChannelOverride);
        builder.append(fIsChannelOverrideStatusKnown);
        builder.append(fSubbufNum);
        builder.append(fSubbufSize);
        builder.append(fTimer);
        return builder.toString().hashCode();
    }

    @Override
    @SuppressWarnings("nls")
    public String toString() {
        return "[TraceChannel (" + fName + ")]";
    }

    
    
}

Back to the top