VirtualBox

Changeset 27607 in vbox


Ignore:
Timestamp:
Mar 22, 2010 6:13:07 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
59148
Message:

Main: remove templates for 'weak' com pointers which do nothing anyway

Location:
trunk
Files:
52 edited

Legend:

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

    r23223 r27607  
    7373    void LogRef(const char *pcszFormat, ...);
    7474}
    75 
    76 /**
    77  *  Strong referencing operators. Used as a second argument to ComPtr<>/ComObjPtr<>.
    78  */
    79 template <class C>
    80 class ComStrongRef
    81 {
    82 protected:
    83 
    84     static void addref(C *p)
    85     {
    86         p->AddRef();
    87     }
    88     static void release(C *p)
    89     {
    90         p->Release();
    91     }
    92 };
    93 
    94 /**
    95  *  Weak referencing operators. Used as a second argument to ComPtr<>/ComObjPtr<>.
    96  */
    97 template <class C>
    98 class ComWeakRef
    99 {
    100 protected:
    101 
    102     static void addref(C * /* p */) {}
    103     static void release(C * /* p */) {}
    104 };
    10575
    10676/**
     
    169139 *  Base template for smart COM pointers. Not intended to be used directly.
    170140 */
    171 template <class C, template <class> class RefOps = ComStrongRef>
    172 class ComPtrBase : protected RefOps <C>
     141template <class C>
     142class ComPtrBase
    173143{
    174144public:
     
    190160protected:
    191161
    192     ComPtrBase () : p (NULL) {}
    193     ComPtrBase (const ComPtrBase &that) : p (that.p) { addref(); }
    194     ComPtrBase (C *that_p) : p (that_p) { addref(); }
    195 
    196     ~ComPtrBase() { release(); }
    197 
    198     ComPtrBase &operator= (const ComPtrBase &that)
    199     {
    200         safe_assign (that.p);
    201         return *this;
    202     }
    203 
    204     ComPtrBase &operator= (C *that_p)
    205     {
    206         safe_assign (that_p);
     162    ComPtrBase()
     163        : p(NULL)
     164    {}
     165
     166    ComPtrBase(const ComPtrBase &that)
     167        : p(that.p)
     168    {
     169        addref();
     170    }
     171
     172    ComPtrBase(C *that_p)
     173        : p(that_p)
     174    {
     175        addref();
     176    }
     177
     178    ~ComPtrBase()
     179    {
     180        release();
     181    }
     182
     183    ComPtrBase &operator=(const ComPtrBase &that)
     184    {
     185        safe_assign(that.p);
     186        return *this;
     187    }
     188
     189    ComPtrBase &operator=(C *that_p)
     190    {
     191        safe_assign(that_p);
    207192        return *this;
    208193    }
     
    221206    }
    222207
    223     bool operator! () const { return isNull(); }
    224 
    225     bool operator< (C* that_p) const { return p < that_p; }
    226     bool operator== (C* that_p) const { return p == that_p; }
     208    bool operator!() const { return isNull(); }
     209
     210    bool operator<(C* that_p) const { return p < that_p; }
     211    bool operator==(C* that_p) const { return p == that_p; }
    227212
    228213    template <class I>
    229     bool equalsTo (I *aThat) const
    230     {
    231         return ComPtrEquals (p, aThat);
     214    bool equalsTo(I *aThat) const
     215    {
     216        return ComPtrEquals(p, aThat);
    232217    }
    233218
    234219    template <class OC>
    235     bool equalsTo (const ComPtrBase <OC> &oc) const
    236     {
    237         return equalsTo ((OC *) oc);
     220    bool equalsTo(const ComPtrBase <OC> &oc) const
     221    {
     222        return equalsTo((OC*)oc);
    238223    }
    239224
    240225    /** Intended to pass instances as in parameters to interface methods */
    241     operator C* () const { return p; }
     226    operator C*() const { return p; }
    242227
    243228    /**
     
    245230     *  pointer).
    246231     */
    247     NoAddRefRelease <C> *operator-> () const
    248     {
    249         AssertMsg (p, ("Managed pointer must not be null\n"));
    250         return (NoAddRefRelease <C> *) p;
     232    NoAddRefRelease<C>* operator->() const
     233    {
     234        AssertMsg(p, ("Managed pointer must not be null\n"));
     235        return (NoAddRefRelease<C>*)p;
    251236    }
    252237
    253238    template <class I>
    254     HRESULT queryInterfaceTo (I **pp) const
     239    HRESULT queryInterfaceTo(I **pp) const
    255240    {
    256241        if (pp)
     
    258243            if (p)
    259244            {
    260                 return p->QueryInterface (COM_IIDOF (I), (void **) pp);
     245                return p->QueryInterface(COM_IIDOF(I), (void**)pp);
    261246            }
    262247            else
     
    282267    {
    283268        if (p)
    284             RefOps <C>::addref (p);
     269            p->AddRef();
    285270    }
    286271
     
    288273    {
    289274        if (p)
    290             RefOps <C>::release (p);
     275            p->Release();
    291276    }
    292277
     
    295280        /* be aware of self-assignment */
    296281        if (that_p)
    297             RefOps <C>::addref (that_p);
     282            that_p->AddRef();
    298283        release();
    299284        p = that_p;
     
    309294 *  @param I    COM interface class
    310295 */
    311 template <class I, template <class> class RefOps = ComStrongRef>
    312 class ComPtr : public ComPtrBase <I, RefOps>
    313 {
    314     typedef ComPtrBase <I, RefOps> Base;
     296template <class I>
     297class ComPtr : public ComPtrBase<I>
     298{
     299    typedef ComPtrBase<I> Base;
    315300
    316301public:
    317302
    318     ComPtr () : Base() {}
    319     ComPtr (const ComPtr &that) : Base (that) {}
    320     ComPtr &operator= (const ComPtr &that)
     303    ComPtr() : Base() {}
     304    ComPtr(const ComPtr &that) : Base(that) {}
     305    ComPtr& operator=(const ComPtr &that)
    321306    {
    322307        Base::operator= (that);
     
    325310
    326311    template <class OI>
    327     ComPtr (OI *that_p) : Base () { operator= (that_p); }
     312    ComPtr(OI *that_p) : Base() { operator=(that_p); }
    328313
    329314    /* specialization for I */
    330     ComPtr (I *that_p) : Base (that_p) {}
     315    ComPtr(I *that_p) : Base(that_p) {}
    331316
    332317    template <class OC>
    333     ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *) oc); }
     318    ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); }
    334319
    335320    template <class OI>
    336     ComPtr &operator= (OI *that_p)
     321    ComPtr &operator=(OI *that_p)
    337322    {
    338323        if (that_p)
    339             that_p->QueryInterface (COM_IIDOF (I), (void **) Base::asOutParam());
     324            that_p->QueryInterface(COM_IIDOF(I), (void**)Base::asOutParam());
    340325        else
    341326            Base::setNull();
     
    346331    ComPtr &operator=(I *that_p)
    347332    {
    348         Base::operator= (that_p);
     333        Base::operator=(that_p);
    349334        return *this;
    350335    }
    351336
    352337    template <class OC>
    353     ComPtr &operator= (const ComPtr <OC, RefOps> &oc)
    354     {
    355         return operator= ((OC *) oc);
     338    ComPtr &operator=(const ComPtr<OC> &oc)
     339    {
     340        return operator=((OC*)oc);
    356341    }
    357342
     
    365350        I *obj = NULL;
    366351#if !defined (VBOX_WITH_XPCOM)
    367         rc = CoCreateInstance (clsid, NULL, CLSCTX_INPROC_SERVER, _ATL_IIDOF (I),
    368                                (void **) &obj);
     352        rc = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, _ATL_IIDOF(I),
     353                              (void**)&obj);
    369354#else /* !defined (VBOX_WITH_XPCOM) */
    370         nsCOMPtr <nsIComponentManager> manager;
    371         rc = NS_GetComponentManager (getter_AddRefs (manager));
    372         if (SUCCEEDED (rc))
    373             rc = manager->CreateInstance (clsid, nsnull, NS_GET_IID (I),
    374                                           (void **) &obj);
     355        nsCOMPtr<nsIComponentManager> manager;
     356        rc = NS_GetComponentManager(getter_AddRefs(manager));
     357        if (SUCCEEDED(rc))
     358            rc = manager->CreateInstance(clsid, nsnull, NS_GET_IID(I),
     359                                         (void **) &obj);
    375360#endif /* !defined (VBOX_WITH_XPCOM) */
    376361        *this = obj;
    377         if (SUCCEEDED (rc))
     362        if (SUCCEEDED(rc))
    378363            obj->Release();
    379364        return rc;
     
    389374     *  method is fully equivalent to #createInprocObject() for now.
    390375     */
    391     HRESULT createLocalObject (const CLSID &clsid)
     376    HRESULT createLocalObject(const CLSID &clsid)
    392377    {
    393378#if !defined (VBOX_WITH_XPCOM)
    394379        HRESULT rc;
    395380        I *obj = NULL;
    396         rc = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER, _ATL_IIDOF (I),
    397                                (void **) &obj);
     381        rc = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, _ATL_IIDOF(I),
     382                              (void**)&obj);
    398383        *this = obj;
    399         if (SUCCEEDED (rc))
     384        if (SUCCEEDED(rc))
    400385            obj->Release();
    401386        return rc;
    402387#else /* !defined (VBOX_WITH_XPCOM) */
    403         return createInprocObject (clsid);
     388        return createInprocObject(clsid);
    404389#endif /* !defined (VBOX_WITH_XPCOM) */
    405390    }
     
    412397     *  @param serverName   Name of the server to create an object within.
    413398     */
    414     HRESULT createObjectOnServer (const CLSID &clsid, const char *serverName)
     399    HRESULT createObjectOnServer(const CLSID &clsid, const char *serverName)
    415400    {
    416401        HRESULT rc;
    417402        I *obj = NULL;
    418         nsCOMPtr <ipcIService> ipcServ = do_GetService (IPC_SERVICE_CONTRACTID, &rc);
    419         if (SUCCEEDED (rc))
     403        nsCOMPtr<ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc);
     404        if (SUCCEEDED(rc))
    420405        {
    421406            PRUint32 serverID = 0;
    422             rc = ipcServ->ResolveClientName (serverName, &serverID);
     407            rc = ipcServ->ResolveClientName(serverName, &serverID);
    423408            if (SUCCEEDED (rc))
    424409            {
    425                 nsCOMPtr <ipcIDConnectService> dconServ =
    426                     do_GetService (IPC_DCONNECTSERVICE_CONTRACTID, &rc);
    427                 if (SUCCEEDED (rc))
    428                     rc = dconServ->CreateInstance (serverID, clsid, NS_GET_IID (I),
    429                                                    (void **) &obj);
     410                nsCOMPtr<ipcIDConnectService> dconServ = do_GetService(IPC_DCONNECTSERVICE_CONTRACTID, &rc);
     411                if (SUCCEEDED(rc))
     412                    rc = dconServ->CreateInstance(serverID, clsid, NS_GET_IID(I),
     413                                                  (void**)&obj);
    430414            }
    431415        }
    432416        *this = obj;
    433         if (SUCCEEDED (rc))
     417        if (SUCCEEDED(rc))
    434418            obj->Release();
    435419        return rc;
     
    443427 *  another interface pointer disregarding its type.
    444428 */
    445 template <template <class> class RefOps>
    446 class ComPtr <IUnknown, RefOps> : public ComPtrBase <IUnknown, RefOps>
    447 {
    448     typedef ComPtrBase <IUnknown, RefOps> Base;
     429template<>
     430class ComPtr<IUnknown> : public ComPtrBase<IUnknown>
     431{
     432    typedef ComPtrBase<IUnknown> Base;
    449433
    450434public:
    451435
    452     ComPtr () : Base() {}
    453     ComPtr (const ComPtr &that) : Base (that) {}
    454     ComPtr &operator= (const ComPtr &that)
    455     {
    456         Base::operator= (that);
     436    ComPtr() : Base() {}
     437    ComPtr(const ComPtr &that) : Base (that) {}
     438    ComPtr& operator=(const ComPtr &that)
     439    {
     440        Base::operator=(that);
    457441        return *this;
    458442    }
    459443
    460444    template <class OI>
    461     ComPtr (OI *that_p) : Base () { operator= (that_p); }
     445    ComPtr(OI *that_p) : Base() { operator=(that_p); }
    462446
    463447    template <class OC>
    464     ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *) oc); }
     448    ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); }
    465449
    466450    template <class OI>
    467     ComPtr &operator= (OI *that_p)
     451    ComPtr &operator=(OI *that_p)
    468452    {
    469453        if (that_p)
    470             that_p->QueryInterface (COM_IIDOF (IUnknown), (void **) Base::asOutParam());
     454            that_p->QueryInterface(COM_IIDOF(IUnknown), (void**)Base::asOutParam());
    471455        else
    472456            Base::setNull();
     
    475459
    476460    template <class OC>
    477     ComPtr &operator= (const ComPtr <OC, RefOps> &oc)
    478     {
    479         return operator= ((OC *) oc);
     461    ComPtr &operator=(const ComPtr<OC> &oc)
     462    {
     463        return operator=((OC*)oc);
    480464    }
    481465};
     
    489473 *  @param C    class that implements some COM interface
    490474 */
    491 template <class C, template <class> class RefOps = ComStrongRef>
    492 class ComObjPtr : public ComPtrBase <C, RefOps>
    493 {
    494     typedef ComPtrBase <C, RefOps> Base;
     475template <class C>
     476class ComObjPtr : public ComPtrBase<C>
     477{
     478    typedef ComPtrBase<C> Base;
    495479
    496480public:
    497481
    498     ComObjPtr () : Base() {}
    499     ComObjPtr (const ComObjPtr &that) : Base (that) {}
    500     ComObjPtr (C *that_p) : Base (that_p) {}
    501 
    502     ComObjPtr &operator= (const ComObjPtr &that)
    503     {
    504         Base::operator= (that);
    505         return *this;
    506     }
    507 
    508     ComObjPtr &operator= (C *that_p)
    509     {
    510         Base::operator= (that_p);
     482    ComObjPtr() : Base() {}
     483    ComObjPtr(const ComObjPtr &that) : Base(that) {}
     484    ComObjPtr(C *that_p) : Base(that_p) {}
     485
     486    ComObjPtr& operator=(const ComObjPtr &that)
     487    {
     488        Base::operator=(that);
     489        return *this;
     490    }
     491
     492    ComObjPtr& operator=(C *that_p)
     493    {
     494        Base::operator=(that_p);
    511495        return *this;
    512496    }
     
    530514#if !defined (VBOX_WITH_XPCOM)
    531515#   ifdef VBOX_COM_OUTOFPROC_MODULE
    532         CComObjectNoLock <C> *obj = new CComObjectNoLock <C>();
     516        CComObjectNoLock<C> *obj = new CComObjectNoLock<C>();
    533517        if (obj)
    534518        {
     
    540524            rc = E_OUTOFMEMORY;
    541525#   else
    542         CComObject <C> *obj = NULL;
    543         rc = CComObject <C>::CreateInstance (&obj);
     526        CComObject<C> *obj = NULL;
     527        rc = CComObject<C>::CreateInstance(&obj);
    544528#   endif
    545529#else /* !defined (VBOX_WITH_XPCOM) */
    546         CComObject <C> *obj = new CComObject <C>();
     530        CComObject<C> *obj = new CComObject<C>();
    547531        if (obj)
    548532            rc = obj->FinalConstruct();
  • trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp

    r27251 r27607  
    7979
    8080/* global weak references (for event handlers) */
    81 static ComPtr <ISession, ComWeakRef> gSession;
    82 static ComPtr <IConsole, ComWeakRef> gConsole;
     81static ISession *gSession = NULL;
     82static IConsole *gConsole = NULL;
    8383static EventQueue *gEventQ = NULL;
    8484
  • trunk/src/VBox/Main/ApplianceImpl.cpp

    r26753 r27607  
    318318////////////////////////////////////////////////////////////////////////////////
    319319
    320 DEFINE_EMPTY_CTOR_DTOR(Appliance)
     320Appliance::Appliance()
     321    : mVirtualBox(NULL)
     322{
     323}
     324
     325Appliance::~Appliance()
     326{
     327}
    321328
    322329/**
  • trunk/src/VBox/Main/AudioAdapterImpl.cpp

    r26235 r27607  
    3434/////////////////////////////////////////////////////////////////////////////
    3535
    36 DEFINE_EMPTY_CTOR_DTOR (AudioAdapter)
     36AudioAdapter::AudioAdapter()
     37    : mParent(NULL)
     38{
     39}
     40
     41AudioAdapter::~AudioAdapter()
     42{
     43}
    3744
    3845HRESULT AudioAdapter::FinalConstruct()
     
    4350void AudioAdapter::FinalRelease()
    4451{
    45     uninit ();
     52    uninit();
    4653}
    4754
     
    169176    mData.free();
    170177
    171     unconst(mPeer).setNull();
    172     unconst(mParent).setNull();
     178    unconst(mPeer) = NULL;
     179    unconst(mParent) = NULL;
    173180}
    174181
  • trunk/src/VBox/Main/AudioSnifferInterface.cpp

    r26173 r27607  
    6868// constructor / destructor
    6969//
    70 AudioSniffer::AudioSniffer(Console *console) : mpDrv(NULL)
    71 {
    72     mParent = console;
     70AudioSniffer::AudioSniffer(Console *console)
     71    : mpDrv(NULL),
     72      mParent(console)
     73{
    7374}
    7475
  • trunk/src/VBox/Main/BIOSSettingsImpl.cpp

    r27059 r27607  
    4040{
    4141    Data()
     42        : pMachine(NULL)
    4243    { }
    4344
    44     ComObjPtr<Machine, ComWeakRef>  pMachine;
    45     ComObjPtr<BIOSSettings>         pPeer;
     45    Machine * const             pMachine;
     46    ComObjPtr<BIOSSettings>     pPeer;
    4647
    4748    // use the XML settings structure in the members for simplicity
     
    115116    m = new Data();
    116117
    117     m->pMachine = aParent;
     118    unconst(m->pMachine) = aParent;
    118119    m->pPeer = that;
    119120
     
    145146    m = new Data();
    146147
    147     m->pMachine = aParent;
     148    unconst(m->pMachine) = aParent;
    148149    // mPeer is left null
    149150
     
    172173    m->bd.free();
    173174
    174     m->pPeer.setNull();
    175     m->pMachine.setNull();
     175    unconst(m->pPeer) = NULL;
     176    unconst(m->pMachine) = NULL;
    176177
    177178    delete m;
  • trunk/src/VBox/Main/ConsoleVRDPServer.cpp

    r26782 r27607  
    21702170        return;
    21712171
    2172     unconst(mParent).setNull();
     2172    unconst(mParent) = NULL;
    21732173}
    21742174
  • trunk/src/VBox/Main/DHCPServerImpl.cpp

    r26163 r27607  
    3434/////////////////////////////////////////////////////////////////////////////
    3535
    36 DEFINE_EMPTY_CTOR_DTOR (DHCPServer)
     36DHCPServer::DHCPServer()
     37    : mVirtualBox(NULL)
     38{
     39}
     40
     41DHCPServer::~DHCPServer()
     42{
     43}
    3744
    3845HRESULT DHCPServer::FinalConstruct()
     
    5360        return;
    5461
    55     unconst(mVirtualBox).setNull();
     62    unconst(mVirtualBox) = NULL;
    5663}
    5764
  • trunk/src/VBox/Main/DisplayImpl.cpp

    r27560 r27607  
    7676/////////////////////////////////////////////////////////////////////////////
    7777
    78 DEFINE_EMPTY_CTOR_DTOR(Display)
     78Display::Display()
     79    : mParent(NULL)
     80{
     81}
     82
     83Display::~Display()
     84{
     85}
     86
    7987
    8088HRESULT Display::FinalConstruct()
     
    663671        mParent->UnregisterCallback (this);
    664672
    665     unconst(mParent).setNull();
     673    unconst(mParent) = NULL;
    666674
    667675    if (mpDrv)
  • trunk/src/VBox/Main/GuestImpl.cpp

    r27190 r27607  
    111111        return;
    112112
    113     unconst(mParent).setNull();
     113    unconst(mParent) = NULL;
    114114}
    115115
  • trunk/src/VBox/Main/HostImpl.cpp

    r27537 r27607  
    157157    {};
    158158
    159     ComObjPtr<VirtualBox, ComWeakRef>
    160                             pParent;
     159    VirtualBox              *pParent;
    161160
    162161#ifdef VBOX_WITH_USB
  • trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp

    r26753 r27607  
    3434/////////////////////////////////////////////////////////////////////////////
    3535
    36 DEFINE_EMPTY_CTOR_DTOR (HostNetworkInterface)
     36HostNetworkInterface::HostNetworkInterface()
     37    : mVBox(NULL)
     38{
     39}
     40
     41HostNetworkInterface::~HostNetworkInterface()
     42{
     43}
    3744
    3845HRESULT HostNetworkInterface::FinalConstruct()
     
    550557    AutoCaller autoCaller(this);
    551558    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    552     mVBox = pVBox;
     559    unconst(mVBox) = pVBox;
    553560
    554561    /* If IPv4 address hasn't been initialized */
  • trunk/src/VBox/Main/KeyboardImpl.cpp

    r26235 r27607  
    120120    mfVMMDevInited = true;
    121121
    122     unconst(mParent).setNull();
     122    unconst(mParent) = NULL;
    123123}
    124124
  • trunk/src/VBox/Main/MachineDebuggerImpl.cpp

    r26235 r27607  
    4949/////////////////////////////////////////////////////////////////////////////
    5050
    51 DEFINE_EMPTY_CTOR_DTOR (MachineDebugger)
     51MachineDebugger::MachineDebugger()
     52    : mParent(NULL)
     53{
     54}
     55
     56MachineDebugger::~MachineDebugger()
     57{
     58}
    5259
    5360HRESULT MachineDebugger::FinalConstruct()
     
    111118        return;
    112119
    113     unconst(mParent).setNull();
     120    unconst(mParent) = NULL;
    114121    mFlushMode = false;
    115122}
  • trunk/src/VBox/Main/MachineImpl.cpp

    r27537 r27607  
    238238
    239239Machine::Machine()
     240    : mPeer(NULL), mParent(NULL)
    240241{}
    241242
     
    607608
    608609    /* mParent is constant during life time, no need to lock */
    609     mParent.queryInterfaceTo(aParent);
     610    ComObjPtr<VirtualBox> pVirtualBox(mParent);
     611    pVirtualBox.queryInterfaceTo(aParent);
    610612
    611613    return S_OK;
     
    60506052
    60516053/**
     6054 *  Returns a pointer to the Machine object for this machine that acts like a
     6055 *  parent for complex machine data objects such as shared folders, etc.
     6056 *
     6057 *  For primary Machine objects and for SnapshotMachine objects, returns this
     6058 *  object's pointer itself. For SessoinMachine objects, returns the peer
     6059 *  (primary) machine pointer.
     6060 */
     6061Machine* Machine::getMachine()
     6062{
     6063    if (getClassID() == clsidSessionMachine)
     6064        return (Machine*)mPeer;
     6065    return this;
     6066}
     6067
     6068/**
    60526069 * Makes sure that there are no machine state dependants. If necessary, waits
    60536070 * for the number of dependants to drop to zero.
     
    90849101        uninitDataAndChildObjects();
    90859102        mData.free();
    9086         unconst(mParent).setNull();
    9087         unconst(mPeer).setNull();
     9103        unconst(mParent) = NULL;
     9104        unconst(mPeer) = NULL;
    90889105        LogFlowThisFuncLeave();
    90899106        return;
     
    92799296    alock.leave();
    92809297
    9281     unconst(mParent).setNull();
    9282     unconst(mPeer).setNull();
     9298    unconst(mParent) = NULL;
     9299    unconst(mPeer) = NULL;
    92839300
    92849301    LogFlowThisFuncLeave();
     
    92949311RWLockHandle *SessionMachine::lockHandle() const
    92959312{
    9296     AssertReturn(!mPeer.isNull(), NULL);
     9313    AssertReturn(mPeer != NULL, NULL);
    92979314    return mPeer->lockHandle();
    92989315}
     
    95889605        ComObjPtr<Progress> progress;
    95899606        progress.createObject();
    9590         progress->init(mParent, static_cast<IMachine *>(mPeer),
     9607        progress->init(mParent, mPeer,
    95919608                       Bstr(tr("Closing session")), FALSE /* aCancelable */);
    95929609        progress.queryInterfaceTo(aProgress);
  • trunk/src/VBox/Main/MediumAttachmentImpl.cpp

    r26562 r27607  
    6161{
    6262    Data()
     63        : pMachine(NULL)
    6364    { }
    6465
    6566    /** Reference to Machine object, for checking mutable state. */
    66     const ComObjPtr<Machine, ComWeakRef> pMachine;
     67    Machine * const pMachine;
    6768    /* later: const ComObjPtr<MediumAttachment> mPeer; */
    6869
     
    164165    m->bd.free();
    165166
    166     unconst(m->pMachine).setNull();
     167    unconst(m->pMachine) = NULL;
    167168
    168169    delete m;
  • trunk/src/VBox/Main/MediumImpl.cpp

    r27592 r27607  
    8888{
    8989    Data()
    90         : state(MediumState_NotCreated),
     90        : pVirtualBox(NULL),
     91          state(MediumState_NotCreated),
    9192          size(0),
    9293          readers(0),
     
    108109
    109110    /** weak VirtualBox parent */
    110     const ComObjPtr<VirtualBox, ComWeakRef> pVirtualBox;
     111    VirtualBox * const pVirtualBox;
    111112
    112113    const Guid id;
     
    13711372    m->queryInfoSem = NIL_RTSEMEVENTMULTI;
    13721373
    1373     unconst(m->pVirtualBox).setNull();
     1374    unconst(m->pVirtualBox) = NULL;
    13741375}
    13751376
  • trunk/src/VBox/Main/MouseImpl.cpp

    r27403 r27607  
    6363/////////////////////////////////////////////////////////////////////////////
    6464
    65 DEFINE_EMPTY_CTOR_DTOR (Mouse)
     65Mouse::Mouse()
     66    : mParent(NULL)
     67{
     68}
     69
     70Mouse::~Mouse()
     71{
     72}
     73
    6674
    6775HRESULT Mouse::FinalConstruct()
     
    138146    mParent = NULL;
    139147#else
    140     unconst(mParent).setNull();
     148    unconst(mParent) = NULL;
    141149#endif
    142150}
  • trunk/src/VBox/Main/NetworkAdapterImpl.cpp

    r26818 r27607  
    3737////////////////////////////////////////////////////////////////////////////////
    3838
    39 DEFINE_EMPTY_CTOR_DTOR (NetworkAdapter)
     39NetworkAdapter::NetworkAdapter()
     40    : mParent(NULL)
     41{
     42}
     43
     44NetworkAdapter::~NetworkAdapter()
     45{
     46}
    4047
    4148HRESULT NetworkAdapter::FinalConstruct()
     
    174181    mData.free();
    175182
    176     unconst(mPeer).setNull();
    177     unconst(mParent).setNull();
     183    unconst(mPeer) = NULL;
     184    unconst(mParent) = NULL;
    178185}
    179186
  • trunk/src/VBox/Main/ParallelPortImpl.cpp

    r26235 r27607  
    4242{
    4343    Data()
    44         : fModified(false)
     44        : fModified(false),
     45          pMachine(NULL)
    4546    { }
    4647
    4748    bool                                    fModified;
    4849
    49     const ComObjPtr<Machine, ComWeakRef>    pMachine;
     50    Machine * const                         pMachine;
    5051    const ComObjPtr<ParallelPort>           pPeer;
    5152
     
    186187    m->bd.free();
    187188
    188     unconst(m->pPeer).setNull();
    189     unconst(m->pMachine).setNull();
     189    unconst(m->pPeer) = NULL;
     190    unconst(m->pMachine) = NULL;
    190191
    191192    delete m;
  • trunk/src/VBox/Main/ProgressImpl.cpp

    r26603 r27607  
    4848////////////////////////////////////////////////////////////////////////////////
    4949
    50 DEFINE_EMPTY_CTOR_DTOR (ProgressBase)
     50ProgressBase::ProgressBase()
     51#if !defined (VBOX_COM_INPROC)
     52    : mParent(NULL)
     53#endif
     54{
     55}
     56
     57ProgressBase::~ProgressBase()
     58{
     59}
     60
    5161
    5262/**
     
    92102 *                      NULL which means initiator = parent, otherwise must not
    93103 *                      be NULL).
    94  * @param aDescription  Task description.
     104 * @param aDescription  ask description.
    95105 * @param aID           Address of result GUID structure (optional).
    96106 *
     
    127137     * (to avoid cycling); otherwise mInitiator will remain null which means
    128138     * that it is the same as the parent */
    129     if (aInitiator && !mParent.equalsTo (aInitiator))
    130         unconst(mInitiator) = aInitiator;
     139    if (aInitiator)
     140    {
     141        ComObjPtr<VirtualBox> pVirtualBox(mParent);
     142        if (!pVirtualBox.equalsTo(aInitiator))
     143            unconst(mInitiator) = aInitiator;
     144    }
    131145#else
    132146    unconst(mInitiator) = aInitiator;
     
    191205            mParent->removeProgress (mId);
    192206
    193         unconst(mParent).setNull();
     207        unconst(mParent) = NULL;
    194208    }
    195209#endif
     
    238252        mInitiator.queryInterfaceTo(aInitiator);
    239253    else
    240         mParent.queryInterfaceTo(aInitiator);
     254    {
     255        ComObjPtr<VirtualBox> pVirtualBox(mParent);
     256        pVirtualBox.queryInterfaceTo(aInitiator);
     257    }
    241258#else
    242259    mInitiator.queryInterfaceTo(aInitiator);
  • trunk/src/VBox/Main/SerialPortImpl.cpp

    r27059 r27607  
    4343{
    4444    Data()
    45         : fModified(false)
     45        : fModified(false),
     46          pMachine(NULL)
    4647    { }
    4748
    48     bool                                    fModified;
    49 
    50     const ComObjPtr<Machine, ComWeakRef>    pMachine;
    51     const ComObjPtr<SerialPort>             pPeer;
    52 
    53     Backupable<settings::SerialPort>        bd;
     49    bool                                fModified;
     50
     51    Machine * const                     pMachine;
     52    const ComObjPtr<SerialPort>         pPeer;
     53
     54    Backupable<settings::SerialPort>    bd;
    5455};
    5556
     
    189190    m->bd.free();
    190191
    191     unconst(m->pPeer).setNull();
    192     unconst(m->pMachine).setNull();
     192    unconst(m->pPeer) = NULL;
     193    unconst(m->pMachine) = NULL;
    193194
    194195    delete m;
  • trunk/src/VBox/Main/SharedFolderImpl.cpp

    r26753 r27607  
    3636
    3737SharedFolder::SharedFolder()
    38     : mParent (NULL)
     38    : mParent(NULL),
     39      mMachine(NULL),
     40      mConsole(NULL),
     41      mVirtualBox(NULL)
    3942{
    4043}
     
    248251    unconst(mParent) = NULL;
    249252
    250     unconst(mMachine).setNull();
    251     unconst(mConsole).setNull();
    252     unconst(mVirtualBox).setNull();
     253    unconst(mMachine) = NULL;
     254    unconst(mConsole) = NULL;
     255    unconst(mVirtualBox) = NULL;
    253256}
    254257
  • trunk/src/VBox/Main/SnapshotImpl.cpp

    r27278 r27607  
    7777{
    7878    Data()
     79        : pVirtualBox(NULL)
    7980    {
    8081        RTTimeSpecSetMilli(&timeStamp, 0);
     
    9192
    9293    /** weak VirtualBox parent */
    93     const ComObjPtr<VirtualBox, ComWeakRef> pVirtualBox;
     94    VirtualBox * const          pVirtualBox;
    9495
    9596    // pParent and llChildren are protected by Machine::snapshotsTreeLockHandle()
     
    10491050    mData.free();
    10501051
    1051     unconst(mParent).setNull();
    1052     unconst(mPeer).setNull();
     1052    unconst(mParent) = NULL;
     1053    unconst(mPeer) = NULL;
    10531054
    10541055    LogFlowThisFuncLeave();
     
    10611062RWLockHandle *SnapshotMachine::lockHandle() const
    10621063{
    1063     AssertReturn(!mPeer.isNull(), NULL);
     1064    AssertReturn(mPeer != NULL, NULL);
    10641065    return mPeer->lockHandle();
    10651066}
  • trunk/src/VBox/Main/StorageControllerImpl.cpp

    r26235 r27607  
    8080{
    8181    Data()
     82        : pParent(NULL)
    8283    { }
    8384
    84     const ComObjPtr<Machine, ComWeakRef>    pParent;
    85     const ComObjPtr<StorageController>      pPeer;
     85    Machine * const                     pParent;
     86    const ComObjPtr<StorageController>  pPeer;
    8687
    8788    Backupable<BackupableStorageControllerData> bd;
     
    290291    m->pParent->removeDependentChild(this);
    291292
    292     unconst(m->pPeer).setNull();
    293     unconst(m->pParent).setNull();
     293    unconst(m->pPeer) = NULL;
     294    unconst(m->pParent) = NULL;
    294295
    295296    delete m;
     
    775776    }
    776777
    777     unconst(m->pPeer).setNull();
    778 }
    779 
    780 const ComObjPtr<Machine, ComWeakRef>& StorageController::getMachine()
     778    unconst(m->pPeer) = NULL;
     779}
     780
     781Machine* StorageController::getMachine()
    781782{
    782783    return m->pParent;
  • trunk/src/VBox/Main/SystemPropertiesImpl.cpp

    r26753 r27607  
    4747/////////////////////////////////////////////////////////////////////////////
    4848
    49 DEFINE_EMPTY_CTOR_DTOR (SystemProperties)
     49SystemProperties::SystemProperties()
     50    : mParent(NULL)
     51{
     52}
     53
     54SystemProperties::~SystemProperties()
     55{
     56}
     57
    5058
    5159HRESULT SystemProperties::FinalConstruct()
     
    170178        return;
    171179
    172     unconst(mParent).setNull();
     180    unconst(mParent) = NULL;
    173181}
    174182
  • trunk/src/VBox/Main/USBControllerImpl.cpp

    r26968 r27607  
    6262struct USBController::Data
    6363{
    64     Data() {};
    65     ~Data() {};
     64    Data()
     65        : pParent(NULL)
     66    {};
     67
     68    ~Data()
     69    {};
    6670
    6771    /** Parent object. */
    68     const ComObjPtr<Machine, ComWeakRef> pParent;
     72    Machine * const                pParent;
    6973    /** Peer object. */
    70     const ComObjPtr<USBController> pPeer;
    71 
    72     Backupable<BackupableUSBData>  bd;
     74    const ComObjPtr<USBController>  pPeer;
     75
     76    Backupable<BackupableUSBData>   bd;
    7377#ifdef VBOX_WITH_USB
    7478    // the following fields need special backup/rollback/commit handling,
     
    250254    m->bd.free();
    251255
    252     unconst(m->pPeer).setNull();
    253     unconst(m->pParent).setNull();
     256    unconst(m->pPeer) = NULL;
     257    unconst(m->pParent) = NULL;
    254258
    255259    delete m;
  • trunk/src/VBox/Main/VFSExplorerImpl.cpp

    r26753 r27607  
    6767};
    6868
    69 DEFINE_EMPTY_CTOR_DTOR(VFSExplorer)
     69VFSExplorer::VFSExplorer()
     70    : mVirtualBox(NULL)
     71{
     72}
     73
     74VFSExplorer::~VFSExplorer()
     75{
     76}
     77
    7078
    7179/**
  • trunk/src/VBox/Main/VMMDevInterface.cpp

    r26782 r27607  
    8989// constructor / destructor
    9090//
    91 VMMDev::VMMDev(Console *console) : mpDrv(NULL)
    92 {
    93     mParent = console;
     91VMMDev::VMMDev(Console *console)
     92    : mpDrv(NULL),
     93      mParent(console)
     94{
    9495    int rc = RTSemEventCreate(&mCredentialsEvent);
    9596    AssertRC(rc);
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r27257 r27607  
    136136     *  is bound to the lifetime of the VirtualBox instance, so it's safe.
    137137     */
    138     ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     138    VirtualBox        *mVirtualBox;
    139139};
    140140
     
    43454345void *VirtualBox::CallbackEvent::handler()
    43464346{
    4347     if (mVirtualBox.isNull())
     4347    if (!mVirtualBox)
    43484348        return NULL;
    43494349
     
    43554355                         autoCaller.state()));
    43564356        /* We don't need mVirtualBox any more, so release it */
    4357         mVirtualBox.setNull();
     4357        mVirtualBox = NULL;
    43584358        return NULL;
    43594359    }
     
    43654365        callbacks = mVirtualBox->m->llCallbacks;
    43664366        /* We don't need mVirtualBox any more, so release it */
    4367         mVirtualBox.setNull();
     4367        mVirtualBox = NULL;
    43684368    }
    43694369
  • trunk/src/VBox/Main/include/ApplianceImpl.h

    r26603 r27607  
    8585private:
    8686    /** weak VirtualBox parent */
    87     const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     87    VirtualBox* const  mVirtualBox;
    8888
    8989    struct Data;            // opaque, defined in ApplianceImpl.cpp
  • trunk/src/VBox/Main/include/AudioAdapterImpl.h

    r26171 r27607  
    9393private:
    9494
    95     const ComObjPtr<Machine, ComWeakRef> mParent;
     95    Machine * const    mParent;
    9696    const ComObjPtr<AudioAdapter> mPeer;
    9797
    98     Backupable<Data> mData;
     98    Backupable<Data>    mData;
    9999};
    100100
  • trunk/src/VBox/Main/include/AudioSnifferInterface.h

    r26173 r27607  
    4747    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
    4848
    49     ComObjPtr<Console, ComWeakRef> mParent;
     49    Console * const    mParent;
    5050};
    5151
  • trunk/src/VBox/Main/include/ConsoleVRDPServer.h

    r25728 r27607  
    287287private:
    288288
    289     const ComObjPtr<Console, ComWeakRef> mParent;
     289    Console * const        mParent;
    290290};
    291291
  • trunk/src/VBox/Main/include/DHCPServerImpl.h

    r26163 r27607  
    8888private:
    8989    /** weak VirtualBox parent */
    90     const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     90    VirtualBox * const      mVirtualBox;
    9191
    9292    const Bstr mName;
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r26782 r27607  
    304304    static DECLCALLBACK(int)   displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
    305305
    306     const ComObjPtr<Console, ComWeakRef> mParent;
     306    Console * const        mParent;
    307307    /** Pointer to the associated display driver. */
    308308    struct DRVMAINDISPLAY  *mpDrv;
  • trunk/src/VBox/Main/include/GuestImpl.h

    r27190 r27607  
    104104    ULONG mCurrentGuestStat[GuestStatisticType_MaxVal];
    105105
    106     ComObjPtr<Console, ComWeakRef> mParent;
     106    Console *mParent;
    107107    Data mData;
    108108};
  • trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h

    r23223 r27607  
    9595    HostNetworkInterfaceType_T mIfType;
    9696
    97     ComObjPtr<VirtualBox, ComWeakRef> mVBox;
     97    VirtualBox * const mVBox;
    9898
    9999    struct Data
  • trunk/src/VBox/Main/include/HostPower.h

    r26044 r27607  
    5151protected:
    5252
    53     ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     53    VirtualBox              *mVirtualBox;
    5454
    55     std::vector <ComPtr<IConsole> > mConsoles;
     55    std::vector< ComPtr<IConsole> > mConsoles;
    5656};
    5757
  • trunk/src/VBox/Main/include/KeyboardImpl.h

    r26173 r27607  
    9696    static DECLCALLBACK(void)   drvDestruct(PPDMDRVINS pDrvIns);
    9797
    98     const ComObjPtr<Console, ComWeakRef> mParent;
     98    Console * const        mParent;
    9999    /** Pointer to the associated keyboard driver. */
    100100    struct DRVMAINKEYBOARD *mpDrv;
  • trunk/src/VBox/Main/include/MachineDebuggerImpl.h

    r23223 r27607  
    9696    bool queueSettings() const;
    9797
    98     const ComObjPtr<Console, ComWeakRef> mParent;
     98    Console * const mParent;
    9999    // flags whether settings have been queued because
    100100    // they could not be sent to the VM (not up yet, etc.)
  • trunk/src/VBox/Main/include/MachineImpl.h

    r27537 r27607  
    542542     * one) or after doing addCaller() manually.
    543543     */
    544     const ComObjPtr<VirtualBox, ComWeakRef>& getVirtualBox() const { return mParent; }
     544    VirtualBox* getVirtualBox() const { return mParent; }
    545545
    546546    /**
     
    685685    HRESULT checkStateDependency(StateDependency aDepType);
    686686
    687     inline Machine *getMachine();
     687    Machine *getMachine();
    688688
    689689    void ensureNoStateDependencies();
     
    776776#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    777777
    778     const ComObjPtr<Machine, ComWeakRef> mPeer;
    779 
    780     const ComObjPtr<VirtualBox, ComWeakRef> mParent;
     778    Machine* const          mPeer;
     779
     780    VirtualBox* const      mParent;
    781781
    782782    uint32_t                m_flModifications;
     
    10721072}
    10731073
    1074 ////////////////////////////////////////////////////////////////////////////////
    1075 
    1076 /**
    1077  *  Returns a pointer to the Machine object for this machine that acts like a
    1078  *  parent for complex machine data objects such as shared folders, etc.
    1079  *
    1080  *  For primary Machine objects and for SnapshotMachine objects, returns this
    1081  *  object's pointer itself. For SessoinMachine objects, returns the peer
    1082  *  (primary) machine pointer.
    1083  */
    1084 inline Machine *Machine::getMachine()
    1085 {
    1086     if (getClassID() == clsidSessionMachine)
    1087         return mPeer;
    1088     return this;
    1089 }
    1090 
    10911074
    10921075#endif // ____H_MACHINEIMPL
  • trunk/src/VBox/Main/include/MouseImpl.h

    r27159 r27607  
    138138    Console *mParent;
    139139#else
    140     const ComObjPtr<Console, ComWeakRef> mParent;
     140    Console * const        mParent;
    141141#endif
    142142    /** Pointer to the associated mouse driver. */
  • trunk/src/VBox/Main/include/NetworkAdapterImpl.h

    r26171 r27607  
    138138    void generateMACAddress();
    139139
    140     const ComObjPtr<Machine, ComWeakRef> mParent;
     140    Machine * const    mParent;
    141141    const ComObjPtr<NetworkAdapter> mPeer;
    142142
    143     bool m_fModified;
    144     Backupable<Data> mData;
     143    bool                m_fModified;
     144    Backupable<Data>    mData;
    145145};
    146146
  • trunk/src/VBox/Main/include/ProgressImpl.h

    r26603 r27607  
    9999#if !defined (VBOX_COM_INPROC)
    100100    /** Weak parent. */
    101     const ComObjPtr<VirtualBox, ComWeakRef> mParent;
    102 #endif
    103 
    104     const ComPtr<IUnknown> mInitiator;
     101    VirtualBox * const      mParent;
     102#endif
     103
     104    const ComPtr<IUnknown>  mInitiator;
    105105
    106106    const Guid mId;
  • trunk/src/VBox/Main/include/SharedFolderImpl.h

    r26044 r27607  
    9797private:
    9898
    99     VirtualBoxBase *const mParent;
     99    VirtualBoxBase * const mParent;
    100100
    101101    /* weak parents (only one of them is not null) */
    102     const ComObjPtr<Machine, ComWeakRef> mMachine;
    103     const ComObjPtr<Console, ComWeakRef> mConsole;
    104     const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     102    Machine * const        mMachine;
     103    Console * const        mConsole;
     104    VirtualBox * const      mVirtualBox;
    105105
    106106    Data m;
  • trunk/src/VBox/Main/include/StorageControllerImpl.h

    r26171 r27607  
    9898
    9999    /** @note this doesn't require a read lock since mParent is constant. */
    100     const ComObjPtr<Machine, ComWeakRef>& getMachine();
     100    Machine* getMachine();
    101101
    102102    ComObjPtr<StorageController> getPeer();
  • trunk/src/VBox/Main/include/SystemPropertiesImpl.h

    r26044 r27607  
    124124    HRESULT setWebServiceAuthLibrary(const Utf8Str &aPath);
    125125
    126     const ComObjPtr<VirtualBox, ComWeakRef> mParent;
     126    VirtualBox * const mParent;
    127127
    128     Utf8Str m_strDefaultMachineFolder;
    129     Utf8Str m_strDefaultMachineFolderFull;
    130     Utf8Str m_strDefaultHardDiskFolder;
    131     Utf8Str m_strDefaultHardDiskFolderFull;
    132     Utf8Str m_strDefaultHardDiskFormat;
     128    Utf8Str             m_strDefaultMachineFolder;
     129    Utf8Str             m_strDefaultMachineFolderFull;
     130    Utf8Str             m_strDefaultHardDiskFolder;
     131    Utf8Str             m_strDefaultHardDiskFolderFull;
     132    Utf8Str             m_strDefaultHardDiskFormat;
    133133
    134     MediumFormatList mMediumFormats;
     134    MediumFormatList    mMediumFormats;
    135135
    136     Utf8Str m_strRemoteDisplayAuthLibrary;
    137     Utf8Str m_strWebServiceAuthLibrary;
    138     ULONG mLogHistoryCount;
    139     AudioDriverType_T mDefaultAudioDriver;
     136    Utf8Str             m_strRemoteDisplayAuthLibrary;
     137    Utf8Str             m_strWebServiceAuthLibrary;
     138    ULONG               mLogHistoryCount;
     139    AudioDriverType_T   mDefaultAudioDriver;
    140140
    141141    friend class VirtualBox;
  • trunk/src/VBox/Main/include/VFSExplorerImpl.h

    r26044 r27607  
    7575private:
    7676    /* Private member vars */
    77     const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
     77    VirtualBox * const mVirtualBox;
    7878
    7979    struct TaskVFSExplorer;  /* Worker thread helper */
  • trunk/src/VBox/Main/include/VMMDev.h

    r26173 r27607  
    6464    static DECLCALLBACK(void)   drvReset(PPDMDRVINS pDrvIns);
    6565
    66     ComObjPtr<Console, ComWeakRef> mParent;
     66    Console * const        mParent;
    6767
    6868    RTSEMEVENT mCredentialsEvent;
  • trunk/src/VBox/Main/include/VRDPServerImpl.h

    r26171 r27607  
    108108private:
    109109
    110     const ComObjPtr<Machine, ComWeakRef> mParent;
     110    Machine * const    mParent;
    111111    const ComObjPtr<VRDPServer> mPeer;
    112112
    113     Backupable<Data> mData;
     113    Backupable<Data>    mData;
    114114};
    115115
  • trunk/src/VBox/Main/include/objectslist.h

    r25894 r27607  
    5050{
    5151public:
    52     typedef ComObjPtr<T, ComStrongRef> MyType;
     52    typedef ComObjPtr<T> MyType;
    5353    typedef std::list<MyType> MyList;
    5454
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