tmf: Use tabs in statistics view for each traces
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.core / src / org / eclipse / linuxtools / internal / lttng / core / state / model / LttngBdevState.java
CommitLineData
5d10d135
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
5945cec9 12package org.eclipse.linuxtools.internal.lttng.core.state.model;
5d10d135
ASL
13
14import java.util.Stack;
15
5945cec9
FC
16import org.eclipse.linuxtools.internal.lttng.core.TraceDebug;
17import org.eclipse.linuxtools.internal.lttng.core.state.StateStrings.BdevMode;
5d10d135
ASL
18
19/**
20 * <b><u>LttvBdevState</u></b>
21 * <p>
22 *
23 */
24public class LttngBdevState implements Cloneable {
25 // ========================================================================
26 // Data
27 // =======================================================================
28 private Stack<BdevMode> mode_stack = new Stack<BdevMode>() ;
29
30
31 // ========================================================================
32 // Constructor
33 // =======================================================================
34 public LttngBdevState() {
35 mode_stack.push(BdevMode.LTTV_BDEV_UNKNOWN);
36 }
37
38 // ========================================================================
39 // Methods
40 // =======================================================================
41 public void clearBdevStack() {
42 mode_stack.clear();
43 }
44
45 public void clearAndSetBaseToBdevStack(BdevMode newState) {
46 mode_stack.clear();
47 // Ensure that there is always at least 1 item in the stack
48 mode_stack.push(newState);
49 }
50
51 public void pushToBdevStack(BdevMode newState) {
52 mode_stack.push(newState);
53 }
54
55 public BdevMode popFromBdevStack() {
56
57 BdevMode returnedMode = mode_stack.pop();
58
59 if (mode_stack.size() < 1) {
9c4eb5f7 60 TraceDebug.debug("Removing last item from mode stack is not allowed! (popFromModeStack)"); //$NON-NLS-1$
5d10d135
ASL
61 mode_stack.push(BdevMode.LTTV_BDEV_UNKNOWN);
62 }
63
64 return returnedMode;
65 }
66
67 public BdevMode peekFromBdevStack() {
68 return mode_stack.peek();
69 }
70
71
cc6eec3e 72 @Override
5d10d135
ASL
73 @SuppressWarnings("unchecked")
74 public LttngBdevState clone() {
75 LttngBdevState newState = null;
76
77 try {
78 newState = (LttngBdevState)super.clone();
79 // Clone should work correctly for all stack object that contain basic java object (String, Long, etc...)
80 newState.mode_stack = (Stack<BdevMode>)this.mode_stack.clone();
81 }
82 catch ( CloneNotSupportedException e ) {
9c4eb5f7 83 System.out.println("Cloning failed with : " + e.getMessage() ); //$NON-NLS-1$
5d10d135
ASL
84 }
85
86 return newState;
87 }
88
89}
This page took 0.039095 seconds and 5 git commands to generate.