VirtualBox

Changeset 31464 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Aug 9, 2010 9:15:40 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
64546
Message:

Main: support per-machine media registries in XML settings (not yet used)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/settings.h

    r31303 r31464  
    6060
    6161class ConfigFileError;
    62 
    63 ////////////////////////////////////////////////////////////////////////////////
    64 //
    65 // Helper classes
    66 //
    67 ////////////////////////////////////////////////////////////////////////////////
    68 
    69 // ExtraDataItem (used by both VirtualBox.xml and machines XML)
    70 typedef std::map<com::Utf8Str, com::Utf8Str> ExtraDataItemsMap;
    71 struct USBDeviceFilter;
    72 typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
    73 
    74 /**
    75  * Common base class for both MainConfigFile and MachineConfigFile
    76  * which contains some common logic for both.
    77  */
    78 class ConfigFileBase
    79 {
    80 public:
    81     bool fileExists();
    82 
    83     void copyBaseFrom(const ConfigFileBase &b);
    84 
    85 protected:
    86     ConfigFileBase(const com::Utf8Str *pstrFilename);
    87     ~ConfigFileBase();
    88 
    89     void parseUUID(com::Guid &guid,
    90                    const com::Utf8Str &strUUID) const;
    91     void parseTimestamp(RTTIMESPEC &timestamp,
    92                         const com::Utf8Str &str) const;
    93 
    94     com::Utf8Str makeString(const RTTIMESPEC &tm);
    95 
    96     void readExtraData(const xml::ElementNode &elmExtraData,
    97                        ExtraDataItemsMap &map);
    98     void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
    99                               USBDeviceFiltersList &ll);
    100 
    101     void setVersionAttribute(xml::ElementNode &elm);
    102     void createStubDocument();
    103 
    104     void writeExtraData(xml::ElementNode &elmParent, const ExtraDataItemsMap &me);
    105     void writeUSBDeviceFilters(xml::ElementNode &elmParent,
    106                                const USBDeviceFiltersList &ll,
    107                                bool fHostMode);
    108 
    109     void clearDocument();
    110 
    111     struct Data;
    112     Data *m;
    113 
    114 private:
    115     // prohibit copying (Data contains pointers to XML which cannot be copied)
    116     ConfigFileBase(const ConfigFileBase&);
    117 
    118     friend class ConfigFileError;
    119 };
    12062
    12163////////////////////////////////////////////////////////////////////////////////
     
    15799};
    158100
     101typedef std::map<com::Utf8Str, com::Utf8Str> PropertiesMap;
     102
     103// ExtraDataItem (used by both VirtualBox.xml and machines XML)
     104typedef std::map<com::Utf8Str, com::Utf8Str> ExtraDataItemsMap;
     105struct USBDeviceFilter;
     106typedef std::list<USBDeviceFilter> USBDeviceFiltersList;
     107
     108struct Medium;
     109typedef std::list<Medium> MediaList;
     110
     111/**
     112 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     113 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     114 * your settings might never get saved.
     115 */
     116struct Medium
     117{
     118    com::Guid       uuid;
     119    com::Utf8Str    strLocation;
     120    com::Utf8Str    strDescription;
     121
     122    // the following are for hard disks only:
     123    com::Utf8Str    strFormat;
     124    bool            fAutoReset;         // optional, only for diffs, default is false
     125    PropertiesMap   properties;
     126    MediumType_T    hdType;
     127
     128    MediaList       llChildren;         // only used with hard disks
     129
     130    bool operator==(const Medium &m) const;
     131};
     132
     133/**
     134 * NOTE: If you add any fields in here, you must update a) the constructor and b)
     135 * the operator== which is used by MachineConfigFile::operator==(), or otherwise
     136 * your settings might never get saved.
     137 */
     138struct MediaRegistry
     139{
     140    MediaList               llHardDisks,
     141                            llDvdImages,
     142                            llFloppyImages;
     143
     144    bool operator==(const MediaRegistry &m) const;
     145};
     146
     147/**
     148 * Common base class for both MainConfigFile and MachineConfigFile
     149 * which contains some common logic for both.
     150 */
     151class ConfigFileBase
     152{
     153public:
     154    bool fileExists();
     155
     156    void copyBaseFrom(const ConfigFileBase &b);
     157
     158protected:
     159    ConfigFileBase(const com::Utf8Str *pstrFilename);
     160    ~ConfigFileBase();
     161
     162    void parseUUID(com::Guid &guid,
     163                   const com::Utf8Str &strUUID) const;
     164    void parseTimestamp(RTTIMESPEC &timestamp,
     165                        const com::Utf8Str &str) const;
     166
     167    com::Utf8Str makeString(const RTTIMESPEC &tm);
     168
     169    void readExtraData(const xml::ElementNode &elmExtraData,
     170                       ExtraDataItemsMap &map);
     171    void readUSBDeviceFilters(const xml::ElementNode &elmDeviceFilters,
     172                              USBDeviceFiltersList &ll);
     173    typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
     174    void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia);
     175    void readMediaRegistry(const xml::ElementNode &elmMediaRegistry, MediaRegistry &mr);
     176
     177    void setVersionAttribute(xml::ElementNode &elm);
     178    void createStubDocument();
     179
     180    void buildExtraData(xml::ElementNode &elmParent, const ExtraDataItemsMap &me);
     181    void buildUSBDeviceFilters(xml::ElementNode &elmParent,
     182                               const USBDeviceFiltersList &ll,
     183                               bool fHostMode);
     184    void buildHardDisk(xml::ElementNode &elmMedium,
     185                       const Medium &m,
     186                       uint32_t level);
     187    void buildMediaRegistry(xml::ElementNode &elmParent,
     188                            const MediaRegistry &mr);
     189    void clearDocument();
     190
     191    struct Data;
     192    Data *m;
     193
     194private:
     195    // prohibit copying (Data contains pointers to XML which cannot be copied)
     196    ConfigFileBase(const ConfigFileBase&);
     197
     198    friend class ConfigFileError;
     199};
     200
    159201////////////////////////////////////////////////////////////////////////////////
    160202//
     
    182224};
    183225
    184 typedef std::map<com::Utf8Str, com::Utf8Str> PropertiesMap;
    185 
    186 struct Medium;
    187 typedef std::list<Medium> MediaList;
    188 
    189 struct Medium
    190 {
    191     com::Guid       uuid;
    192     com::Utf8Str    strLocation;
    193     com::Utf8Str    strDescription;
    194 
    195     // the following are for hard disks only:
    196     com::Utf8Str    strFormat;
    197     bool            fAutoReset;         // optional, only for diffs, default is false
    198     PropertiesMap   properties;
    199     MediumType_T    hdType;
    200 
    201     MediaList       llChildren;         // only used with hard disks
    202 };
    203 
    204226struct MachineRegistryEntry
    205227{
     
    225247    MainConfigFile(const com::Utf8Str *pstrFilename);
    226248
    227     typedef enum {Error, HardDisk, DVDImage, FloppyImage} MediaType;
    228     void readMedium(MediaType t, const xml::ElementNode &elmMedium, MediaList &llMedia);
    229     void readMediaRegistry(const xml::ElementNode &elmMediaRegistry);
    230249    void readMachineRegistry(const xml::ElementNode &elmMachineRegistry);
    231250    void readDHCPServers(const xml::ElementNode &elmDHCPServers);
    232251
    233     void writeHardDisk(xml::ElementNode &elmMedium,
    234                        const Medium &m,
    235                        uint32_t level);
    236252    void write(const com::Utf8Str strFilename);
    237253
    238254    Host                    host;
    239255    SystemProperties        systemProperties;
    240     MediaList               llHardDisks,
    241                             llDvdImages,
    242                             llFloppyImages;
     256    MediaRegistry           mediaRegistry;
    243257    MachinesRegistry        llMachines;
    244258    DHCPServersList         llDhcpServers;
     
    865879    Hardware                hardwareMachine;
    866880    Storage                 storageMachine;
     881    MediaRegistry           mediaRegistry;
    867882
    868883    ExtraDataItemsMap       mapExtraDataItems;
     
    882897        BuildMachineXML_IncludeSnapshots = 0x01,
    883898        BuildMachineXML_WriteVboxVersionAttribute = 0x02,
    884         BuildMachineXML_SkipRemovableMedia = 0x02
     899        BuildMachineXML_SkipRemovableMedia = 0x04,
     900        BuildMachineXML_MediaRegistry = 0x08
    885901    };
    886902    void buildMachineXML(xml::ElementNode &elmMachine,
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