VirtualBox

Changeset 15762 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Dec 25, 2008 11:53:50 PM (16 years ago)
Author:
vboxsync
Message:

Main: Exmplicit machine state comparisons replaced with bool "IsMetastate"-like methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/Global.h

    r15064 r15762  
    6666
    6767    static const char *OSTypeId (VBOXOSTYPE aOSType);
     68
     69    /**
     70     * Returns @c true if the given machine state is an online state. This is a
     71     * recommended way to detect if the VM is online (being executed in a
     72     * dedicated process) or not. Note that some online states are also
     73     * transitional states (see #IsTransitional()).
     74     */
     75    static bool IsOnline (MachineState_T aState)
     76    {
     77        return aState >= MachineState_FirstOnline &&
     78               aState <= MachineState_LastOnline;
     79    }
     80
     81    /**
     82     * Returns @c true if the given machine state is a transient state. This is
     83     * a recommended way to detect if the VM is performing some potentially
     84     * lengthy operation (such as starting, stopping, saving, discarding
     85     * snapshot, etc.). Note some (but not all) transitional states are also
     86     * online states (see #IsOnline()).
     87     */
     88    static bool IsTransient (MachineState_T aState)
     89    {
     90        return aState >= MachineState_FirstTransient &&
     91               aState <= MachineState_LastTransient;
     92    }
     93
     94    /**
     95     * Shortcut to <tt>IsOnline (aState) || IsTransient (aState)</tt>. When it
     96     * returns @false, the VM is turned off (no VM process) and not busy with
     97     * another exclusive operation.
     98     */
     99    static bool IsOnlineOrTransient (MachineState_T aState)
     100    {
     101        return IsOnline (aState) || IsTransient (aState);
     102    }
     103
     104    /**
     105     * Shortcut to <tt>IsOnline (aState) && !IsTransient (aState)</tt>. This is
     106     * a recommended way to detect if the VM emulation thread is in action
     107     * (either running, suspended, or stuck). When this method returns @false,
     108     * then either the VM is not online or the emulation thread is being started
     109     * or stopped, etc.
     110     */
     111    static bool IsActive (MachineState_T aState)
     112    {
     113        return IsOnline (aState) && !IsTransient (aState);
     114    }
    68115};
    69116
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