VirtualBox

Ignore:
Timestamp:
Jul 4, 2018 6:49:59 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123446
Message:

ApplianceImpl.cpp: Lose the silly applianceIONameMap and associated stuff since it's unused and should've been a tiny switch statement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/ApplianceImpl.cpp

    r72898 r72899  
    3737using namespace std;
    3838
    39 ////////////////////////////////////////////////////////////////////////////////
    40 //
    41 // Appliance constructor / destructor
    42 //
    43 // ////////////////////////////////////////////////////////////////////////////////
    44 
    45 DEFINE_EMPTY_CTOR_DTOR(VirtualSystemDescription)
    46 
    47 HRESULT VirtualSystemDescription::FinalConstruct()
    48 {
    49     return BaseFinalConstruct();
    50 }
    51 
    52 void VirtualSystemDescription::FinalRelease()
    53 {
    54     uninit();
    55 
    56     BaseFinalRelease();
    57 }
    58 
    59 Appliance::Appliance()
    60     : mVirtualBox(NULL)
    61 {
    62 }
    63 
    64 Appliance::~Appliance()
    65 {
    66 }
    67 
    68 
    69 HRESULT Appliance::FinalConstruct()
    70 {
    71     return BaseFinalConstruct();
    72 }
    73 
    74 void Appliance::FinalRelease()
    75 {
    76     uninit();
    77 
    78     BaseFinalRelease();
    79 }
    80 
    81 
    82 ////////////////////////////////////////////////////////////////////////////////
    83 //
    84 // Internal helpers
    85 //
    86 ////////////////////////////////////////////////////////////////////////////////
    87 
    88 static const char* const strISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm";
    89 static const char* const strVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized";
    90 static const char* const strVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse";
    91 static const char* const strVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed";
    92 static const char* const strVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed";
    93 static const char* const strVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171";
     39
     40/*********************************************************************************************************************************
     41*   Global Variables                                                                                                             *
     42*********************************************************************************************************************************/
     43static const char * const g_pszISOURI = "http://www.ecma-international.org/publications/standards/Ecma-119.htm";
     44static const char * const g_pszVMDKStreamURI = "http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized";
     45static const char * const g_pszVMDKSparseURI = "http://www.vmware.com/specifications/vmdk.html#sparse";
     46static const char * const g_pszVMDKCompressedURI = "http://www.vmware.com/specifications/vmdk.html#compressed";
     47static const char * const g_pszVMDKCompressedURI2 = "http://www.vmware.com/interfaces/specifications/vmdk.html#compressed";
     48static const char * const g_pszrVHDURI = "http://go.microsoft.com/fwlink/?LinkId=137171";
    9449
    9550static std::map<Utf8Str, Utf8Str> supportedStandardsURI;
    96 
    97 static const char* const applianceIOTarName = "Appliance::IOTar";
    98 static const char* const applianceIOShaName = "Appliance::IOSha";
    99 static const char* const applianceIOFileName = "Appliance::IOFile";
    100 
    101 static std::map<APPLIANCEIONAME, Utf8Str> applianceIONameMap;
    10251
    10352static const struct
     
    10554    ovf::CIMOSType_T    cim;
    10655    VBOXOSTYPE          osType;
    107 }
    108 g_osTypes[] =
     56} g_aOsTypes[] =
    10957{
    11058    { ovf::CIMOSType_CIMOS_Unknown,                              VBOXOSTYPE_Unknown },
     
    219167
    220168/* These are the 32-Bit ones. They are sorted by priority. */
    221 static const osTypePattern g_osTypesPattern[] =
     169static const osTypePattern g_aOsTypesPattern[] =
    222170{
    223171    {"Windows NT",    VBOXOSTYPE_WinNT4},
     
    250198
    251199/* These are the 64-Bit ones. They are sorted by priority. */
    252 static const osTypePattern g_osTypesPattern64[] =
     200static const osTypePattern g_aOsTypesPattern64[] =
    253201{
    254202    {"Windows XP",    VBOXOSTYPE_WinXP_x64},
     
    282230    if (c == ovf::CIMOSType_CIMOS_Other)
    283231    {
    284         for (size_t i=0; i < RT_ELEMENTS(g_osTypesPattern); ++i)
    285             if (cStr.contains (g_osTypesPattern[i].pcszPattern, Utf8Str::CaseInsensitive))
     232        for (size_t i=0; i < RT_ELEMENTS(g_aOsTypesPattern); ++i)
     233            if (cStr.contains (g_aOsTypesPattern[i].pcszPattern, Utf8Str::CaseInsensitive))
    286234            {
    287                 strType = Global::OSTypeId(g_osTypesPattern[i].osType);
     235                strType = Global::OSTypeId(g_aOsTypesPattern[i].osType);
    288236                return;
    289237            }
     
    291239    else if (c == ovf::CIMOSType_CIMOS_Other_64)
    292240    {
    293         for (size_t i=0; i < RT_ELEMENTS(g_osTypesPattern64); ++i)
    294             if (cStr.contains (g_osTypesPattern64[i].pcszPattern, Utf8Str::CaseInsensitive))
     241        for (size_t i=0; i < RT_ELEMENTS(g_aOsTypesPattern64); ++i)
     242            if (cStr.contains (g_aOsTypesPattern64[i].pcszPattern, Utf8Str::CaseInsensitive))
    295243            {
    296                 strType = Global::OSTypeId(g_osTypesPattern64[i].osType);
     244                strType = Global::OSTypeId(g_aOsTypesPattern64[i].osType);
    297245                return;
    298246            }
    299247    }
    300248
    301     for (size_t i = 0; i < RT_ELEMENTS(g_osTypes); ++i)
    302     {
    303         if (c == g_osTypes[i].cim)
    304         {
    305             strType = Global::OSTypeId(g_osTypes[i].osType);
     249    for (size_t i = 0; i < RT_ELEMENTS(g_aOsTypes); ++i)
     250    {
     251        if (c == g_aOsTypes[i].cim)
     252        {
     253            strType = Global::OSTypeId(g_aOsTypes[i].osType);
    306254            return;
    307255        }
     
    324272ovf::CIMOSType_T convertVBoxOSType2CIMOSType(const char *pcszVBox, BOOL fLongMode)
    325273{
    326     for (size_t i = 0; i < RT_ELEMENTS(g_osTypes); ++i)
    327     {
    328         if (!RTStrICmp(pcszVBox, Global::OSTypeId(g_osTypes[i].osType)))
    329         {
    330             if (fLongMode && !(g_osTypes[i].osType & VBOXOSTYPE_x64))
     274    for (size_t i = 0; i < RT_ELEMENTS(g_aOsTypes); ++i)
     275    {
     276        if (!RTStrICmp(pcszVBox, Global::OSTypeId(g_aOsTypes[i].osType)))
     277        {
     278            if (fLongMode && !(g_aOsTypes[i].osType & VBOXOSTYPE_x64))
    331279            {
    332                 VBOXOSTYPE enmDesiredOsType = (VBOXOSTYPE)((int)g_osTypes[i].osType | (int)VBOXOSTYPE_x64);
     280                VBOXOSTYPE enmDesiredOsType = (VBOXOSTYPE)((int)g_aOsTypes[i].osType | (int)VBOXOSTYPE_x64);
    333281                size_t     j = i;
    334                 while (++j < RT_ELEMENTS(g_osTypes))
    335                     if (g_osTypes[j].osType == enmDesiredOsType)
    336                         return g_osTypes[j].cim;
     282                while (++j < RT_ELEMENTS(g_aOsTypes))
     283                    if (g_aOsTypes[j].osType == enmDesiredOsType)
     284                        return g_aOsTypes[j].cim;
    337285                j = i;
    338286                while (--j > 0)
    339                     if (g_osTypes[j].osType == enmDesiredOsType)
    340                         return g_osTypes[j].cim;
     287                    if (g_aOsTypes[j].osType == enmDesiredOsType)
     288                        return g_aOsTypes[j].cim;
    341289                /* Not all OSes have 64-bit versions, so just return the 32-bit variant. */
    342290            }
    343             return g_osTypes[i].cim;
     291            return g_aOsTypes[i].cim;
    344292        }
    345293    }
     
    364312}
    365313
     314
     315////////////////////////////////////////////////////////////////////////////////
     316//
     317// Appliance constructor / destructor
     318//
     319// ////////////////////////////////////////////////////////////////////////////////
     320
     321DEFINE_EMPTY_CTOR_DTOR(VirtualSystemDescription)
     322
     323HRESULT VirtualSystemDescription::FinalConstruct()
     324{
     325    return BaseFinalConstruct();
     326}
     327
     328void VirtualSystemDescription::FinalRelease()
     329{
     330    uninit();
     331
     332    BaseFinalRelease();
     333}
     334
     335Appliance::Appliance()
     336    : mVirtualBox(NULL)
     337{
     338}
     339
     340Appliance::~Appliance()
     341{
     342}
     343
     344
     345HRESULT Appliance::FinalConstruct()
     346{
     347    return BaseFinalConstruct();
     348}
     349
     350void Appliance::FinalRelease()
     351{
     352    uninit();
     353
     354    BaseFinalRelease();
     355}
     356
     357
     358////////////////////////////////////////////////////////////////////////////////
     359//
     360// Internal helpers
     361//
     362////////////////////////////////////////////////////////////////////////////////
     363
     364
    366365////////////////////////////////////////////////////////////////////////////////
    367366//
     
    411410    m->m_pSecretKeyStore = new SecretKeyStore(false /* fRequireNonPageable*/);
    412411    AssertReturn(m->m_pSecretKeyStore, E_FAIL);
    413 
    414     i_initApplianceIONameMap();
    415412
    416413    rc = i_initSetOfSupportedStandardsURI();
     
    706703        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
    707704
    708         supportedStandardsURI.insert(std::make_pair(Utf8Str(strISOURI), strTrgFormat));
     705        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszISOURI), strTrgFormat));
    709706    }
    710707
     
    720717        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
    721718
    722         supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKStreamURI), strTrgFormat));
    723         supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKSparseURI), strTrgFormat));
    724         supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI), strTrgFormat));
    725         supportedStandardsURI.insert(std::make_pair(Utf8Str(strVMDKCompressedURI2), strTrgFormat));
     719        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKStreamURI), strTrgFormat));
     720        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKSparseURI), strTrgFormat));
     721        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKCompressedURI), strTrgFormat));
     722        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszVMDKCompressedURI2), strTrgFormat));
    726723    }
    727724
     
    737734        Utf8Str strTrgFormat = Utf8Str(bstrFormatName);
    738735
    739         supportedStandardsURI.insert(std::make_pair(Utf8Str(strVHDURI), strTrgFormat));
     736        supportedStandardsURI.insert(std::make_pair(Utf8Str(g_pszrVHDURI), strTrgFormat));
    740737    }
    741738
     
    768765    return uri;
    769766}
    770 
    771 HRESULT Appliance::i_initApplianceIONameMap()
    772 {
    773     HRESULT rc = S_OK;
    774     if (!applianceIONameMap.empty())
    775         return rc;
    776 
    777     applianceIONameMap.insert(std::make_pair(applianceIOTar, applianceIOTarName));
    778     applianceIONameMap.insert(std::make_pair(applianceIOFile, applianceIOFileName));
    779     applianceIONameMap.insert(std::make_pair(applianceIOSha, applianceIOShaName));
    780 
    781     return rc;
    782 }
    783 
    784 Utf8Str Appliance::i_applianceIOName(APPLIANCEIONAME type) const
    785 {
    786     Utf8Str name;
    787     std::map<APPLIANCEIONAME, Utf8Str>::const_iterator cit = applianceIONameMap.find(type);
    788     if (cit != applianceIONameMap.end())
    789     {
    790         name = cit->second;
    791     }
    792 
    793     return name;
    794 }
    795 
    796767
    797768/**
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette