VirtualBox

Changeset 7388 in vbox


Ignore:
Timestamp:
Mar 9, 2008 11:54:16 PM (17 years ago)
Author:
vboxsync
Message:

Main/Settings: Perform conversion in a loop to allow for multi-step version to version updates (e.g. v1.0->v1.1->v1.2) which saves from patching all previous transformation rules when on every version change but still makes it possible to update from too old versions to the most recent one.

File:
1 edited

Legend:

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

    r7315 r7388  
    12991299
    13001300    /**
     1301     * The Error class represents errors that may happen when parsing or
     1302     * validating the XML document representing the settings tree.
     1303     */
     1304    class VBOXSETTINGS_CLASS Error : public RuntimeError
     1305    {
     1306    public:
     1307
     1308        Error (const char *aMsg = NULL) : RuntimeError (aMsg) {}
     1309    };
     1310
     1311    /**
     1312     * The EConversionCycle class represents a conversion cycle detected by the
     1313     * AutoConverter::needsConversion() implementation.
     1314     */
     1315    class VBOXSETTINGS_CLASS EConversionCycle : public Error
     1316    {
     1317    public:
     1318
     1319        EConversionCycle (const char *aMsg = NULL) : Error (aMsg) {}
     1320    };
     1321
     1322    /**
    13011323     * The InputResolver class represents an interface to provide input streams
    13021324     * for external entities given an URL and entity ID.
     
    13371359         *
    13381360         * The implementation normally checks for the "version" value of the
    1339          * root key to determine if the conversion is necessary. The
    1340          * implementation must return a string representing the old version
    1341          * (before conversion) in the @c aOldVersion argument -- this string is
    1342          * used by XmlTreeBackend::oldVersion() and must be non-NULL to indicate
    1343          * that the conversion has been performed on the tree. The returned
    1344          * string must be allocated using RTStrDup or such.
     1361         * root key to determine if the conversion is necessary. When the
     1362         * @a aOldVersion argument is not NULL, the implementation must return a
     1363         * non-NULL non-empty string representing the old version (before
     1364         * conversion) in it this string is used by XmlTreeBackend::oldVersion()
     1365         * and must be non-NULL to indicate that the conversion has been
     1366         * performed on the tree. The returned string must be allocated using
     1367         * RTStrDup() or such.
     1368         *
     1369         * This method is called again after the successful transformation to
     1370         * let the implementation retry the version check and request another
     1371         * transformation if necessary. This may be used to perform multi-step
     1372         * conversion like this: 1.1 => 1.2, 1.2 => 1.3 (instead of 1.1 => 1.3)
     1373         * which saves from the need to update all previous conversion
     1374         * templates to make each of them convert directly to the recent
     1375         * version.
     1376         *
     1377         * @note Multi-step transformations are performed in a loop that exits
     1378         *       only when this method returns @false. It's up to the
     1379         *       implementation to detect cycling (repeated requests to convert
     1380         *       from the same version) wrong version order, etc. and throw an
     1381         *       EConversionCycle exception to break the loop without returning
     1382         *       @false (which means the transformation succeeded).
    13451383         *
    13461384         * @param aRoot                 Root settings key.
    1347          * @param aOldVersionString     Old version string (allocated by
    1348          *                              RTStrDup or such).
     1385         * @param aOldVersionString     Where to store old version string
     1386         *                              pointer. May be NULL.
    13491387         */
    13501388        virtual bool needsConversion (const Key &aRoot,
    1351                                       char *&aOldVersion) const = 0;
     1389                                      char **aOldVersion) const = 0;
    13521390
    13531391        /**
     
    13591397    };
    13601398
    1361     /**
    1362      * The Error class represents errors that may happen when parsing or
    1363      * validating the XML document representing the settings tree.
    1364      */
    1365     class VBOXSETTINGS_CLASS Error : public RuntimeError
    1366     {
    1367     public:
    1368 
    1369         Error (const char *aMsg = NULL) : RuntimeError (aMsg) {}
    1370     };
    1371 
    13721399    XmlTreeBackend();
    13731400    ~XmlTreeBackend();
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