当前位置: 首页>>代码示例>>C++>>正文


C++ SCXHandle::Update方法代码示例

本文整理汇总了C++中scxcorelib::SCXHandle::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ SCXHandle::Update方法的具体用法?C++ SCXHandle::Update怎么用?C++ SCXHandle::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scxcorelib::SCXHandle的用法示例。


在下文中一共展示了SCXHandle::Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateSolarisHelper

    /**
       Enumeration Helper for the Solaris platform. Not all disks are available from
       MNTTAB on this platform, this it is necessary to perform some additional
       searching of the file system.
    */
    void StaticPhysicalDiskEnumeration::UpdateSolarisHelper()
    {
        // workaround for unknown FS/devices
        // try to get a list of disks from /dev/dsk
        std::vector<SCXCoreLib::SCXHandle<SCXCoreLib::SCXFileInfo> > disk_infos = m_deps->GetDevDskInfo();
        std::map< std::wstring, int > found_devices;

        // iterate through all devices 
        for ( unsigned int i = 0; i < disk_infos.size(); i++ ){
            std::wstring dev_name = disk_infos[i]->GetFullPath().GetFilename();

            dev_name = dev_name.substr(0,dev_name.find_last_not_of(L"0123456789"));

            if ( found_devices.find( dev_name ) != found_devices.end() )
                continue; // already considered

            found_devices[dev_name] = 0;

            try {
                SCXCoreLib::SCXHandle<StaticPhysicalDiskInstance> disk = GetInstance(dev_name);

                if ( disk == 0 ){
                    disk = new StaticPhysicalDiskInstance(m_deps);
                    disk->SetId(dev_name);
                    disk->m_device = disk_infos[i]->GetDirectoryPath().Get() + dev_name;
                    disk->m_online = true;
                    // NOTE: Update will throw in case if disk is removable media, so 
                    // we will skip it (no call to AddInstance)
                    disk->Update();
                    AddInstance(disk);
                   
                } else {
                    disk->Update(); // check if disk is still 'alive'
                    // if disk goes off-line, Update throws and status remains 'false'
                    disk->m_online = true;
                }
            } catch ( SCXCoreLib::SCXException& e )
            {
                //std::wcout << L"excp in dsk update: " << e.What() << endl << e.Where() << endl;
                // ignore errors, since disk may not be accessible and it's fine
            }
        }
    }
开发者ID:Microsoft,项目名称:pal,代码行数:48,代码来源:staticphysicaldiskenumeration.cpp

示例2: UpdateInstances

    /**
       Update all instances.

    */
    void StatisticalLogicalDiskEnumeration::UpdateInstances()
    {
        scxulong total_reads = 0;
        scxulong total_writes = 0;
#if defined(hpux)
        scxulong total_tTime = 0;
#endif
        scxulong total_rTime = 0;
        scxulong total_wTime = 0;
        scxulong total_transfers = 0;
        scxulong total_rPercent = 0;
        scxulong total_wPercent = 0;
        scxulong total_tPercent = 0;
        SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> total = GetTotalInstance();
        if (0 != total)
        {
            total->Reset();
            total->m_online = true;
        }
        
        for (EntityIterator iter = Begin(); iter != End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter;
            disk->Update();
            if (0 != total)
            {
                total->m_readsPerSec += disk->m_readsPerSec;
                total->m_writesPerSec += disk->m_writesPerSec;
                total->m_transfersPerSec += disk->m_transfersPerSec;
                total->m_rBytesPerSec += disk->m_rBytesPerSec;
                total->m_wBytesPerSec += disk->m_wBytesPerSec;
                total->m_tBytesPerSec += disk->m_tBytesPerSec;
                total->m_rTime += disk->m_rTime;
                total->m_wTime += disk->m_wTime;
                total->m_tTime += disk->m_tTime;
                total->m_runTime += disk->m_runTime;
                total->m_waitTime += disk->m_waitTime;
                total->m_mbUsed += disk->m_mbUsed;
                total->m_mbFree += disk->m_mbFree;
                total_reads += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_writes += disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#if defined (hpux)
                total_transfers += disk->m_transfers.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_tTime += disk->m_tTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#elif defined (linux)
                total_transfers += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES) + disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_rTime += disk->m_rTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_wTime += disk->m_wTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#elif defined (sun)
                total_transfers += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES) + disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_rTime += disk->m_runTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_wTime += disk->m_waitTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#endif
                total_rPercent += disk->m_rPercentage;
                total_wPercent += disk->m_wPercentage;
                total_tPercent += disk->m_tPercentage;
            }
        }

        if (0 != total)
        {
            if (Size() > 0)
            {
                total->m_rPercentage = total_rPercent/Size();
                total->m_wPercentage = total_wPercent/Size();
                total->m_tPercentage = total_tPercent/Size();
            }
                    
            if (total_reads != 0)
            {
                total->m_secPerRead = static_cast<double>(total_rTime) / static_cast<double>(total_reads) / 1000.0;
            }
            if (total_writes != 0)
            {
                total->m_secPerWrite = static_cast<double>(total_wTime) / static_cast<double>(total_writes) / 1000.0;
            }
            if (total_transfers != 0)
            {
#if defined(hpux)
                total->m_secPerTransfer = static_cast<double>(total_tTime) / static_cast<double>(total_transfers) / 1000.0;
#elif defined(linux) || defined(sun)
                total->m_secPerTransfer = static_cast<double>(total_rTime+total_wTime) / static_cast<double>(total_transfers) / 1000.0;
#endif
            }
        }
    }
开发者ID:Microsoft,项目名称:SCVMMLinuxGuestAgent,代码行数:90,代码来源:statisticallogicaldiskenumeration.cpp

示例3: UpdateInstances

    /**
       Update all instances.

    */
    void StatisticalLogicalDiskEnumeration::UpdateInstances()
    {
        scxulong total_reads = 0;
        scxulong total_writes = 0;
#if defined(hpux)
        scxulong total_tTime = 0;
#endif
        scxulong total_rTime = 0;
        scxulong total_wTime = 0;
        scxulong total_transfers = 0;
        scxulong total_rPercent = 0;
        scxulong total_wPercent = 0;
        scxulong total_tPercent = 0;

        set<wstring> diskSet;
        pair<set<wstring>::iterator,bool> Pair;

        SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> total = GetTotalInstance();
        if (0 != total)
        {
            total->Reset();
            SCX_LOGTRACE(m_log, L"Device being set to ONLINE for TOTAL instance");
            total->m_online = true;
        }

        for (EntityIterator iter = Begin(); iter != End(); ++iter)
        {
            SCXCoreLib::SCXHandle<StatisticalLogicalDiskInstance> disk = *iter;
            disk->Update();

            Pair = diskSet.insert(disk->m_device);
            if(Pair.second == false)
                continue;

            if (0 != total)
            {
                total->m_readsPerSec += disk->m_readsPerSec;
                total->m_writesPerSec += disk->m_writesPerSec;
                total->m_transfersPerSec += disk->m_transfersPerSec;
                total->m_rBytesPerSec += disk->m_rBytesPerSec;
                total->m_wBytesPerSec += disk->m_wBytesPerSec;
                total->m_tBytesPerSec += disk->m_tBytesPerSec;
                total->m_rTime += disk->m_rTime;
                total->m_wTime += disk->m_wTime;
                total->m_tTime += disk->m_tTime;
                total->m_runTime += disk->m_runTime;
                total->m_waitTime += disk->m_waitTime;
                total->m_mbUsed += disk->m_mbUsed;
                total->m_mbFree += disk->m_mbFree;
                total_reads += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_writes += disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#if defined (hpux)
                total_transfers += disk->m_transfers.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_tTime += disk->m_tTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#elif defined (linux)
                total_transfers += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES) + disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_rTime += disk->m_rTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_wTime += disk->m_wTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#elif defined (sun)
                total_transfers += disk->m_reads.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES) + disk->m_writes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_rTime += disk->m_runTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
                total_wTime += disk->m_waitTimes.GetDelta(MAX_DISKINSTANCE_DATASAMPER_SAMPLES);
#endif
                total_rPercent += disk->m_rPercentage;
                total_wPercent += disk->m_wPercentage;
                total_tPercent += disk->m_tPercentage;
            }
        }

        if (0 != total)
        {
            if (Size() > 0)
            {
                total->m_rPercentage = total_rPercent/Size();
                total->m_wPercentage = total_wPercent/Size();
                total->m_tPercentage = total_tPercent/Size();
            }

            if (total_reads != 0)
            {
                total->m_secPerRead = static_cast<double>(total_rTime) / static_cast<double>(total_reads) / 1000.0;
            }
            if (total_writes != 0)
            {
                total->m_secPerWrite = static_cast<double>(total_wTime) / static_cast<double>(total_writes) / 1000.0;
            }
            if (total_transfers != 0)
            {
#if defined(hpux)
                total->m_secPerTransfer = static_cast<double>(total_tTime) / static_cast<double>(total_transfers) / 1000.0;
#elif defined(linux) || defined(sun)
                total->m_secPerTransfer = static_cast<double>(total_rTime+total_wTime) / static_cast<double>(total_transfers) / 1000.0;
#endif
            }
        }
    }
开发者ID:Microsoft,项目名称:pal,代码行数:100,代码来源:statisticallogicaldiskenumeration.cpp


注:本文中的scxcorelib::SCXHandle::Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。