VirtualBox

Changeset 4647 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Sep 10, 2007 8:26:51 AM (17 years ago)
Author:
vboxsync
Message:

Completed statistic query

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

Legend:

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

    r4608 r4647  
    8080        mStatUpdateInterval = 0;                    /* Default is not to report guest statistics at all */
    8181
     82    for (int i=0;i<GuestStatisticType_MaxVal;i++)
     83        mCurrentGuestStat[i] = GUEST_STAT_INVALID;
     84
    8285    return S_OK;
    8386}
     
    271274        return E_INVALIDARG;
    272275
    273     switch(aStatistic)
    274     {
    275     case GuestStatisticType_CPULoad_Idle:
    276     case GuestStatisticType_CPULoad_Kernel:
    277     case GuestStatisticType_CPULoad_User:
    278     case GuestStatisticType_Threads:
    279     case GuestStatisticType_Processes:
    280     case GuestStatisticType_Handles:
    281     case GuestStatisticType_MemoryLoad:
    282     case GuestStatisticType_PhysMemTotal:
    283     case GuestStatisticType_PhysMemAvailable:
    284     case GuestStatisticType_PhysMemBalloon:
    285     case GuestStatisticType_MemCommitTotal:
    286     case GuestStatisticType_MemKernelTotal:
    287     case GuestStatisticType_MemKernelPaged:
    288     case GuestStatisticType_MemKernelNonpaged:
    289     case GuestStatisticType_MemSystemCache:
    290     case GuestStatisticType_PageFileSize:
    291         *aStatVal = 0;
    292         break;
    293 
    294     default:
    295         AssertFailed();
    296         return E_INVALIDARG;
    297     }
     276    if (aStatistic >= GuestStatisticType_MaxVal)
     277        return E_INVALIDARG;
     278
     279    /* not available or not yet reported? */
     280    if (mCurrentGuestStat[aStatistic] == GUEST_STAT_INVALID)
     281        return E_INVALIDARG;
     282
     283    *aStatVal = mCurrentGuestStat[aStatistic];
    298284    return S_OK;
    299285}
     
    304290        return E_INVALIDARG;
    305291
    306     switch(aStatistic)
    307     {
    308     case GuestStatisticType_CPULoad_Idle:
    309     case GuestStatisticType_CPULoad_Kernel:
    310     case GuestStatisticType_CPULoad_User:
    311     case GuestStatisticType_Threads:
    312     case GuestStatisticType_Processes:
    313     case GuestStatisticType_Handles:
    314     case GuestStatisticType_MemoryLoad:
    315     case GuestStatisticType_PhysMemTotal:
    316     case GuestStatisticType_PhysMemAvailable:
    317     case GuestStatisticType_PhysMemBalloon:
    318     case GuestStatisticType_MemCommitTotal:
    319     case GuestStatisticType_MemKernelTotal:
    320     case GuestStatisticType_MemKernelPaged:
    321     case GuestStatisticType_MemKernelNonpaged:
    322     case GuestStatisticType_MemSystemCache:
    323     case GuestStatisticType_PageFileSize:
    324         break;
    325 
    326     default:
    327         AssertFailed();
    328         return E_INVALIDARG;
    329     }
     292    if (aStatistic >= GuestStatisticType_MaxVal)
     293        return E_INVALIDARG;
     294
     295    /* internal method assumes that the caller known what he's doing (no boundary checks) */
     296    mCurrentGuestStat[aStatistic] = aStatVal;
    330297    return S_OK;
    331298}
  • trunk/src/VBox/Main/include/GuestImpl.h

    r4571 r4647  
    2222
    2323class Console;
     24
     25#define GUEST_STAT_INVALID          (ULONG)-1
    2426
    2527class ATL_NO_VTABLE Guest :
     
    9193    ULONG mStatUpdateInterval;
    9294
     95    ULONG mCurrentGuestStat[GuestStatisticType_MaxVal];
     96
    9397    ComObjPtr <Console, ComWeakRef> mParent;
    9498    Data mData;
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