VirtualBox

Changeset 30681 in vbox


Ignore:
Timestamp:
Jul 6, 2010 5:20:20 PM (15 years ago)
Author:
vboxsync
Message:

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

Location:
trunk
Files:
41 edited

Legend:

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

    r30676 r30681  
    3232#include "VBox/com/Guid.h"
    3333#include "VBox/com/assert.h"
    34 
    35 #include <iprt/memory> // for auto_copy_ptr
    3634
    3735struct IProgress;
     
    109107     */
    110108    explicit ErrorInfo()
    111         : mIsBasicAvailable (false), mIsFullAvailable (false)
    112         , mResultCode (S_OK)
    113         { init(); }
    114 
    115     /**
    116      *  Constructs a new, "interfaceless" ErrorInfo instance that takes
    117      *  the error information possibly set on the current thread by an
    118      *  interface method of the given interface pointer.
    119 
    120      *  If the given interface does not support providing error information or,
    121      *  for some reason didn't set any error information, both
    122      *  #isFullAvailable() and #isBasicAvailable() will return |false|.
    123      *
    124      *  @param aPtr pointer to the interface whose method returned an
    125      *              error
    126      */
    127     template <class I> ErrorInfo (I *aPtr)
    128         : mIsBasicAvailable (false), mIsFullAvailable (false)
    129         , mResultCode (S_OK)
    130         { init (aPtr, COM_IIDOF(I)); }
    131 
    132     /**
    133      *  Constructs a new ErrorInfo instance from the smart interface pointer.
    134      *  See template <class I> ErrorInfo (I *aPtr) for details
    135      *
    136      *  @param aPtr smart pointer to the interface whose method returned
    137      *              an error
    138      */
    139     template <class I> ErrorInfo (const ComPtr <I> &aPtr)
    140         : mIsBasicAvailable (false), mIsFullAvailable (false)
    141         , mResultCode (S_OK)
    142         { init (static_cast <I*> (aPtr), COM_IIDOF(I)); }
    143 
    144     /** Specialization for the IVirtualBoxErrorInfo smart pointer */
    145     ErrorInfo (const ComPtr <IVirtualBoxErrorInfo> &aPtr)
    146         : mIsBasicAvailable (false), mIsFullAvailable (false)
    147         , mResultCode (S_OK)
    148         { init (aPtr); }
    149 
    150     /**
    151      *  Constructs a new ErrorInfo instance from the IVirtualBoxErrorInfo
    152      *  interface pointer. If this pointer is not NULL, both #isFullAvailable()
    153      *  and #isBasicAvailable() will return |true|.
    154      *
    155      *  @param aInfo    pointer to the IVirtualBoxErrorInfo interface that
    156      *                  holds error info to be fetched by this instance
    157      */
    158     ErrorInfo (IVirtualBoxErrorInfo *aInfo)
    159         : mIsBasicAvailable (false), mIsFullAvailable (false)
    160         , mResultCode (S_OK)
    161         { init (aInfo); }
     109        : mIsBasicAvailable(false),
     110          mIsFullAvailable(false),
     111          mResultCode(S_OK),
     112          m_pNext(NULL)
     113    {
     114        init();
     115    }
     116
     117    ErrorInfo(IUnknown *pObj, const GUID &aIID)
     118        : mIsBasicAvailable(false),
     119          mIsFullAvailable(false),
     120          mResultCode(S_OK),
     121          m_pNext(NULL)
     122    {
     123        init(pObj, aIID);
     124    }
    162125
    163126    virtual ~ErrorInfo();
     
    175138     *  this method returns true (otherwise they simply return NULL-like values).
    176139     */
    177     bool isBasicAvailable() const { return mIsBasicAvailable; }
     140    bool isBasicAvailable() const
     141    {
     142        return mIsBasicAvailable;
     143    }
    178144
    179145    /**
     
    189155     *  this method returns true (otherwise they simply return NULL-like values).
    190156     */
    191     bool isFullAvailable() const { return mIsFullAvailable; }
    192 
    193     /**
    194      *  Returns @c true if both isBasicAvailable() and isFullAvailable() are
    195      *  @c false.
    196      */
    197     bool isNull() const { return !mIsBasicAvailable && !mIsFullAvailable; }
     157    bool isFullAvailable() const
     158    {
     159        return mIsFullAvailable;
     160    }
    198161
    199162    /**
    200163     *  Returns the COM result code of the failed operation.
    201164     */
    202     HRESULT getResultCode() const { return mResultCode; }
     165    HRESULT getResultCode() const
     166    {
     167        return mResultCode;
     168    }
    203169
    204170    /**
    205171     *  Returns the IID of the interface that defined the error.
    206172     */
    207     const Guid &getInterfaceID() const { return mInterfaceID; }
     173    const Guid& getInterfaceID() const
     174    {
     175        return mInterfaceID;
     176    }
    208177
    209178    /**
    210179     *  Returns the name of the component that generated the error.
    211180     */
    212     const Bstr &getComponent() const { return mComponent; }
     181    const Bstr& getComponent() const
     182    {
     183        return mComponent;
     184    }
    213185
    214186    /**
    215187     *  Returns the textual description of the error.
    216188     */
    217     const Bstr &getText() const { return mText; }
     189    const Bstr& getText() const
     190    {
     191        return mText;
     192    }
    218193
    219194    /**
    220195     *  Returns the next error information object or @c NULL if there is none.
    221196     */
    222     const ErrorInfo *getNext() const { return mNext.get(); }
     197    const ErrorInfo* getNext() const
     198    {
     199        return m_pNext;
     200    }
    223201
    224202    /**
    225203     *  Returns the name of the interface that defined the error
    226204     */
    227     const Bstr &getInterfaceName() const { return mInterfaceName; }
     205    const Bstr& getInterfaceName() const
     206    {
     207        return mInterfaceName;
     208    }
    228209
    229210    /**
     
    234215     *  template <class I> ErrorInfo (const ComPtr <I> &i) constructor.
    235216     */
    236     const Guid &getCalleeIID() const { return mCalleeIID; }
     217    const Guid& getCalleeIID() const
     218    {
     219        return mCalleeIID;
     220    }
    237221
    238222    /**
     
    243227     *  template <class I> ErrorInfo (const ComPtr <I> &i) constructor.
    244228     */
    245     const Bstr &getCalleeName() const { return mCalleeName; }
     229    const Bstr& getCalleeName() const
     230    {
     231        return mCalleeName;
     232    }
    246233
    247234    /**
     
    253240        mIsBasicAvailable = false;
    254241        mIsFullAvailable = false;
     242
     243        if (m_pNext)
     244        {
     245            delete m_pNext;
     246            m_pNext = NULL;
     247        }
    255248
    256249        mResultCode = S_OK;
     
    258251        mComponent.setNull();
    259252        mText.setNull();
    260         mNext.reset();
    261253        mInterfaceName.setNull();
    262254        mCalleeIID.clear();
     
    267259protected:
    268260
    269     ErrorInfo (bool /* aDummy */)
    270         : mIsBasicAvailable (false), mIsFullAvailable (false)
    271         , mResultCode (S_OK)
    272         {}
    273 
    274     void init (bool aKeepObj = false);
    275     void init (IUnknown *aUnk, const GUID &aIID, bool aKeepObj = false);
    276     void init (IVirtualBoxErrorInfo *aInfo);
     261    ErrorInfo(bool /* aDummy */)
     262        : mIsBasicAvailable(false),
     263          mIsFullAvailable(false),
     264          mResultCode(S_OK),
     265          m_pNext(NULL)
     266    { }
     267
     268    void init(bool aKeepObj = false);
     269    void init(IUnknown *aUnk, const GUID &aIID, bool aKeepObj = false);
     270    void init(IVirtualBoxErrorInfo *aInfo);
    277271
    278272    bool mIsBasicAvailable : 1;
     
    284278    Bstr    mText;
    285279
    286     cppx::auto_copy_ptr <ErrorInfo> mNext;
     280    ErrorInfo *m_pNext;
    287281
    288282    Bstr mInterfaceName;
     
    290284    Bstr mCalleeName;
    291285
    292     ComPtr <IUnknown> mErrorInfo;
     286    ComPtr<IUnknown> mErrorInfo;
     287
     288private:
     289    ErrorInfo(const ErrorInfo&);
    293290};
    294291
     
    311308     *  @param  progress    the progress object representing a failed operation
    312309     */
    313     ProgressErrorInfo (IProgress *progress);
     310    ProgressErrorInfo(IProgress *progress);
    314311};
    315312
     
    381378        setNull();
    382379        mForgot = false;
    383         init (true /* aKeepObj */);
     380        init(true /* aKeepObj */);
    384381    }
    385382
  • trunk/include/VBox/com/Guid.h

    r30676 r30681  
    4444#include "VBox/com/string.h"
    4545
    46 #include <iprt/cpp/utils.h>
    4746#include <iprt/uuid.h>
    4847
  • trunk/include/VBox/com/array.h

    r30676 r30681  
    168168#include "VBox/com/ptr.h"
    169169#include "VBox/com/assert.h"
    170 
    171 #include "iprt/cpp/utils.h"
    172170
    173171#if defined (VBOX_WITH_XPCOM)
  • trunk/include/VBox/com/com.h

    r30676 r30681  
    5959void GetInterfaceNameByIID(const GUID &aIID, BSTR *aName);
    6060
    61 #ifdef VBOX_WITH_XPCOM
    62 
    63 /**
    64  *  Helper method to keep all the XPCOM headers out of include/VBox/com/ptr.h.
    65  */
    66 HRESULT GlueCreateObjectOnServer(const CLSID &clsid,
    67                                  const char *serverName,
    68                                  const nsIID &id,
    69                                  void** ppobj);
    70 
    71 /**
    72  *  Helper method to keep all the XPCOM headers out of include/VBox/com/ptr.h.
    73  */
    74 HRESULT GlueCreateInstance(const CLSID &clsid,
    75                            const nsIID &id,
    76                            void** ppobj);
    77 
    78 #endif // VBOX_WITH_XPCOM
    79 
    8061/**
    8162 *  Returns the VirtualBox user home directory.
  • trunk/include/VBox/com/defs.h

    r30676 r30681  
    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
  • trunk/include/VBox/com/ptr.h

    r30676 r30681  
    4343#else
    4444 #include <nsISupportsUtils.h>
     45
    4546#endif /* !defined (VBOX_WITH_XPCOM) */
    4647
    47 #include <VBox/com/com.h>
     48#include <VBox/com/defs.h>
     49
     50#ifdef VBOX_WITH_XPCOM
     51
     52namespace com
     53{
     54// declare a couple of XPCOM helper methods (defined in glue/com.cpp)
     55// so we don't have to include a ton of XPCOM implementation headers here
     56HRESULT GlueCreateObjectOnServer(const CLSID &clsid,
     57                                 const char *serverName,
     58                                 const nsIID &id,
     59                                 void** ppobj);
     60HRESULT GlueCreateInstance(const CLSID &clsid,
     61                           const nsIID &id,
     62                           void** ppobj);
     63}
     64
     65#endif // VBOX_WITH_XPCOM
    4866
    4967/**
  • trunk/include/iprt/cpp/utils.h

    r30676 r30681  
    2727#define ___iprt_cpputils_h
    2828
    29 #include <iprt/assert.h>
    30 
    31 #include <memory>
    32 
    3329/** @defgroup grp_rt_cpputils   C++ Utilities
    3430 * @ingroup grp_rt
     
    4844 */
    4945template <class C>
    50 inline C &unconst (const C &that) { return const_cast <C &> (that); }
     46inline C& unconst(const C &that) { return const_cast<C&>(that); }
    5147
    5248
     
    6359 */
    6460template <class C>
    65 inline C *unconst (const C *that) { return const_cast <C *> (that); }
     61inline C* unconst(const C *that) { return const_cast<C*>(that); }
    6662
    6763
    68 /**
    69  * Extensions to the std namespace.
    70  */
    71 namespace stdx
     64namespace iprt
    7265{
    73 
    74 /* forward */
    75 template <class> class auto_ref_ptr;
    76 
    77 /**
    78  * Base class for objects willing to support smart reference counting using
    79  * the auto_ref_ptr template.
    80  *
    81  * When a class wants to be used with the auto_ref_ptr template it simply
    82  * declares the auto_ref class among its public base classes -- there is no
    83  * need to implement any additional methods.
    84  */
    85 class auto_ref
    86 {
    87 protected:
    88 
    89     auto_ref() : mRefs (0) {}
    90 
    91     /** Increases the reference counter and returns it */
    92     size_t ref() { return ++ mRefs; }
    93 
    94     /** Decreases the reference counter and returns it */
    95     size_t unref() { Assert (mRefs > 0); return -- mRefs; }
    96 
    97 private:
    98 
    99     size_t mRefs;
    100 
    101     template <class> friend class auto_ref_ptr;
    102 };
    103 
    104 /**
    105  * The auto_ref_ptr template manages pointers to objects that support
    106  * reference counting by implementing auto_ref or a similar interface.
    107  *
    108  * Pointer management includes the following key points:
    109  *
    110  *   1) Automatic increment of the object's reference counter when the given
    111  *      auto_ref_ptr instance starts managing a pointer to this object.
    112  *
    113  *   2) Automatic decrement of the reference counter when the given
    114  *      auto_ref_ptr instance is destroyed, or before it is assigned a pointer
    115  *      to a new object.
    116  *
    117  *   3) Automatic deletion of the managed object whenever its reference
    118  *      counter reaches zero after a decrement.
    119  *
    120  *   4) Providing the dereference operator-> that gives direct access to the
    121  *      managed pointer.
    122  *
    123  * The object class to manage must provide ref() and unref() methods that have
    124  * the same syntax and semantics as defined in the auto_ref class.
    125  *
    126  * @param C     Class to manage.
    127  */
    128 template <class C>
    129 class auto_ref_ptr
    130 {
    131 public:
    132 
    133     /**
    134      * Creates a null instance that does not manage anything.
    135      */
    136     auto_ref_ptr() : m (NULL) {}
    137 
    138     /**
    139      * Creates an instance that starts managing the given pointer. The
    140      * reference counter of the object pointed to by @a a is incremented by
    141      * one.
    142      *
    143      * @param a Pointer to manage.
    144      */
    145     auto_ref_ptr (C* a) : m (a) { if (m) m->ref(); }
    146 
    147     /**
    148      * Creates an instance that starts managing a pointer managed by the given
    149      * instance. The reference counter of the object managed by @a that is
    150      * incremented by one.
    151      *
    152      * @param that Instance to take a pointer to manage from.
    153      */
    154     auto_ref_ptr (const auto_ref_ptr &that) : m (that.m) { if (m) m->ref(); }
    155 
    156     ~auto_ref_ptr() { do_unref(); }
    157 
    158     /**
    159      * Assigns the given pointer to this instance and starts managing it. The
    160      * reference counter of the object pointed to by @a a is incremented by
    161      * one. The reference counter of the object previously managed by this
    162      * instance is decremented by one.
    163      *
    164      * @param a Pointer to assign.
    165      */
    166     auto_ref_ptr &operator= (C *a) { do_reref (a); return *this; }
    167 
    168     /**
    169      * Assigns a pointer managed by the given instance to this instance and
    170      * starts managing it. The reference counter of the object managed by @a
    171      * that is incremented by one. The reference counter of the object
    172      * previously managed by this instance is decremented by one.
    173      *
    174      * @param that Instance which pointer to reference.
    175      */
    176     auto_ref_ptr &operator= (const auto_ref_ptr &that) { do_reref (that.m); return *this; }
    177 
    178     /**
    179      * Returns @c true if this instance is @c null and false otherwise.
    180      */
    181     bool is_null() const { return m == NULL; }
    182 
    183     /**
    184      * Dereferences the instance by returning the managed pointer.
    185      * Asserts that the managed pointer is not @c NULL.
    186      */
    187     C *operator-> () const { AssertMsg (m, ("Managed pointer is NULL!\n")); return m; }
    188 
    189     /**
    190      * Returns the managed pointer or @c NULL if this instance is @c null.
    191      */
    192     C *raw() const { return m; }
    193 
    194     /**
    195      * Compares this auto_ref_ptr instance with another instance and returns
    196      * @c true if both instances manage the same or @c NULL pointer.
    197      *
    198      * Note that this method compares pointer values only, it doesn't try to
    199      * compare objects themselves. Doing otherwise would a) break the common
    200      * 'pointer to something' comparison semantics auto_ref_ptr tries to
    201      * follow and b) require to define the comparison operator in the managed
    202      * class which is not always possible. You may analyze pointed objects
    203      * yourself if you need more precise comparison.
    204      *
    205      * @param that Instance to compare this instance with.
    206      */
    207     bool operator== (const auto_ref_ptr &that) const
    208     {
    209         return m == that.m;
    210     }
    211 
    212 protected:
    213 
    214     void do_reref (C *a)
    215     {
    216         /* be aware of self assignment */
    217         if (a)
    218             a->ref();
    219         if (m)
    220         {
    221             size_t refs = m->unref();
    222             if (refs == 0)
    223             {
    224                 refs = 1; /* stabilize */
    225                 delete m;
    226             }
    227         }
    228         m = a;
    229     }
    230 
    231     void do_unref() { do_reref (NULL); }
    232 
    233     C *m;
    234 };
    235 
    236 /**
    237  * The exception_trap_base class is an abstract base class for all
    238  * exception_trap template instantiations.
    239  *
    240  * Pointer variables of this class are used to store a pointer any object of
    241  * any class instantiated from the exception_trap template, or in other words
    242  * to store a full copy of any exception wrapped into the exception_trap instance
    243  * allocated on the heap.
    244  *
    245  * See the exception_trap template for more info.
    246  */
    247 class exception_trap_base
    248 {
    249 public:
    250     virtual void rethrow() = 0;
    251     virtual ~exception_trap_base() {}
    252 };
    253 
    254 /**
    255  * The exception_trap template acts like a wrapper for the given exception
    256  * class that stores a full copy of the exception and therefore allows to
    257  * rethrow it preserving the actual type information about the exception
    258  * class.
    259  *
    260  * This functionality is useful in situations where it is necessary to catch a
    261  * (known) number of exception classes and pass the caught exception instance
    262  * to an upper level using a regular variable (rather than the exception
    263  * unwinding mechanism itself) *and* preserve all information about the type
    264  * (class) of the caight exception so that it may be rethrown on the upper
    265  * level unchanged.
    266  *
    267  * Usage pattern:
    268  * @code
    269     using namespace std;
    270     using namespace stdx;
    271 
    272     auto_ptr <exception_trap_base> trapped;
    273 
    274     int callback();
    275 
    276     int safe_callback()
    277     {
    278       try
    279       {
    280         // callback may throw a set of exceptions but we don't want it to start
    281         // unwinding the stack right now
    282 
    283         return callback();
    284       }
    285       catch (const MyException &err) { trapped = new_exception_trap (err); }
    286       catch (const MyException2 &err) { trapped = new_exception_trap (err); }
    287       catch (...) { trapped = new_exception_trap (logic_error()); }
    288 
    289       return -1;
    290     }
    291 
    292     void bar()
    293     {
    294       // call a funciton from some C library that supports callbacks but knows
    295       // nothing about exceptions so throwing one from a callback will leave
    296       // the library in an undetermined state
    297 
    298       do_something_with_callback (safe_callback());
    299 
    300       // check if we have got an exeption from callback() and rethrow it now
    301       // when we are not in the C library any more
    302       if (trapped.get() != NULL)
    303         trapped->rethrow();
    304     }
    305  * @endcode
    306  *
    307  * @param T Exception class to wrap.
    308  */
    309 template <typename T>
    310 class exception_trap : public exception_trap_base
    311 {
    312 public:
    313 
    314     exception_trap (const T &aTrapped) : trapped (aTrapped) {}
    315     void rethrow() { throw trapped; }
    316 
    317     T trapped;
    318 };
    319 
    320 /**
    321  * Convenience function that allocates a new exception_trap instance on the
    322  * heap by automatically deducing the exception_trap template argument from
    323  * the type of the exception passed in @a aTrapped.
    324  *
    325  * The following two lines of code inside the catch block are equivalent:
    326  *
    327  * @code
    328     using namespace std;
    329     using namespace stdx;
    330     catch (const MyException &err)
    331     {
    332       auto_ptr <exception_trap_base> t1 = new exception_trap <MyException> (err);
    333       auto_ptr <exception_trap_base> t2 = new_exception_trap (err);
    334     }
    335  * @endcode
    336  *
    337  * @param aTrapped Exception to put to the allocated trap.
    338  *
    339  * @return Allocated exception_trap object.
    340  */
    341 template <typename T>
    342 static exception_trap <T> *
    343 new_exception_trap (const T &aTrapped)
    344 {
    345     return new exception_trap <T> (aTrapped);
    346 }
    347 
    348 /**
    349  * Enhancement of std::auto_ptr @<char@> intended to take pointers to char
    350  * buffers allocated using new[].
    351  *
    352  * This differs from std::auto_ptr @<char@> so that it overloads some methods to
    353  * uses delete[] instead of delete to delete the owned data in order to
    354  * conform to the C++ standard (and avoid valgrind complaints).
    355  *
    356  * Note that you should not use instances of this class where pointers or
    357  * references to objects of std::auto_ptr @<char@> are expeced. Despite the fact
    358  * the classes are related, the base is not polymorphic (in particular,
    359  * neither the destructor nor the reset() method are virtual). It means that when
    360  * acessing instances of this class through the base pointer, overloaded
    361  * methods won't be called.
    362  */
    363 class char_auto_ptr : public std::auto_ptr <char>
    364 {
    365 public:
    366 
    367     explicit char_auto_ptr (char *a = 0) throw()
    368         : std::auto_ptr <char> (a) {}
    369 
    370     /* Note: we use unconst brute force below because the non-const version
    371      * of the copy constructor won't accept temporary const objects
    372      * (e.g. function return values) in GCC. std::auto_ptr has the same
    373      * "problem" but it seems overcome it using #pragma GCC system_header
    374      * which doesn't work here. */
    375     char_auto_ptr (const char_auto_ptr &that) throw()
    376         : std::auto_ptr <char> (unconst (that).release()) {}
    377 
    378     ~char_auto_ptr() { delete[] (release()); }
    379 
    380     char_auto_ptr &operator= (char_auto_ptr &that) throw()
    381     {
    382         std::auto_ptr <char>::operator= (that);
    383         return *this;
    384     }
    385 
    386     void reset (char *a) throw()
    387     {
    388         if (a != get())
    389         {
    390             delete[] (release());
    391             std::auto_ptr <char>::reset (a);
    392         }
    393     }
    394 };
    395 
    39666/**
    39767 * A simple class used to prevent copying and assignment.  Inherit from this
     
    40979};
    41080
    411 } /* namespace stdx */
     81} // namespace iprt
    41282
    41383/** @} */
    41484
    415 #endif
     85#endif // ___iprt_cpputils_h
    41686
  • trunk/include/iprt/memory

    r30676 r30681  
    1 /** @file
    2  * IPRT - C++ Extensions: memory.
    3  */
    4 
    5 /*
    6  * Copyright (C) 2007 Oracle Corporation
    7  *
    8  * This file is part of VirtualBox Open Source Edition (OSE), as
    9  * available from http://www.virtualbox.org. This file is free software;
    10  * you can redistribute it and/or modify it under the terms of the GNU
    11  * General Public License (GPL) as published by the Free Software
    12  * Foundation, in version 2 as it comes in the "COPYING" file of the
    13  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
    14  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
    15  *
    16  * The contents of this file may alternatively be used under the terms
    17  * of the Common Development and Distribution License Version 1.0
    18  * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
    19  * VirtualBox OSE distribution, in which case the provisions of the
    20  * CDDL are applicable instead of those of the GPL.
    21  *
    22  * You may elect to license modified versions of this file under the
    23  * terms and conditions of either the GPL or the CDDL or both.
    24  */
    25 
    26 #ifndef ___iprt_memory___
    27 #define ___iprt_memory___
    28 
    29 /** @defgroup grp_rt_cppx_memory  IPRT C++ Extensions: memory
    30  * @ingroup grp_rt_cppx
    31  * @{
    32  */
    33 
    34 #ifdef __cplusplus
    35 
    36 #include <memory> /* for auto_ptr */
    37 
    38 namespace cppx
    39 {
    40 
    41 /**
    42  *  A simple std::auto_ptr extension that adds CopyConstructible and
    43  *  Assignable semantics.
    44  *
    45  *  Instances of this class, when constructed from or assigned with instances
    46  *  of the same class, create a copy of the managed object using the new
    47  *  operator and the managed object's copy constructor, as opposed to
    48  *  std::auto_ptr which simply transfers ownership in these cases.
    49  *
    50  *  This template is useful for member variables of a class that store
    51  *  dynamically allocated instances of some other class and these instances
    52  *  need to be copied when the containing class instance is copied itself.
    53  *
    54  *  Be careful when returning instances of this class by value: it will call
    55  *  cause to create a copy of the managed object which is probably is not what
    56  *  you want, especially if its constructor is quite an expensive operation.
    57  */
    58 template <typename T>
    59 class auto_copy_ptr : public std::auto_ptr <T>
    60 {
    61 public:
    62 
    63     /** @see std::auto_ptr <T>::auto_ptr() */
    64     auto_copy_ptr (T *p = 0) throw() : std::auto_ptr <T> (p) {}
    65 
    66     /**
    67      * Copy constructor.
    68      * Takes a copy of the given instance by taking a copy of the managed
    69      * object using its copy constructor. Both instances will continue to own
    70      * their objects.
    71      */
    72     auto_copy_ptr (const auto_copy_ptr &that) throw()
    73         : std::auto_ptr <T> (that.get() ? new T (*that.get()) : NULL) {}
    74 
    75     /**
    76      * Assignment operator.
    77      * Takes a copy of the given instance by taking a copy of the managed
    78      * object using its copy constructor. Both instances will continue to own
    79      * their objects.
    80      */
    81     auto_copy_ptr &operator= (const auto_copy_ptr &that) throw()
    82     {
    83         std::auto_ptr <T>::reset (that.get() ? new T (*that.get()) : NULL);
    84         return *this;
    85     }
    86 };
    87 
    88 } /* namespace cppx */
    89 
    90 
    91 #endif /* __cplusplus */
    92 
    93 /** @} */
    94 
    95 #endif
  • trunk/src/VBox/Additions/x11/VBoxClient/VBoxClient.h

    r30676 r30681  
    2626/** A simple class describing a service.  VBoxClient will run exactly one
    2727 * service per invocation. */
    28 class Service : public stdx::non_copyable
     28class Service : public iprt::non_copyable
    2929{
    3030public:
  • trunk/src/VBox/Frontends/VBoxHeadless/testcase/tstHeadless.cpp

    r30676 r30681  
    139139            if (FAILED (resultCode))
    140140            {
    141                 ComPtr <IVirtualBoxErrorInfo> errorInfo;
    142                 CHECK_ERROR_BREAK (progress,
    143                                    COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
    144                 ErrorInfo info (errorInfo);
     141                ComPtr<IVirtualBoxErrorInfo> errorInfo;
     142                CHECK_ERROR_BREAK(progress,
     143                                  COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
     144                ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
    145145                com::GluePrintErrorInfo(info);
    146146            }
     
    175175                if (FAILED (resultCode))
    176176                {
    177                     ComPtr <IVirtualBoxErrorInfo> errorInfo;
    178                     CHECK_ERROR_BREAK (progress,
    179                                        COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
    180                     ErrorInfo info (errorInfo);
     177                    ComPtr<IVirtualBoxErrorInfo> errorInfo;
     178                    CHECK_ERROR_BREAK(progress,
     179                                      COMGETTER(ErrorInfo) (errorInfo.asOutParam()));
     180                    ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
    181181                    com::GluePrintErrorInfo(info);
    182182                }
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r30676 r30681  
    324324                /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
    325325                 * because it contains more accurate info about what went wrong. */
    326                 ErrorInfo info(guest);
     326                ErrorInfo info(guest, COM_IIDOF(IGuest));
    327327                if (info.isFullAvailable())
    328328                {
    329329                    if (rc == VBOX_E_IPRT_ERROR)
    330                     {
    331330                        RTPrintf("%ls.\n", info.getText().raw());
    332                     }
    333331                    else
    334                     {
    335332                        RTPrintf("ERROR: %ls (%Rhrc).\n", info.getText().raw(), info.getResultCode());
    336                     }
    337333                }
    338334                break;
     
    398394                            /* If we got a VBOX_E_IPRT error we handle the error in a more gentle way
    399395                             * because it contains more accurate info about what went wrong. */
    400                             ErrorInfo info(guest);
     396                            ErrorInfo info(guest, COM_IIDOF(IGuest));
    401397                            if (info.isFullAvailable())
    402398                            {
     
    493489                        ComPtr<IVirtualBoxErrorInfo> execError;
    494490                        rc = progress->COMGETTER(ErrorInfo)(execError.asOutParam());
    495                         com::ErrorInfo info (execError);
     491                        com::ErrorInfo info(execError, COM_IIDOF(IVirtualBoxErrorInfo));
    496492                        if (SUCCEEDED(rc) && info.isFullAvailable())
    497493                        {
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageImport.cpp

    r30676 r30681  
    267267        RTPrintf("Interpreting %ls...\n", path.raw());
    268268        rc = pAppliance->Interpret();
    269         com::ErrorInfo info0(pAppliance);
     269        com::ErrorInfo info0(pAppliance, COM_IIDOF(IAppliance));
    270270
    271271        com::SafeArray<BSTR> aWarnings;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageInfo.cpp

    r30676 r30681  
    170170                rc = machine->COMGETTER(AccessError)(accessError.asOutParam());
    171171                RTPrintf("Access error details:\n");
    172                 ErrorInfo ei(accessError);
     172                ErrorInfo ei(accessError, COM_IIDOF(IVirtualBoxErrorInfo));
    173173                GluePrintErrorInfo(ei);
    174174                RTPrintf("\n");
     
    12911291            if (FAILED(rc))
    12921292            {
    1293                 com::ErrorInfo info (display);
     1293                com::ErrorInfo info(display, COM_IIDOF(IDisplay));
    12941294                GluePrintErrorInfo(info);
    12951295                return rc;
     
    13561356                if (FAILED(rc))
    13571357                {
    1358                     com::ErrorInfo info (remoteDisplayInfo);
     1358                    com::ErrorInfo info(remoteDisplayInfo, COM_IIDOF(IRemoteDisplayInfo));
    13591359                    GluePrintErrorInfo(info);
    13601360                    return rc;
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r30676 r30681  
    387387        if (FAILED(iRc))
    388388        {
    389             ComPtr <IVirtualBoxErrorInfo> errorInfo;
     389            ComPtr<IVirtualBoxErrorInfo> errorInfo;
    390390            CHECK_ERROR_RET(progress, COMGETTER(ErrorInfo)(errorInfo.asOutParam()), 1);
    391             ErrorInfo info (errorInfo);
     391            ErrorInfo info(errorInfo, COM_IIDOF(IVirtualBoxErrorInfo));
    392392            com::GluePrintErrorInfo(info);
    393393        }
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r30676 r30681  
    20082008    if (rc != S_OK)
    20092009    {
    2010         com::ErrorInfo info(gConsole);
     2010        com::ErrorInfo info(gConsole, COM_IIDOF(IConsole));
    20112011        if (info.isBasicAvailable())
    20122012            PrintError("Failed to power up VM", info.getText().raw());
     
    27922792        for (unsigned i = 0; i < gcMonitors; i++)
    27932793            gDisplay->SetFramebuffer(i, NULL);
    2794     }   
     2794    }
    27952795
    27962796    gMouse = NULL;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxMedium.h

    r30676 r30681  
    2626/* Local includes */
    2727#include "COMDefs.h"
     28
     29#include <iprt/cpp/utils.h>
    2830
    2931/**
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.cpp

    r30676 r30681  
    224224////////////////////////////////////////////////////////////////////////////////
    225225
    226 void COMErrorInfo::init (const CVirtualBoxErrorInfo &info)
     226void COMErrorInfo::init(const CVirtualBoxErrorInfo &info)
    227227{
    228228    AssertReturnVoid (!info.isNull());
     
    249249    gotAll &= info.isOk();
    250250
     251    m_pNext = NULL;
     252
    251253    CVirtualBoxErrorInfo next = info.GetNext();
    252254    if (info.isOk() && !next.isNull())
    253255    {
    254         mNext.reset (new COMErrorInfo (next));
    255         Assert (mNext.get());
    256     }
    257     else
    258         mNext.reset();
     256        m_pNext = new COMErrorInfo(next);
     257        Assert(m_pNext);
     258    }
     259
    259260    gotSomething |= info.isOk();
    260261    gotAll &= info.isOk();
     
    266267
    267268    AssertMsg (gotSomething, ("Nothing to fetch!\n"));
     269}
     270
     271void COMErrorInfo::copyFrom(const COMErrorInfo &x)
     272{
     273    mIsNull = x.mIsNull;
     274    mIsBasicAvailable = x.mIsBasicAvailable;
     275    mIsFullAvailable = x.mIsFullAvailable;
     276
     277    mResultCode = x.mResultCode;
     278    mInterfaceID = x.mInterfaceID;
     279    mComponent = x.mComponent;
     280    mText = mText;
     281
     282    if (x.m_pNext)
     283        m_pNext = new COMErrorInfo(*x.m_pNext);
     284    else
     285        m_pNext = NULL;
     286
     287    mInterfaceName = x.mInterfaceName;
     288    mCalleeIID = x.mCalleeIID;
     289    mCalleeName = x.mCalleeName;
     290}
     291
     292void COMErrorInfo::cleanup()
     293{
     294    if (m_pNext)
     295    {
     296        delete m_pNext;
     297        m_pNext = NULL;
     298    }
    268299}
    269300
     
    278309 *      UUID of the callee's interface. Ignored when callee is NULL
    279310 */
    280 void COMErrorInfo::fetchFromCurrentThread (IUnknown *callee, const GUID *calleeIID)
     311void COMErrorInfo::fetchFromCurrentThread(IUnknown *callee, const GUID *calleeIID)
    281312{
    282313    mIsNull = true;
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/COMDefs.h

    r30676 r30681  
    8484#include <QMetaType>
    8585
    86 #include <iprt/memory> // for auto_copy_ptr
    87 
    8886/*
    8987 * Additional COM / XPCOM defines and includes
     
    123121
    124122    COMErrorInfo()
    125         : mIsNull (true)
    126         , mIsBasicAvailable (false), mIsFullAvailable (false)
    127         , mResultCode (S_OK) {}
    128 
    129     COMErrorInfo (const CVirtualBoxErrorInfo &info) { init (info); }
    130 
    131     /* the default copy ctor and assignment op are ok */
     123        : mIsNull(true),
     124          mIsBasicAvailable(false),
     125          mIsFullAvailable(false),
     126          mResultCode(S_OK),
     127          m_pNext(NULL)
     128    {}
     129
     130    COMErrorInfo(const COMErrorInfo &info)
     131    {
     132        copyFrom(info);
     133    }
     134
     135    COMErrorInfo(const CVirtualBoxErrorInfo &info)
     136    {
     137        init(info);
     138    }
     139
     140    ~COMErrorInfo()
     141    {
     142        cleanup();
     143    }
     144
     145    COMErrorInfo& operator=(const COMErrorInfo &info)
     146    {
     147        cleanup();
     148        copyFrom(info);
     149        return *this;
     150    }
    132151
    133152    bool isNull() const { return mIsNull; }
     
    141160    QString text() const { return mText; }
    142161
    143     const COMErrorInfo *next() const { return mNext.get(); }
     162    const COMErrorInfo *next() const { return m_pNext; }
    144163
    145164    QString interfaceName() const { return mInterfaceName; }
     
    148167
    149168private:
    150 
    151     void init (const CVirtualBoxErrorInfo &info);
    152     void fetchFromCurrentThread (IUnknown *callee, const GUID *calleeIID);
     169    void init(const CVirtualBoxErrorInfo &info);
     170    void copyFrom(const COMErrorInfo &x);
     171    void cleanup();
     172
     173    void fetchFromCurrentThread(IUnknown *callee, const GUID *calleeIID);
    153174
    154175    static QString getInterfaceNameFromIID (const QUuid &id);
     
    163184    QString mText;
    164185
    165     cppx::auto_copy_ptr <COMErrorInfo> mNext;
     186    COMErrorInfo *m_pNext;
    166187
    167188    QString mInterfaceName;
     
    537558     * Queries the current result code and error info from the given component.
    538559     */
    539     COMResult (const COMBaseWithEI &aComponent)
    540         : mRC (aComponent.lastRC())
    541         , mErrInfo (aComponent.errorInfo()) {}
     560    COMResult(const COMBaseWithEI &aComponent)
     561        : mRC(aComponent.lastRC()),
     562          mErrInfo(aComponent.errorInfo())
     563    { }
    542564
    543565    /**
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r30676 r30681  
    147147 * Class containing the shared information service functionality.
    148148 */
    149 class Service : public stdx::non_copyable
     149class Service : public iprt::non_copyable
    150150{
    151151private:
     
    718718        switch (eFunction)
    719719        {
    720             /* 
    721              * The guest asks the host for the next messsage to process. 
     720            /*
     721             * The guest asks the host for the next messsage to process.
    722722             */
    723723            case GUEST_GET_HOST_MSG:
     
    737737
    738738            /*
    739              * The guest notifies the host that some output at stdout/stderr is available. 
     739             * The guest notifies the host that some output at stdout/stderr is available.
    740740             */
    741741            case GUEST_EXEC_SEND_OUTPUT:
     
    744744                break;
    745745
    746             /* 
    747              * The guest notifies the host of the current client status. 
     746            /*
     747             * The guest notifies the host of the current client status.
    748748             */
    749749            case GUEST_EXEC_SEND_STATUS:
  • trunk/src/VBox/HostServices/GuestProperties/service.cpp

    r30676 r30681  
    147147 * Class containing the shared information service functionality.
    148148 */
    149 class Service : public stdx::non_copyable
     149class Service : public iprt::non_copyable
    150150{
    151151private:
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r30676 r30681  
    1818
    1919#include <iprt/path.h>
     20#include <iprt/cpp/utils.h>
    2021
    2122#include <VBox/com/array.h>
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r30676 r30681  
    3030#include <iprt/path.h>
    3131#include <iprt/alloca.h>
     32#include <iprt/cpp/utils.h>
    3233
    3334#include <VBox/err.h>
  • trunk/src/VBox/Main/DHCPServerImpl.cpp

    r30676 r30681  
    2222#include "AutoCaller.h"
    2323#include "Logging.h"
     24
     25#include <iprt/cpp/utils.h>
    2426
    2527#include <VBox/settings.h>
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r30676 r30681  
    2727#include <iprt/thread.h>
    2828#include <iprt/asm.h>
     29#include <iprt/cpp/utils.h>
    2930
    3031#include <VBox/pdmdrv.h>
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r30676 r30681  
    2222#include "Logging.h"
    2323#include "netif.h"
     24
     25#include <iprt/cpp/utils.h>
    2426
    2527#ifdef RT_OS_FREEBSD
  • trunk/src/VBox/Main/KeyboardImpl.cpp

    r30676 r30681  
    2424#include <VBox/com/array.h>
    2525#include <VBox/pdmdrv.h>
     26
    2627#include <iprt/asm.h>
     28#include <iprt/cpp/utils.h>
    2729
    2830// defines
  • trunk/src/VBox/Main/MachineDebuggerImpl.cpp

    r30676 r30681  
    3333#include <VBox/err.h>
    3434#include <VBox/hwaccm.h>
     35#include <iprt/cpp/utils.h>
    3536
    3637// defines
  • trunk/src/VBox/Main/MediumAttachmentImpl.cpp

    r30676 r30681  
    2323#include "AutoCaller.h"
    2424#include "Logging.h"
     25
     26#include <iprt/cpp/utils.h>
    2527
    2628////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/MediumFormatImpl.cpp

    r30676 r30681  
    2424#include <VBox/VBoxHDD.h>
    2525
     26#include <iprt/cpp/utils.h>
     27
    2628// constructor / destructor
    2729/////////////////////////////////////////////////////////////////////////////
     
    5860
    5961    /* The ID of the backend */
    60     unconst (m.id) = aVDInfo->pszBackend;
     62    unconst(m.id) = aVDInfo->pszBackend;
    6163    /* The Name of the backend */
    6264    /* Use id for now as long as VDBACKENDINFO hasn't any extra
    6365     * name/description field. */
    64     unconst (m.name) = aVDInfo->pszBackend;
     66    unconst(m.name) = aVDInfo->pszBackend;
    6567    /* The capabilities of the backend */
    66     unconst (m.capabilities) = aVDInfo->uBackendCaps;
     68    unconst(m.capabilities) = aVDInfo->uBackendCaps;
    6769    /* Save the supported file extensions in a list */
    6870    if (aVDInfo->papszFileExtensions)
  • trunk/src/VBox/Main/MediumImpl.cpp

    r30676 r30681  
    3434#include <iprt/file.h>
    3535#include <iprt/tcp.h>
     36#include <iprt/cpp/utils.h>
    3637
    3738#include <VBox/VBoxHDD.h>
  • trunk/src/VBox/Main/MouseImpl.cpp

    r30676 r30681  
    1616 */
    1717
     18#include <iprt/cpp/utils.h>
     19
    1820#include "MouseImpl.h"
    1921#include "DisplayImpl.h"
     
    2426
    2527#include <VBox/pdmdrv.h>
     28
    2629#include <iprt/asm.h>
     30
    2731#include <VBox/VMMDev.h>
    2832
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r30676 r30681  
    3434#include <iprt/time.h>
    3535#include <iprt/semaphore.h>
     36#include <iprt/cpp/utils.h>
    3637
    3738#include <VBox/err.h>
  • trunk/src/VBox/Main/RemoteUSBDeviceImpl.cpp

    r30676 r30681  
    2424#include "Logging.h"
    2525
     26#include <iprt/cpp/utils.h>
     27
    2628#include <VBox/err.h>
    2729
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r30676 r30681  
    3636
    3737#include <iprt/path.h>
     38#include <iprt/cpp/utils.h>
     39
    3840#include <VBox/param.h>
    3941#include <VBox/err.h>
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r30676 r30681  
    3131#include <iprt/process.h>
    3232#include <iprt/ldr.h>
     33#include <iprt/cpp/utils.h>
    3334
    3435#include <VBox/err.h>
  • trunk/src/VBox/Main/USBDeviceImpl.cpp

    r30676 r30681  
    2121#include "Logging.h"
    2222
     23#include <iprt/cpp/utils.h>
     24
    2325// constructor / destructor
    2426/////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/VFSExplorerImpl.cpp

    r30676 r30681  
    2121#include <iprt/file.h>
    2222#include <iprt/s3.h>
     23#include <iprt/cpp/utils.h>
    2324
    2425#include <VBox/com/array.h>
     
    3334#include "AutoCaller.h"
    3435#include "Logging.h"
     36
     37#include <memory>
    3538
    3639////////////////////////////////////////////////////////////////////////////////
  • trunk/src/VBox/Main/glue/ErrorInfo.cpp

    r30676 r30681  
    4444////////////////////////////////////////////////////////////////////////////////
    4545
    46 void ErrorInfo::init (bool aKeepObj /* = false */)
     46void ErrorInfo::init(bool aKeepObj /* = false */)
    4747{
    4848    HRESULT rc = E_FAIL;
     
    144144}
    145145
    146 void ErrorInfo::init (IUnknown *aI, const GUID &aIID, bool aKeepObj /* = false */)
     146void ErrorInfo::init(IUnknown *aI,
     147                     const GUID &aIID,
     148                     bool aKeepObj /* = false */)
    147149{
    148150    Assert(aI);
     
    175177}
    176178
    177 void ErrorInfo::init (IVirtualBoxErrorInfo *info)
     179void ErrorInfo::init(IVirtualBoxErrorInfo *info)
    178180{
    179181    AssertReturnVoid (info);
     
    206208    gotAll &= SUCCEEDED(rc);
    207209
     210    m_pNext = NULL;
     211
    208212    ComPtr<IVirtualBoxErrorInfo> next;
    209213    rc = info->COMGETTER(Next) (next.asOutParam());
    210214    if (SUCCEEDED(rc) && !next.isNull())
    211215    {
    212         mNext.reset (new ErrorInfo (next));
    213         Assert(mNext.get());
    214         if (!mNext.get())
     216        m_pNext = new ErrorInfo(next);
     217        Assert(m_pNext);
     218        if (!m_pNext)
    215219            rc = E_OUTOFMEMORY;
    216220    }
    217     else
    218         mNext.reset();
     221
    219222    gotSomething |= SUCCEEDED(rc);
    220223    gotAll &= SUCCEEDED(rc);
     
    228231ErrorInfo::~ErrorInfo()
    229232{
     233    if (m_pNext)
     234    {
     235        delete m_pNext;
     236        m_pNext = NULL;
     237    }
    230238}
    231239
  • trunk/src/VBox/Main/glue/errorprint.cpp

    r30676 r30681  
    2828namespace com
    2929{
    30 
    3130
    3231void GluePrintErrorInfo(com::ErrorInfo &info)
     
    7574{
    7675    // if we have full error info, print something nice, and start with the actual error message
    77     com::ErrorInfo info(iface);
     76    com::ErrorInfo info(iface, COM_IIDOF(IUnknown));
    7877    if (info.isFullAvailable() || info.isBasicAvailable())
    7978        GluePrintErrorInfo(info);
  • trunk/src/VBox/Main/webservice/vboxweb.cpp

    r30676 r30681  
    913913
    914914/**
    915  * Raises a SOAP runtime fault.
     915 * Raises a SOAP runtime fault. Implementation for the RaiseSoapRuntimeFault template
     916 * function in vboxweb.h.
    916917 *
    917918 * @param pObj
    918919 */
    919 void RaiseSoapRuntimeFault(struct soap *soap,
    920                            HRESULT apirc,
    921                            IUnknown *pObj)
    922 {
    923     com::ErrorInfo info(pObj);
     920void RaiseSoapRuntimeFault2(struct soap *soap,
     921                            HRESULT apirc,
     922                            IUnknown *pObj,
     923                            const com::Guid &iid)
     924{
     925    com::ErrorInfo info(pObj, iid);
    924926
    925927    WEBDEBUG(("   error, raising SOAP exception\n"));
  • trunk/src/VBox/Main/webservice/vboxweb.h

    r30676 r30681  
    7373void RaiseSoapInvalidObjectFault(struct soap *soap, WSDLT_ID obj);
    7474
    75 void RaiseSoapRuntimeFault(struct soap *soap, HRESULT apirc, IUnknown *pObj);
     75void RaiseSoapRuntimeFault2(struct soap *soap, HRESULT apirc, IUnknown *pObj, const com::Guid &iid);
     76
     77/**
     78 * Template function called everywhere from methodmaps.cpp which calls
     79 * RaiseSoapRuntimeFault2() with the correct COM interface ID.
     80 * @param soap
     81 * @param apirc
     82 * @param pObj
     83 */
     84template <class T>
     85void RaiseSoapRuntimeFault(struct soap *soap, HRESULT apirc, const ComPtr<T> &pObj)
     86{
     87    RaiseSoapRuntimeFault2(soap, apirc, pObj, COM_IIDOF(T));
     88}
    7689
    7790/****************************************************************************
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