⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 software.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            extendedVersionSupplied = true;            majorValue.get(majorVersion);            minorVersion = 0;            revisionNumber = 0;            buildNumber = 0;            // Get the Version if present            Uint32 index = providerInstance.findProperty(                PROVIDERMODULE_PROPERTY_VERSION);            if(index != PEG_NOT_FOUND)            {                CIMValue propValue =                  providerInstance.getProperty(index).getValue();                if(!propValue.isNull())                {                    propValue.get(version);                }            }            // Get the Minor version if present            index = providerInstance.findProperty(                PROVIDERMODULE_PROPERTY_MINORVERSION);            if(index != PEG_NOT_FOUND)            {                CIMValue propValue =                  providerInstance.getProperty(index).getValue();                if(!propValue.isNull())                {                    propValue.get(minorVersion);                }            }            // Get the revision number if present            index = providerInstance.findProperty(                PROVIDERMODULE_PROPERTY_REVISIONNUMBER);            if(index != PEG_NOT_FOUND)            {                CIMValue propValue =                  providerInstance.getProperty(index).getValue();                if(!propValue.isNull())                {                    propValue.get(revisionNumber);                }            }            // Get the build number if present            index = providerInstance.findProperty(                    PROVIDERMODULE_PROPERTY_BUILDNUMBER);            if(index != PEG_NOT_FOUND)            {                CIMValue propValue =                  providerInstance.getProperty(index).getValue();                if(!propValue.isNull())                {                    propValue.get(buildNumber);                }            }        }    }}//// Method that enumerates instances of the PG_SoftwareIdentity class. There// should be one instance for every provider registered with the CIMOM, i.e.// one for every instance of PG_Provider in the interop namespace in the// repository.//Array<CIMInstance> InteropProvider::enumSoftwareIdentityInstances(){    Array<CIMInstance> instances;    Array<CIMInstance> registeredProviders = repository->enumerateInstancesForClass(        PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PROVIDER);    for(Uint32 i = 0, n = registeredProviders.size(); i < n; ++i)    {        String moduleName;        String providerName;        String version;        String vendor;        String interfaceType;        Uint16 majorVersion;        Uint16 minorVersion;        Uint16 revisionNumber;        Uint16 buildNumber;        String elementName;        String caption;        bool extendedVersionInfo;        extractSoftwareIdentityInfo(registeredProviders[i], moduleName,            providerName, vendor, version, majorVersion, minorVersion,            revisionNumber, buildNumber, extendedVersionInfo, interfaceType,            elementName, caption);        instances.append(buildSoftwareIdentity(moduleName, providerName,            vendor, version, majorVersion, minorVersion, revisionNumber,            buildNumber, extendedVersionInfo, interfaceType, elementName,            caption));    }    // Always have the Interop provider    instances.append(buildSoftwareIdentity(PEGASUS_MODULE_NAME,        INTEROP_PROVIDER_NAME, PEGASUS_CIMOM_GENERIC_NAME,        PEGASUS_PRODUCT_VERSION,        0, 0, 0, 0, false, // no extended revision info        PEGASUS_INTERNAL_PROVIDER_TYPE, String::EMPTY, String::EMPTY));    return instances;}//// Enumerates instances of the ElementSoftwareIdentity association class. There// will be one instance for each profile and subprofile contained in an// instance of ProviderProfileCapabilities.//Array<CIMInstance> InteropProvider::enumElementSoftwareIdentityInstances(){    Array<CIMInstance> instances;    Array<CIMInstance> profileCapabilities = repository->enumerateInstancesForClass(        PEGASUS_NAMESPACENAME_INTEROP,        PEGASUS_CLASSNAME_PG_PROVIDERPROFILECAPABILITIES);    CIMClass elementSoftwareIdentityClass = repository->getClass(        PEGASUS_NAMESPACENAME_INTEROP,        PEGASUS_CLASSNAME_PG_ELEMENTSOFTWAREIDENTITY, false, true, false);    CIMClass registeredProfileClass = repository->getClass(        PEGASUS_NAMESPACENAME_INTEROP, PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE,        false, true, false);    for(Uint32 i = 0, n = profileCapabilities.size(); i < n; ++i)    {        CIMInstance & currentCapabilities = profileCapabilities[i];        String version;        String organizationName;        Array<String> subprofiles;        String dummyStr;        Uint16 dummyInt = 0;        Array<Uint16> dummyIntArray;        Array<String> subprofileVersions;        Array<String> subprofileOrgs;        String profileId = extractProfileInfo(currentCapabilities,            profileCapabilitiesClass,            registeredProfileClass,            dummyStr, // Throw away profile name            version,            dummyInt, // Throw away organization enum            organizationName,            subprofiles,            subprofileVersions,            dummyIntArray, // Throw away subprofile organization enums            subprofileOrgs,            false); // Get subprofile information        String moduleName = getRequiredValue<String>(currentCapabilities,            CAPABILITIES_PROPERTY_PROVIDERMODULENAME);        String providerName = getRequiredValue<String>(currentCapabilities,            CAPABILITIES_PROPERTY_PROVIDERNAME);        String softwareInstanceId = moduleName + "+" + providerName;        // Create an association between the Provider's SoftwareIdentity and        // this Registered Profile.        instances.append(buildDependencyInstance(            softwareInstanceId,            PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY,            profileId,            PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE,            elementSoftwareIdentityClass));        // Loop through the subprofile info and create associations between        // the Provider's SoftwareIdentity and the Registered Subprofiles.        for(Uint32 j = 0, m = subprofiles.size(); j < m; ++j)        {            String subprofileVersion;            if(subprofileVersions.size() == 0)            {                subprofileVersion = version;            }            else            {                subprofileVersion = subprofileVersions[j];            }            instances.append(buildDependencyInstance(                softwareInstanceId,                PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY,                buildProfileInstanceId(subprofileOrgs[j], subprofiles[j],                    subprofileVersion),                PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE,                elementSoftwareIdentityClass));        }    }    // Create default association between Server profile, Indications    // subprofile, and the Pegasus Interoperability provider software identity    String interopSoftwareIdentity = PEGASUS_MODULE_NAME + "+" +        INTEROP_PROVIDER_NAME;    String serverProfileId = buildProfileInstanceId(SNIA_NAME, "Server",        SNIA_VER_110);    String indicationProfileId = buildProfileInstanceId(SNIA_NAME,        "Indication", SNIA_VER_110);    String softwareProfileId = buildProfileInstanceId(SNIA_NAME,        "Software", SNIA_VER_110);    instances.append(buildDependencyInstance(interopSoftwareIdentity,        PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, serverProfileId,        PEGASUS_CLASSNAME_PG_REGISTEREDPROFILE,        elementSoftwareIdentityClass));    instances.append(buildDependencyInstance(interopSoftwareIdentity,        PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, indicationProfileId,        PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE,        elementSoftwareIdentityClass));    instances.append(buildDependencyInstance(interopSoftwareIdentity,        PEGASUS_CLASSNAME_PG_SOFTWAREIDENTITY, softwareProfileId,        PEGASUS_CLASSNAME_PG_REGISTEREDSUBPROFILE,        elementSoftwareIdentityClass));    return instances;}//// Enumerates instances of the InstalledSoftwareIdentity association class.//Array<CIMInstance> InteropProvider::enumInstalledSoftwareIdentityInstances(){    // All of the software identity instances are associated to the    // ComputerSystem on which the object manager resides. Simply loop through    // all the instances and build the association.    Array<CIMInstance> instances;    CIMObjectPath csPath = getComputerSystemInstance().getPath();    Array<CIMInstance> softwareInstances = enumSoftwareIdentityInstances();    CIMClass installedSoftwareClass;    CIMInstance skeletonInst =  buildInstanceSkeleton(        PEGASUS_NAMESPACENAME_INTEROP,        PEGASUS_CLASSNAME_PG_INSTALLEDSOFTWAREIDENTITY, installedSoftwareClass);    for(Uint32 i = 0, n = softwareInstances.size(); i < n; ++i)    {        CIMInstance installedSoftwareInstance = skeletonInst.clone();        setPropertyValue(installedSoftwareInstance,            INSTALLEDSOFTWAREIDENTITY_PROPERTY_INSTALLEDSOFTWARE,            CIMValue(softwareInstances[i].getPath()));        setPropertyValue(installedSoftwareInstance,            INSTALLEDSOFTWAREIDENTITY_PROPERTY_SYSTEM,            CIMValue(csPath));        installedSoftwareInstance.setPath(installedSoftwareInstance.buildPath(            installedSoftwareClass));        instances.append(installedSoftwareInstance);    }    return instances;}PEGASUS_NAMESPACE_END// END_OF_FILE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -