VirtualBox

Changeset 30670 in vbox for trunk/include/VBox/com/defs.h


Ignore:
Timestamp:
Jul 6, 2010 2:37:09 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
63429
Message:

Main: COM header cleanup (remove obscure and unused templates)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/defs.h

    r28950 r30670  
    521521        if ((FAILED (aRC) && !FAILED (mRC)) ||
    522522            (mRC == S_OK && aRC != S_OK))
    523             mRC = aRC;
    524 
    525         return *this;
    526     }
    527 
    528     operator HRESULT() const { return mRC; }
    529 
    530     HRESULT *operator&() { return &mRC; }
    531 
    532 private:
    533 
    534     HRESULT mRC;
    535 };
    536 
    537 /**
    538  * "Last worst" result type.
    539  *
    540  * Variables of this class are used instead of HRESULT variables when it is
    541  * desirable to memorize the "last worst" result code instead of the last
    542  * assigned one. In other words, an assignment operation to a variable of this
    543  * class will succeed only if the result code to assign has the same or worse
    544  * severity. The following table demonstrate this (the first column lists the
    545  * previous result code stored in the variable, the first row lists the new
    546  * assigned, 'A' means the assignment will take place, '> S_OK' means a warning
    547  * result code):
    548  *
    549  * {{{
    550  *             FAILED    > S_OK    S_OK
    551  * FAILED        A         -         -
    552  * > S_OK        A         A         -
    553  * S_OK          A         A         -
    554  *
    555  * }}}
    556  *
    557  * In practice, you will need to use a LWResult variable when you call some COM
    558  * method B after COM method A fails and want to return the result code of B
    559  * if B also fails, but still want to return the failed result code of A if B
    560  * issues a warning or succeeds.
    561  */
    562 class LWResult
    563 {
    564 
    565 public:
    566 
    567     /**
    568      * Constructs a new variable. Note that by default this constructor sets the
    569      * result code to E_FAIL to make sure a failure is returned to the caller if
    570      * the variable is never assigned another value (which is considered as the
    571      * improper use of this class).
    572      */
    573     LWResult (HRESULT aRC = E_FAIL) : mRC (aRC) {}
    574 
    575     LWResult &operator= (HRESULT aRC)
    576     {
    577         if (FAILED (aRC) ||
    578             (SUCCEEDED (mRC) && aRC != S_OK))
    579523            mRC = aRC;
    580524
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