VirtualBox

Changeset 3044

Show
Ignore:
Timestamp:
06/05/07 12:37:38 (2 years ago)
Author:
vboxsync
Message:

Main: Added ErrorInfoKeeper::takeError().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/com/ErrorInfo.h

    r2981 r3044  
    303303 *  error information while it still needs to make another call before return. 
    304304 * 
     305 *  Instead of calling #restore() explicitly you may let the object destructor 
     306 *  do it for you, if you correctly limit the object's lifeime. 
     307 * 
    305308 *  The usage pattern is: 
    306309 *  <code> 
     
    313316 *           bar->method(); 
    314317 *           ... 
    315  *           // restore error info from foo to return it to the caller 
    316  *           eik.restore(); 
     318 *           // no need to call #restore() explicitly here because the eik's 
     319 *           // destructor will restore error info fetched after the failed 
     320 *           // call to foo before returning to the caller 
    317321 *           return rc; 
    318322 *      } 
     
    329333    /** 
    330334     *  Destroys this instance and automatically calls #restore() which will 
    331      *  either restorr error info fetched by the constructor or do nothing 
     335     *  either restore error info fetched by the constructor or do nothing 
    332336     *  if #forget() was called before destruction. */ 
    333337    ~ErrorInfoKeeper() { if (!mForgot) restore(); } 
     
    342346 
    343347    /** 
    344      *  Forgets error info fetched by the constructor which prevents it from 
     348     *  Forgets error info fetched by the constructor to prevent it from 
    345349     *  being restored by #restore() or by the destructor. 
    346350     */ 
    347351    void forget() { mForgot = 0; } 
     352 
     353    /** 
     354     *  Forgets error info fetched by the constructor to prevent it from 
     355     *  being restored by #restore() or by the destructor, and returns the 
     356     *  stored error info object to the caller. 
     357     */ 
     358    ComPtr <IUnknown> takeError() { mForgot = 0; return mErrorInfo; } 
    348359 
    349360private: 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy