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


C++ scxcorelib::SCXHandle类代码示例

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


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

示例1: GetDHCPEnabledFromProcessList

    /**
        Get DHCPEnabled status from the process list
    */
    bool NetworkInterfaceConfigurationEnumeration::GetDHCPEnabledFromProcessList(
            std::wstring& name,
            SCXCoreLib::SCXHandle<NetworkInstanceConfigurationEnumerationDeps> deps)
    {
        ProcessEnumeration procEnum;
        procEnum.SampleData();
        procEnum.Update(true);

        std::vector<SCXCoreLib::SCXHandle<ProcessInstance> > proc_v = deps->Find(L"dhcpcd", procEnum); 
        if(proc_v.size() == 0)
          return false; 
        
        for(std::vector<SCXCoreLib::SCXHandle<ProcessInstance> >::iterator i = proc_v.begin(); i != proc_v.end(); ++i)
        {
             SCXCoreLib::SCXHandle<ProcessInstance> process = (*i);
             std::vector<std::string> parms;  
             if(!process->GetParameters(parms))
                  continue; 
            
             for(std::vector<std::string>::iterator i_parms = parms.begin(); i_parms != parms.end(); i_parms++)
               if(name.compare(SCXCoreLib::StrFromMultibyte(*i_parms)) == 0)
                 return true;
        } 
        
        return false;
    }
开发者ID:Microsoft,项目名称:SCVMMLinuxGuestAgent,代码行数:29,代码来源:networkinterfaceconfigurationenumeration.cpp

示例2: SCXCIMInstanceNotFound

    /**
      Lookup the instance representation, given keys provided from CIMOM

      \param[in]    keys   SCXInstance with property keys set
      \returns             Pointer to located instance

      \throws              SCXInvalidArgumentException
      \throws              SCXInternalErrorException
      \throws              SCXCIMInstanceNotFound   The instance with given keys cannot be found

      This method knows which the key properties of the entity are and returns
      pointer to that item if found.

    */
    SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> CPUProvider::FindInstance(const SCXInstance& keys) const // private
    {
        // Start by extracting all key properties
        const SCXProperty& nameprop = GetKeyRef(L"Name", keys);

        for(size_t i=0; i<m_cpus->Size(); i++)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> testinst = m_cpus->GetInstance(i);

            // Compare key values of input args and the current instance
            if (testinst->GetProcName() == nameprop.GetStrValue())
            {
                // Match
                return testinst;
            }
        }

        // As last resort, check if we the request is for the _Total instance
        if (m_cpus->GetTotalInstance() != 0 )
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::CPUInstance> testinst = m_cpus->GetTotalInstance();

            if (testinst->GetProcName() == nameprop.GetStrValue())
            {
                return testinst;
            }
        }

        throw SCXCIMInstanceNotFound(keys.DumpString(), SCXSRCLOCATION);
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:44,代码来源:cpuprovider.cpp

示例3: AddKeys

    /**
       Add a SCXInstance with the name property set frmo the ProcessInstance to the collection

       \param[in]   processinst    Process instance to get data from
       \param[out]  inst           Instance to add keys to
       \param[in]   cimtype        Type of CIM Class to return

       \throws      SCXInvalidArgumentException - The instance can not be converted to a ProcessInstance

       This method contains knowledge on which are the key fields for the class.
       The key properties are defined in the MOF file.

    */
    void ProcessProvider::AddKeys(SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst, SCXInstance &inst, SupportedCimClasses cimtype) // private
    {
        SCX_LOGTRACE(m_log, L"ProcessProvider AddKeys()");

        if (processinst == NULL)
        {
            throw SCXInvalidArgumentException(L"einst", L"Not a ProcessInstance", SCXSRCLOCATION);
        }

        scxulong pid;
        if (processinst->GetPID(pid))
        {
            SCXProperty pid_prop(L"Handle", StrFrom(pid));
            inst.AddKey(pid_prop);
        }

        AddScopingOperatingSystemKeys(inst);
        if (eSCX_UnixProcessStatisticalInformation == cimtype)
        {
            std::string name;
            if (processinst->GetName(name))
            {
                SCXProperty name_prop(L"Name", StrFromMultibyte(name));
                inst.AddKey(name_prop);
                SCXProperty creationClass_prop(L"ProcessCreationClassName", L"SCX_UnixProcessStatisticalInformation");
                inst.AddKey(creationClass_prop);
            }
        }
        else if (eSCX_UnixProcess == cimtype)
        {
            SCXProperty creationClass_prop(L"CreationClassName", L"SCX_UnixProcess");
            inst.AddKey(creationClass_prop);
        }

    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:48,代码来源:processprovider.cpp

示例4: callDumpStringForCoverage

 void callDumpStringForCoverage()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     CPPUNIT_ASSERT(thread->DumpString().find(L"SCXThread") != std::wstring::npos);
     thread->RequestTerminate();
     CPPUNIT_ASSERT(SCXCoreLib::SCXThreadParam().DumpString().find(L"SCXThreadParam") != std::wstring::npos);
 }
开发者ID:Microsoft,项目名称:pal,代码行数:7,代码来源:scxthread_test.cpp

示例5: TestStartTwiceFails

 void TestStartTwiceFails()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     SCXUNIT_ASSERT_THROWN_EXCEPTION(thread->Start(SCXThreadTest::SimpleThreadBodyTerminate), SCXCoreLib::SCXThreadStartException, L"started");
     thread->RequestTerminate();
     thread->Wait();
 }
开发者ID:Microsoft,项目名称:pal,代码行数:7,代码来源:scxthread_test.cpp

示例6: EnumerateOneInstance

MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
                          SCX_LANEndpoint_Class& inst, bool keysOnly,
                          SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf)
{
    // Add the key properperties first.
    inst.CreationClassName_value("SCX_LANEndpoint");
    inst.Name_value(StrToMultibyte(intf->GetName()).c_str());

    // Add the scoping systems keys.
    inst.SystemCreationClassName_value("SCX_ComputerSystem");
    SCXCoreLib::NameResolver mi;
    inst.SystemName_value(StrToMultibyte(mi.GetHostDomainname()).c_str());
    if (!keysOnly)
    {
        inst.InstanceID_value(StrToMultibyte(intf->GetName()).c_str());
        inst.Caption_value("LAN endpoint caption information");
        inst.Description_value("LAN Endpoint description information");
        
        inst.ElementName_value(StrToMultibyte(intf->GetName()).c_str());

        std::wstring text;
        if(intf->GetMACAddressRAW(text))
        {
            inst.MACAddress_value(StrToMultibyte(text).c_str());
            intf->GetMACAddress(text, '-', true);
            inst.FormattedMACAddress_value(StrToMultibyte(text).c_str());
        }
    }
    context.Post(inst);
}
开发者ID:Microsoft,项目名称:SCXcore,代码行数:32,代码来源:SCX_LANEndpoint_Class_Provider.cpp

示例7: TestThreadExceptionHaveCorrectThreadID

 void TestThreadExceptionHaveCorrectThreadID()
 {
     SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
     try {
         thread->Start(SCXThreadTest::SimpleThreadBodyTerminate);
         CPPUNIT_FAIL("Expected exception not thrown: SCXThreadStartException");
     } catch (SCXCoreLib::SCXThreadStartException& e) {
         CPPUNIT_ASSERT_EQUAL(SCXCoreLib::SCXThread::GetCurrentThreadID(), e.GetThreadID());
     }
 }
开发者ID:Microsoft,项目名称:pal,代码行数:10,代码来源:scxthread_test.cpp

示例8: FindPhysicalDisks

    /**
       Discover physical disks.

       Logical disks are identified by the /etc/mnttab file (by design). Physical
       disks discovered will be those "hosting" the logical disks found. If ever
       seen in that file, the disk will be discovered. If the disk is removed it
       will be marked as offline.

       How to identify physical disks from logical disks:

       Linux --

       Logical disks are named things like /dev/hda0, /dev/hda1 and so on.
       The numeric value in the end of the name is the partition/logical ID
       of the physical disk. In the example above both logical disks are on
       physical disk /dev/hda.

       For LVM partitions on Linux have two entries for the same device.  An LVM
       device entry is stored in the /dev/mapper directory with a name in the form
       <logical-volume-group>-<logical-volume>.  There is also a device mapper (dm)
       device entry stored in the /dev directory in the form dm-<id>.  This is a
       1-to-1 relationship and the <id> is equal to the device minor ID that both
       device entries have in common.  Discovery of the physical device(s) that
       contain the LVM partition is done by mapping the LVM device to the dm device,
       then looking at the dm devices slave entries in Sysfs, and then finally
       performing the same conversion from a logical Linux partition name to a
       physical drive name that is done for all other partitions.

       Solaris --

       Logical disks are named things like /dev/dsk/c1t0d0s0, /dev/dsk/c1t0d0s1
       and so on. The last letter/numeric pair is the partition/logical ID
       of the physical disk. In the example above both logical disks are on
       physical disk /dev/dsk/c1t0d0.

       HPUX --

       Logical disks are logical volumes with names like /dev/vg00/lvol3.
       /dev/vg00 in the example name is the volume group name. Using the /etc/lvmtab
       file the volume group can be translated to a partition named /dev/disk/disk3_p2
       (or /dev/dsk/c2t0d0s2 using a naming standard deprecated as of HPUX 11.3). The
       old naming standard works like the one for solaris while the new one identifies
       the physical disk as /dev/disk/disk3 in the example above.

       AIX --

       TODO: Document how disks are enumerated on AIX.
    */
    void StatisticalPhysicalDiskEnumeration::FindPhysicalDisks()
    {
        for (EntityIterator iter=Begin(); iter!=End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = *iter;
            disk->m_online = false;
        }

        m_deps->RefreshMNTTab();
        for (std::vector<MntTabEntry>::const_iterator it = m_deps->GetMNTTab().begin();
             it != m_deps->GetMNTTab().end(); it++)
        {
            if ( ! m_deps->FileSystemIgnored(it->fileSystem) &&
                 ! m_deps->DeviceIgnored(it->device) &&
                 m_deps->LinkToPhysicalExists(it->fileSystem, it->device, it->mountPoint) )
            {
                std::map<std::wstring, std::wstring> devices = m_deps->GetPhysicalDevices(it->device);
                if (devices.size() == 0)
                {
                    static SCXCoreLib::LogSuppressor suppressor(SCXCoreLib::eError, SCXCoreLib::eTrace);
                    std::wstringstream               out;

                    out << L"Unable to locate physical devices for: " << it->device;
                    SCX_LOG(m_log, suppressor.GetSeverity(out.str()), out.str());
                    continue;
                }
                for (std::map<std::wstring, std::wstring>::const_iterator dev_it = devices.begin();
                     dev_it != devices.end(); dev_it++)
                {
                    SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = AddDiskInstance(dev_it->first, dev_it->second);
#if defined(hpux)
                    if (0 != disk)
                    {
                        if (m_pathToRdev.end() == m_pathToRdev.find(disk->m_device))
                        {
                            SCXCoreLib::SCXFilePath fp(disk->m_device);
                            fp.SetFilename(L"");
                            UpdatePathToRdev(fp.Get());
                        }
                        SCXASSERT(m_pathToRdev.end() != m_pathToRdev.find(disk->m_device));

                        scxlong diskInfoIndex = disk->FindDiskInfoByID(m_pathToRdev.find(disk->m_device)->second);
                        m_deps->AddDeviceInstance(disk->m_device, L"", diskInfoIndex, m_pathToRdev.find(disk->m_device)->second);
                    }
#endif
                }
            }
        }

#if defined(sun)
        this->UpdateSolarisHelper();
#endif
//.........这里部分代码省略.........
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:101,代码来源:statisticalphysicaldiskenumeration.cpp

示例9: TestThreadTerminate

    void TestThreadTerminate(void)
    {
        // Test terminating a thread
        SCXCoreLib::SCXHandle<SCXCoreLib::SCXThread> thread = GivenARunningThread();
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
        time_t later = time(NULL) + 10;
        while (thread->IsAlive() && later > time(NULL))
            SCXCoreLib::SCXThread::Sleep(10);
        CPPUNIT_ASSERT_MESSAGE("Thread did not terminate", ! thread->IsAlive());

        // terminate again
        CPPUNIT_ASSERT_NO_THROW(thread->RequestTerminate());
    }
开发者ID:Microsoft,项目名称:pal,代码行数:13,代码来源:scxthread_test.cpp

示例10: SampleDisks

    /**
       Store sample data for all instances in collection.

    */
    void StatisticalPhysicalDiskEnumeration::SampleDisks()
    {
        SCXCoreLib::SCXThreadLock lock(m_lock);
#if defined(linux)
        m_deps->RefreshProcDiskStats();
#endif
        for (EntityIterator iter = Begin(); iter != End(); iter++)
        {
            SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = *iter;

            disk->Sample();
        }
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:17,代码来源:statisticalphysicaldiskenumeration.cpp

示例11: SCXInvalidStateException

    /**
      Lookup the instance representation, given keys provided from CIMOM

      \param[in]    keys   SCXInstance with property keys set
      \returns             Pointer to located instance

      \throws              SCXInvalidArgumentException
      \throws              SCXInternalErrorException
      \throws              SCXCIMInstanceNotFound   The instance with given keys cannot be found

      This method knows which the key properties of the entity are and returns
      pointer to that item if found.

    */
    SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> ProcessProvider::FindInstance(const SCXInstance& keys) const // private
    {
        // Start by extracting all key properties
        ValidateScopingOperatingSystemKeys(keys);
        SupportedCimClasses cimtype = static_cast<SupportedCimClasses>(m_ProviderCapabilities.GetCimClassId(keys));
        if (eSCX_UnixProcessStatisticalInformation == cimtype) {
            ValidateKeyValue(L"ProcessCreationClassName", keys, L"SCX_UnixProcessStatisticalInformation");
            GetKeyRef(L"Name", keys);
        } else if (eSCX_UnixProcess == cimtype) {
            ValidateKeyValue(L"CreationClassName", keys, L"SCX_UnixProcess");
        } else {
            throw SCXInvalidStateException(L"Unknown cimtype value", SCXSRCLOCATION);
        }

        const SCXProperty &pidprop = GetKeyRef(L"Handle", keys);
        scxulong pid;

        for(size_t i=0; i<m_processes->Size(); i++)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> testinst = m_processes->GetInstance(i);
            if (testinst == NULL)
            {
                throw SCXInternalErrorException(L"Instance from list not an ProcessInstance", SCXSRCLOCATION);
            }
            // Compare key values of input args and the current instance
            testinst->GetPID(pid);
            if (StrFrom(pid) == pidprop.GetStrValue())
            {
                // Match
                return testinst;
            }
        }

        // As last resort, check if we the request is for the _Total instance
        if (m_processes->GetTotalInstance() != 0)
        {
            SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> testinst = m_processes->GetTotalInstance();
            if (testinst == NULL)
            {
                throw SCXInternalErrorException(L"Total instance not a ProcessInstance", SCXSRCLOCATION);
            }
            testinst->GetPID(pid);
            if (StrFrom(pid) == pidprop.GetStrValue())
            {
                return testinst;
            }
        }


        throw SCXCIMInstanceNotFound(keys.DumpString(), SCXSRCLOCATION);
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:65,代码来源:processprovider.cpp

示例12: GetResource

    /**
        Get the value for the spcified resource from a specified instance

        \param[in]     resource      Name of resource to get
        \param[in]     processinst   Instance to get resource from

        \returns       Value for specifed resource

        \throws        SCXInternalErrorException    If given resource not handled
    */
    scxulong ProcessProvider::GetResource(const std::wstring &resource, SCXCoreLib::SCXHandle<SCXSystemLib::ProcessInstance> processinst)
    {
        scxulong res = 0;
        bool gotResource = false;

        if (StrCompare(resource, L"CPUTime", true) == 0)
        {
            unsigned int cputime;
            gotResource = processinst->GetCPUTime(cputime);
            res = static_cast<scxulong>(cputime);
        }
        else if (StrCompare(resource, L"BlockReadsPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockReadsPerSecond(res);
        }
        else if (StrCompare(resource, L"BlockWritesPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockWritesPerSecond(res);
        }
        else if (StrCompare(resource, L"BlockTransfersPerSecond", true) == 0)
        {
            gotResource = processinst->GetBlockTransfersPerSecond(res);
        }
        else if (StrCompare(resource, L"PercentUserTime", true) == 0)
        {
            gotResource = processinst->GetPercentUserTime(res);
        }
        else if (StrCompare(resource, L"PercentPrivilegedTime", true) == 0)
        {
            gotResource = processinst->GetPercentPrivilegedTime(res);
        }
        else if (StrCompare(resource, L"UsedMemory", true) == 0)
        {
            gotResource = processinst->GetUsedMemory(res);
        }
        else if (StrCompare(resource, L"PercentUsedMemory", true) == 0)
        {
            gotResource = processinst->GetPercentUsedMemory(res);
        }
        else if (StrCompare(resource, L"PagesReadPerSec", true) == 0)
        {
            gotResource = processinst->GetPagesReadPerSec(res);
        }
        else
        {
            throw UnknownResourceException(resource, SCXSRCLOCATION);
        }

        if ( ! gotResource)
        {
            throw SCXInternalErrorException(StrAppend(L"GetResource: Failed to get resouce: ", resource), SCXSRCLOCATION);
        }

        return res;
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:65,代码来源:processprovider.cpp

示例13: EnumerateOneInstance

MI_BEGIN_NAMESPACE

static void EnumerateOneInstance(Context& context,
                          SCX_EthernetPortStatistics_Class& inst, bool keysOnly,
                          SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf)
{
    // Add the key properperties first.
    inst.InstanceID_value(StrToMultibyte(intf->GetName()).c_str());

    if (!keysOnly)
    {
        inst.Caption_value("Ethernet port information");
        inst.Description_value("Statistics on transfer performance for a port");

        scxulong ulong = 0;
        scxulong bytesReceived = intf->GetBytesReceived(ulong) ? ulong : 0;
        inst.BytesReceived_value(bytesReceived);

        scxulong bytesTransmitted = intf->GetBytesSent(ulong) ? ulong : 0;
        inst.BytesTransmitted_value(bytesTransmitted);

        inst.BytesTotal_value(bytesReceived + bytesTransmitted);

        inst.PacketsReceived_value(intf->GetPacketsReceived(ulong) ? ulong : 0);
        inst.PacketsTransmitted_value(intf->GetPacketsSent(ulong) ? ulong : 0);

        inst.TotalTxErrors_value(intf->GetErrorsSending(ulong) ? ulong : 0);

        inst.TotalRxErrors_value(intf->GetErrorsReceiving(ulong) ? ulong : 0);

        inst.TotalCollisions_value(intf->GetCollisions(ulong) ? ulong : 0);
    }
    context.Post(inst);
}
开发者ID:Microsoft,项目名称:SCXcore,代码行数:34,代码来源:SCX_EthernetPortStatistics_Class_Provider.cpp

示例14: string

    /**
       Add a new disk instacne if it does not already exist.

       \param   name name of instance.
       \param   device device string (only used if new instance created).
       \returns NULL if a disk with the given name already exists - otherwise the new disk.

       \note The disk will be marked as online if found.
    */
    SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> StatisticalPhysicalDiskEnumeration::AddDiskInstance(const std::wstring& name, const std::wstring& device)
    {
        SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance> disk = FindDiskByDevice(name);
        if (0 == disk)
        {
            disk = new StatisticalPhysicalDiskInstance(m_deps);
            disk->SetId(name);
            disk->m_device = device;
            disk->m_online = true;
            AddInstance(disk);
            return disk;
        }
        disk->m_online = true;
        return SCXCoreLib::SCXHandle<StatisticalPhysicalDiskInstance>(0);
    }
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:24,代码来源:statisticalphysicaldiskenumeration.cpp

示例15: GetEnabledState

//! Determine enabled state according to CIM
//! \param[in]   intf    Interface in question
static unsigned short GetEnabledState(SCXCoreLib::SCXHandle<SCXSystemLib::NetworkInterfaceInstance> intf) 
{
    enum {eUnknown = 0, eEnabled = 2, eDisabled = 3, eEnabledButOffline = 6} enabledState = eUnknown;
    bool up = false;
    bool running = false;
    bool knownIfUp = intf->GetUp(up);
    bool knownIfRunning = intf->GetRunning(running);
    if (knownIfUp && knownIfRunning) {
        if (up) {
            enabledState = eEnabled;
        } else {
            enabledState = running ? eEnabledButOffline : eDisabled;
        }
    }
    return enabledState;
}
开发者ID:Microsoft,项目名称:SCXcore,代码行数:18,代码来源:SCX_IPProtocolEndpoint_Class_Provider.cpp


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