Commit | Line | Data |
---|---|---|
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 | *******************************************************************************/ | |
12 | package org.eclipse.linuxtools.lttng.state.model; | |
13 | ||
14 | import org.eclipse.linuxtools.lttng.state.StateStrings; | |
58c60db3 | 15 | import org.eclipse.linuxtools.tmf.event.TmfTimestamp; |
5d10d135 ASL |
16 | |
17 | /** | |
18 | * <b><u>LttngExecutionState</u></b> | |
19 | * <p> | |
20 | * | |
21 | */ | |
22 | public class LttngExecutionState implements Cloneable { | |
23 | // ======================================================================== | |
24 | // Data | |
25 | // ======================================================================= | |
58c60db3 FC |
26 | private TmfTimestamp entry_LttTime = null; |
27 | private TmfTimestamp change_LttTime = null; | |
5d10d135 ASL |
28 | private Long cum_cpu_time_Timens = null; |
29 | ||
30 | private StateStrings.ProcessStatus proc_status = StateStrings.ProcessStatus.LTTV_STATE_UNNAMED; | |
31 | private StateStrings.ExecutionMode exec_mode = StateStrings.ExecutionMode.LTTV_STATE_MODE_UNKNOWN; | |
32 | private String exec_submode = StateStrings.ExecutionSubMode.LTTV_STATE_SUBMODE_UNKNOWN.getInName(); | |
33 | ||
58c60db3 | 34 | public LttngExecutionState clone() { |
5d10d135 ASL |
35 | LttngExecutionState newState = null; |
36 | ||
37 | try { | |
38 | newState = (LttngExecutionState)super.clone(); | |
39 | ||
40 | // *** IMPORTANT *** | |
41 | // Basic type in java are immutable! | |
42 | // Thus, using assignation ("=") on basic type is CORRECT, | |
43 | // but we should ALWAYS use "new" or "clone()" on "non basic" type | |
44 | newState.cum_cpu_time_Timens = this.cum_cpu_time_Timens; | |
45 | newState.exec_submode = this.exec_submode; | |
46 | ||
47 | // ProcessStatus and ExecutionMode are enum, and so shouldn't be a problem to use their reference | |
48 | newState.proc_status = this.proc_status; | |
49 | newState.exec_mode = this.exec_mode; | |
58c60db3 FC |
50 | |
51 | // No clonable implemented in TMF, we will use copy constructor | |
52 | // NOTE : we GOT to check for null to avoid crashing on null pointer here! | |
53 | if ( this.entry_LttTime != null ) { | |
54 | newState.entry_LttTime = new TmfTimestamp(this.entry_LttTime); | |
55 | } | |
56 | ||
57 | if ( this.change_LttTime != null ) { | |
58 | newState.change_LttTime = new TmfTimestamp(this.change_LttTime); | |
59 | } | |
5d10d135 ASL |
60 | } |
61 | catch ( CloneNotSupportedException e ) { | |
62 | System.out.println("Cloning failed with : " + e.getMessage() ); | |
63 | } | |
64 | ||
65 | return newState; | |
66 | } | |
67 | ||
68 | // ======================================================================== | |
69 | // Methods | |
70 | // ======================================================================= | |
71 | /** | |
72 | * @return the entry_LttTime | |
73 | */ | |
58c60db3 | 74 | public TmfTimestamp getEntry_LttTime() { |
5d10d135 ASL |
75 | return entry_LttTime; |
76 | } | |
77 | ||
78 | /** | |
79 | * @param entryLttTime | |
80 | * the entry_LttTime to set | |
81 | */ | |
58c60db3 | 82 | public void setEntry_Time(TmfTimestamp entryLttTime) { |
5d10d135 ASL |
83 | entry_LttTime = entryLttTime; |
84 | } | |
85 | ||
86 | /** | |
87 | * @return the change_LttTime | |
88 | */ | |
58c60db3 | 89 | public TmfTimestamp getChange_LttTime() { |
5d10d135 ASL |
90 | return change_LttTime; |
91 | } | |
92 | ||
93 | /** | |
94 | * @param changeLttTime | |
95 | * the change_LttTime to set | |
96 | */ | |
58c60db3 | 97 | public void setChange_Time(TmfTimestamp changeLttTime) { |
5d10d135 ASL |
98 | change_LttTime = changeLttTime; |
99 | } | |
100 | ||
101 | /** | |
102 | * @return the cum_cpu_time_LttTime | |
103 | */ | |
104 | public Long getCum_cpu_time() { | |
105 | return cum_cpu_time_Timens; | |
106 | } | |
107 | ||
108 | /** | |
109 | * @param cumCpuTimeLttTime | |
110 | * the cum_cpu_time_LttTime to set | |
111 | */ | |
112 | public void setCum_cpu_time(Long cumCpuTime) { | |
113 | cum_cpu_time_Timens = cumCpuTime; | |
114 | } | |
115 | ||
116 | /** | |
117 | * @return the proc_status | |
118 | */ | |
119 | public StateStrings.ProcessStatus getProc_status() { | |
120 | return proc_status; | |
121 | } | |
122 | ||
123 | /** | |
124 | * @param procStatus | |
125 | * the proc_status to set | |
126 | */ | |
127 | public void setProc_status(StateStrings.ProcessStatus procStatus) { | |
128 | proc_status = procStatus; | |
129 | } | |
130 | ||
131 | /** | |
132 | * @return the exec_mode | |
133 | */ | |
134 | public StateStrings.ExecutionMode getExec_mode() { | |
135 | return exec_mode; | |
136 | } | |
137 | ||
138 | /** | |
139 | * @param execMode | |
140 | * the exec_mode to set | |
141 | */ | |
142 | public void setExec_mode(StateStrings.ExecutionMode execMode) { | |
143 | exec_mode = execMode; | |
144 | } | |
145 | ||
146 | /** | |
147 | * @return the exec_submode | |
148 | */ | |
149 | public String getExec_submode() { | |
150 | return exec_submode; | |
151 | } | |
152 | ||
153 | /** | |
154 | * @param execSubmode | |
155 | * the exec_submode to set | |
156 | */ | |
157 | public void setExec_submode(String execSubmode) { | |
158 | exec_submode = execSubmode; | |
159 | } | |
160 | } |