VirtualBox

Changeset 23648 in vbox


Ignore:
Timestamp:
Oct 9, 2009 2:18:33 PM (15 years ago)
Author:
vboxsync
Message:

Main/Global: Added stringifyMachineState.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/Global.cpp

    r23500 r23648  
    2727
    2828#include <iprt/assert.h>
     29#include <iprt/string.h>
    2930
    3031/* static */
     
    168169 */
    169170/* static */
    170 const char *Global::OSTypeId (VBOXOSTYPE aOSType)
     171const char *Global::OSTypeId(VBOXOSTYPE aOSType)
    171172{
    172     for (size_t i = 0; i < RT_ELEMENTS (sOSTypes); ++ i)
     173    for (size_t i = 0; i < RT_ELEMENTS(sOSTypes); ++i)
    173174    {
    174         if (sOSTypes [i].osType == aOSType)
    175             return sOSTypes [i].id;
     175        if (sOSTypes[i].osType == aOSType)
     176            return sOSTypes[i].id;
    176177    }
    177178
    178     AssertMsgFailed (("No record for VBOXOSTYPE %d\n", aOSType));
    179     return sOSTypes [0].id;
     179    AssertMsgFailed(("No record for VBOXOSTYPE %d\n", aOSType));
     180    return sOSTypes[0].id;
    180181}
     182
     183/*static*/ const char *
     184Global::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
    181212/* vi: set tabstop=4 shiftwidth=4 expandtab: */
  • trunk/src/VBox/Main/include/Global.h

    r21607 r23648  
    6464    };
    6565
    66     static const OSType sOSTypes [SchemaDefs::OSTypeId_COUNT];
     66    static const OSType sOSTypes[SchemaDefs::OSTypeId_COUNT];
    6767
    68     static const char *OSTypeId (VBOXOSTYPE aOSType);
     68    static const char *OSTypeId(VBOXOSTYPE aOSType);
    6969
    7070    /**
     
    7474     * transitional states (see #IsTransitional()).
    7575     */
    76     static bool IsOnline (MachineState_T aState)
     76    static bool IsOnline(MachineState_T aState)
    7777    {
    7878        return aState >= MachineState_FirstOnline &&
     
    8787     * online states (see #IsOnline()).
    8888     */
    89     static bool IsTransient (MachineState_T aState)
     89    static bool IsTransient(MachineState_T aState)
    9090    {
    9191        return aState >= MachineState_FirstTransient &&
     
    9898     * another exclusive operation.
    9999     */
    100     static bool IsOnlineOrTransient (MachineState_T aState)
     100    static bool IsOnlineOrTransient(MachineState_T aState)
    101101    {
    102         return IsOnline (aState) || IsTransient (aState);
     102        return IsOnline(aState) || IsTransient(aState);
    103103    }
    104104
     
    110110     * or stopped, etc.
    111111     */
    112     static bool IsActive (MachineState_T aState)
     112    static bool IsActive(MachineState_T aState)
    113113    {
    114         return IsOnline (aState) && !IsTransient (aState);
     114        return IsOnline(aState) && !IsTransient(aState);
    115115    }
     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);
    116124};
    117125
    118 #endif /* ____H_GLOBAL */
     126#endif /* !____H_GLOBAL */
    119127/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette