| 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 | *******************************************************************************/ |
| 12 | package org.eclipse.linuxtools.lttng.state.model; |
| 13 | |
| 14 | import org.eclipse.linuxtools.lttng.LttngConstants; |
| 15 | import org.eclipse.linuxtools.lttng.state.StateStrings; |
| 16 | |
| 17 | /** |
| 18 | * <b><u>LttngExecutionState</u></b> |
| 19 | * <p> |
| 20 | * |
| 21 | */ |
| 22 | public class LttngExecutionState implements Cloneable { |
| 23 | // ======================================================================== |
| 24 | // Data |
| 25 | // ======================================================================= |
| 26 | |
| 27 | private Long entry_LttTime = null; |
| 28 | private Long change_LttTime = null; |
| 29 | private Long cum_cpu_time_Timens = null; |
| 30 | |
| 31 | private StateStrings.ProcessStatus proc_status = StateStrings.ProcessStatus.LTTV_STATE_UNNAMED; |
| 32 | private StateStrings.ExecutionMode exec_mode = StateStrings.ExecutionMode.LTTV_STATE_MODE_UNKNOWN; |
| 33 | private String exec_submode = StateStrings.ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.getInName(); |
| 34 | // Note: For statistics performance improvement a integer representation of the submode is used |
| 35 | // as well as a bit mask is applied! |
| 36 | private int exec_submode_id = Integer.valueOf(StateStrings.ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.ordinal() | LttngConstants.STATS_NONE_ID); |
| 37 | |
| 38 | @Override |
| 39 | public LttngExecutionState clone() { |
| 40 | LttngExecutionState newState = null; |
| 41 | |
| 42 | try { |
| 43 | newState = (LttngExecutionState)super.clone(); |
| 44 | |
| 45 | // *** IMPORTANT *** |
| 46 | // Basic type in java are immutable! |
| 47 | // Thus, using assignation ("=") on basic type is CORRECT, |
| 48 | // but we should ALWAYS use "new" or "clone()" on "non basic" type |
| 49 | newState.cum_cpu_time_Timens = this.cum_cpu_time_Timens; |
| 50 | newState.exec_submode = this.exec_submode; |
| 51 | newState.exec_submode_id = this.exec_submode_id; |
| 52 | |
| 53 | // ProcessStatus and ExecutionMode are enum, and so shouldn't be a problem to use their reference |
| 54 | newState.proc_status = this.proc_status; |
| 55 | newState.exec_mode = this.exec_mode; |
| 56 | newState.entry_LttTime = this.entry_LttTime; |
| 57 | newState.change_LttTime = this.change_LttTime; |
| 58 | } |
| 59 | catch ( CloneNotSupportedException e ) { |
| 60 | System.out.println("Cloning failed with : " + e.getMessage() ); //$NON-NLS-1$ |
| 61 | } |
| 62 | |
| 63 | return newState; |
| 64 | } |
| 65 | |
| 66 | // ======================================================================== |
| 67 | // Methods |
| 68 | // ======================================================================= |
| 69 | /** |
| 70 | * @return the entry_LttTime |
| 71 | */ |
| 72 | public Long getEntry_LttTime() { |
| 73 | return entry_LttTime; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * @param entryLttTime |
| 78 | * the entry_LttTime to set |
| 79 | */ |
| 80 | public void setEntry_Time(Long entryLttTime) { |
| 81 | entry_LttTime = entryLttTime; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * @return the change_LttTime |
| 86 | */ |
| 87 | public Long getChange_LttTime() { |
| 88 | return change_LttTime; |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @param changeLttTime |
| 93 | * the change_LttTime to set |
| 94 | */ |
| 95 | public void setChange_Time(Long changeLttTime) { |
| 96 | change_LttTime = changeLttTime; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * @return the cum_cpu_time_LttTime |
| 101 | */ |
| 102 | public Long getCum_cpu_time() { |
| 103 | return cum_cpu_time_Timens; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * @param cumCpuTimeLttTime |
| 108 | * the cum_cpu_time_LttTime to set |
| 109 | */ |
| 110 | public void setCum_cpu_time(Long cumCpuTime) { |
| 111 | cum_cpu_time_Timens = cumCpuTime; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * @return the proc_status |
| 116 | */ |
| 117 | public StateStrings.ProcessStatus getProc_status() { |
| 118 | return proc_status; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @param procStatus |
| 123 | * the proc_status to set |
| 124 | */ |
| 125 | public void setProc_status(StateStrings.ProcessStatus procStatus) { |
| 126 | proc_status = procStatus; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @return the exec_mode |
| 131 | */ |
| 132 | public StateStrings.ExecutionMode getExec_mode() { |
| 133 | return exec_mode; |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * @param execMode |
| 138 | * the exec_mode to set |
| 139 | */ |
| 140 | public void setExec_mode(StateStrings.ExecutionMode execMode) { |
| 141 | exec_mode = execMode; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * @return the exec_submode |
| 146 | */ |
| 147 | public String getExec_submode() { |
| 148 | return exec_submode; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @param execSubmode |
| 153 | * the exec_submode to set |
| 154 | */ |
| 155 | public void setExec_submode(String execSubmode) { |
| 156 | exec_submode = execSubmode; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * @return the exec_submode |
| 161 | */ |
| 162 | public int getExec_submode_id() { |
| 163 | return exec_submode_id; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * @param execSubmode |
| 168 | * the exec_submode id to set |
| 169 | */ |
| 170 | public void setExec_submode_id(int execSubmodeId) { |
| 171 | exec_submode_id = execSubmodeId; |
| 172 | } |
| 173 | |
| 174 | |
| 175 | @Override |
| 176 | @SuppressWarnings("nls") |
| 177 | public String toString() { |
| 178 | return "[LttngExecutionState: " + "entry=" + entry_LttTime + ",change=" + change_LttTime + ",cum_cpu=" + cum_cpu_time_Timens + |
| 179 | ",pstatus=" + proc_status + ",emode=" + exec_mode + ",esubmode=" + exec_submode +"]"; |
| 180 | } |
| 181 | } |