Changeset 23648 in vbox
- Timestamp:
- Oct 9, 2009 2:18:33 PM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/Global.cpp
r23500 r23648 27 27 28 28 #include <iprt/assert.h> 29 #include <iprt/string.h> 29 30 30 31 /* static */ … … 168 169 */ 169 170 /* static */ 170 const char *Global::OSTypeId 171 const char *Global::OSTypeId(VBOXOSTYPE aOSType) 171 172 { 172 for (size_t i = 0; i < RT_ELEMENTS (sOSTypes); ++i)173 for (size_t i = 0; i < RT_ELEMENTS(sOSTypes); ++i) 173 174 { 174 if (sOSTypes 175 return sOSTypes 175 if (sOSTypes[i].osType == aOSType) 176 return sOSTypes[i].id; 176 177 } 177 178 178 AssertMsgFailed 179 return sOSTypes 179 AssertMsgFailed(("No record for VBOXOSTYPE %d\n", aOSType)); 180 return sOSTypes[0].id; 180 181 } 182 183 /*static*/ const char * 184 Global::stringifyMachineState(MachineState_T aState) 185 { 186 switch (aState) 187 { 188 case MachineState_Null: return "Null"; 189 case MachineState_PoweredOff: return "PoweredOff"; 190 case MachineState_Saved: return "Saved"; 191 case MachineState_Aborted: return "Aborted"; 192 case MachineState_Running: return "Running"; 193 case MachineState_Paused: return "Paused"; 194 case MachineState_Stuck: return "GuruMeditation"; 195 case MachineState_Starting: return "Starting"; 196 case MachineState_Stopping: return "Stopping"; 197 case MachineState_Saving: return "Saving"; 198 case MachineState_Restoring: return "Restoring"; 199 case MachineState_Discarding: return "Discarding"; 200 case MachineState_SettingUp: return "SettingUp"; 201 default: 202 { 203 AssertMsgFailed(("%d (%#x)\n", aState, aState)); 204 static char s_szMsg[48]; 205 RTStrPrintf(s_szMsg, sizeof(s_szMsg), "InvalidState-0x%08x\n", aState); 206 return s_szMsg; 207 } 208 209 } 210 } 211 181 212 /* vi: set tabstop=4 shiftwidth=4 expandtab: */ -
trunk/src/VBox/Main/include/Global.h
r21607 r23648 64 64 }; 65 65 66 static const OSType sOSTypes 66 static const OSType sOSTypes[SchemaDefs::OSTypeId_COUNT]; 67 67 68 static const char *OSTypeId 68 static const char *OSTypeId(VBOXOSTYPE aOSType); 69 69 70 70 /** … … 74 74 * transitional states (see #IsTransitional()). 75 75 */ 76 static bool IsOnline 76 static bool IsOnline(MachineState_T aState) 77 77 { 78 78 return aState >= MachineState_FirstOnline && … … 87 87 * online states (see #IsOnline()). 88 88 */ 89 static bool IsTransient 89 static bool IsTransient(MachineState_T aState) 90 90 { 91 91 return aState >= MachineState_FirstTransient && … … 98 98 * another exclusive operation. 99 99 */ 100 static bool IsOnlineOrTransient 100 static bool IsOnlineOrTransient(MachineState_T aState) 101 101 { 102 return IsOnline (aState) || IsTransient(aState);102 return IsOnline(aState) || IsTransient(aState); 103 103 } 104 104 … … 110 110 * or stopped, etc. 111 111 */ 112 static bool IsActive 112 static bool IsActive(MachineState_T aState) 113 113 { 114 return IsOnline (aState) && !IsTransient(aState);114 return IsOnline(aState) && !IsTransient(aState); 115 115 } 116 117 /** 118 * Stringify a machine state. 119 * 120 * @returns Pointer to a read only string. 121 * @param aState Valid machine state. 122 */ 123 static const char *stringifyMachineState(MachineState_T aState); 116 124 }; 117 125 118 #endif /* ____H_GLOBAL */126 #endif /* !____H_GLOBAL */ 119 127 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.