Changeset 27607 in vbox
- Timestamp:
- Mar 22, 2010 6:13:07 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 59148
- Location:
- trunk
- Files:
-
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/com/ptr.h
r23223 r27607 73 73 void LogRef(const char *pcszFormat, ...); 74 74 } 75 76 /**77 * Strong referencing operators. Used as a second argument to ComPtr<>/ComObjPtr<>.78 */79 template <class C>80 class ComStrongRef81 {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 ComWeakRef99 {100 protected:101 102 static void addref(C * /* p */) {}103 static void release(C * /* p */) {}104 };105 75 106 76 /** … … 169 139 * Base template for smart COM pointers. Not intended to be used directly. 170 140 */ 171 template <class C , template <class> class RefOps = ComStrongRef>172 class ComPtrBase : protected RefOps <C>141 template <class C> 142 class ComPtrBase 173 143 { 174 144 public: … … 190 160 protected: 191 161 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); 207 192 return *this; 208 193 } … … 221 206 } 222 207 223 bool operator! 224 225 bool operator< 226 bool operator== 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; } 227 212 228 213 template <class I> 229 bool equalsTo 230 { 231 return ComPtrEquals 214 bool equalsTo(I *aThat) const 215 { 216 return ComPtrEquals(p, aThat); 232 217 } 233 218 234 219 template <class OC> 235 bool equalsTo 236 { 237 return equalsTo ((OC *)oc);220 bool equalsTo(const ComPtrBase <OC> &oc) const 221 { 222 return equalsTo((OC*)oc); 238 223 } 239 224 240 225 /** Intended to pass instances as in parameters to interface methods */ 241 operator C* 226 operator C*() const { return p; } 242 227 243 228 /** … … 245 230 * pointer). 246 231 */ 247 NoAddRefRelease <C> *operator->() const248 { 249 AssertMsg 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; 251 236 } 252 237 253 238 template <class I> 254 HRESULT queryInterfaceTo 239 HRESULT queryInterfaceTo(I **pp) const 255 240 { 256 241 if (pp) … … 258 243 if (p) 259 244 { 260 return p->QueryInterface (COM_IIDOF (I), (void **)pp);245 return p->QueryInterface(COM_IIDOF(I), (void**)pp); 261 246 } 262 247 else … … 282 267 { 283 268 if (p) 284 RefOps <C>::addref (p);269 p->AddRef(); 285 270 } 286 271 … … 288 273 { 289 274 if (p) 290 RefOps <C>::release (p);275 p->Release(); 291 276 } 292 277 … … 295 280 /* be aware of self-assignment */ 296 281 if (that_p) 297 RefOps <C>::addref (that_p);282 that_p->AddRef(); 298 283 release(); 299 284 p = that_p; … … 309 294 * @param I COM interface class 310 295 */ 311 template <class I , template <class> class RefOps = ComStrongRef>312 class ComPtr : public ComPtrBase <I, RefOps>313 { 314 typedef ComPtrBase <I, RefOps> Base;296 template <class I> 297 class ComPtr : public ComPtrBase<I> 298 { 299 typedef ComPtrBase<I> Base; 315 300 316 301 public: 317 302 318 ComPtr 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) 321 306 { 322 307 Base::operator= (that); … … 325 310 326 311 template <class OI> 327 ComPtr (OI *that_p) : Base () { operator=(that_p); }312 ComPtr(OI *that_p) : Base() { operator=(that_p); } 328 313 329 314 /* specialization for I */ 330 ComPtr (I *that_p) : Base(that_p) {}315 ComPtr(I *that_p) : Base(that_p) {} 331 316 332 317 template <class OC> 333 ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *)oc); }318 ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); } 334 319 335 320 template <class OI> 336 ComPtr &operator= 321 ComPtr &operator=(OI *that_p) 337 322 { 338 323 if (that_p) 339 that_p->QueryInterface (COM_IIDOF (I), (void **)Base::asOutParam());324 that_p->QueryInterface(COM_IIDOF(I), (void**)Base::asOutParam()); 340 325 else 341 326 Base::setNull(); … … 346 331 ComPtr &operator=(I *that_p) 347 332 { 348 Base::operator= 333 Base::operator=(that_p); 349 334 return *this; 350 335 } 351 336 352 337 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); 356 341 } 357 342 … … 365 350 I *obj = NULL; 366 351 #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); 369 354 #else /* !defined (VBOX_WITH_XPCOM) */ 370 nsCOMPtr 371 rc = NS_GetComponentManager (getter_AddRefs(manager));372 if (SUCCEEDED 373 rc = manager->CreateInstance (clsid, nsnull, NS_GET_IID(I),374 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); 375 360 #endif /* !defined (VBOX_WITH_XPCOM) */ 376 361 *this = obj; 377 if (SUCCEEDED 362 if (SUCCEEDED(rc)) 378 363 obj->Release(); 379 364 return rc; … … 389 374 * method is fully equivalent to #createInprocObject() for now. 390 375 */ 391 HRESULT createLocalObject 376 HRESULT createLocalObject(const CLSID &clsid) 392 377 { 393 378 #if !defined (VBOX_WITH_XPCOM) 394 379 HRESULT rc; 395 380 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); 398 383 *this = obj; 399 if (SUCCEEDED 384 if (SUCCEEDED(rc)) 400 385 obj->Release(); 401 386 return rc; 402 387 #else /* !defined (VBOX_WITH_XPCOM) */ 403 return createInprocObject 388 return createInprocObject(clsid); 404 389 #endif /* !defined (VBOX_WITH_XPCOM) */ 405 390 } … … 412 397 * @param serverName Name of the server to create an object within. 413 398 */ 414 HRESULT createObjectOnServer 399 HRESULT createObjectOnServer(const CLSID &clsid, const char *serverName) 415 400 { 416 401 HRESULT rc; 417 402 I *obj = NULL; 418 nsCOMPtr <ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc);419 if (SUCCEEDED 403 nsCOMPtr<ipcIService> ipcServ = do_GetService(IPC_SERVICE_CONTRACTID, &rc); 404 if (SUCCEEDED(rc)) 420 405 { 421 406 PRUint32 serverID = 0; 422 rc = ipcServ->ResolveClientName 407 rc = ipcServ->ResolveClientName(serverName, &serverID); 423 408 if (SUCCEEDED (rc)) 424 409 { 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); 430 414 } 431 415 } 432 416 *this = obj; 433 if (SUCCEEDED 417 if (SUCCEEDED(rc)) 434 418 obj->Release(); 435 419 return rc; … … 443 427 * another interface pointer disregarding its type. 444 428 */ 445 template <template <class> class RefOps>446 class ComPtr <IUnknown, RefOps> : public ComPtrBase <IUnknown, RefOps>447 { 448 typedef ComPtrBase <IUnknown, RefOps> Base;429 template<> 430 class ComPtr<IUnknown> : public ComPtrBase<IUnknown> 431 { 432 typedef ComPtrBase<IUnknown> Base; 449 433 450 434 public: 451 435 452 ComPtr 453 ComPtr 454 ComPtr &operator=(const ComPtr &that)455 { 456 Base::operator= 436 ComPtr() : Base() {} 437 ComPtr(const ComPtr &that) : Base (that) {} 438 ComPtr& operator=(const ComPtr &that) 439 { 440 Base::operator=(that); 457 441 return *this; 458 442 } 459 443 460 444 template <class OI> 461 ComPtr (OI *that_p) : Base () { operator=(that_p); }445 ComPtr(OI *that_p) : Base() { operator=(that_p); } 462 446 463 447 template <class OC> 464 ComPtr (const ComPtr <OC, RefOps> &oc) : Base () { operator= ((OC *)oc); }448 ComPtr(const ComPtr<OC> &oc) : Base() { operator=((OC*)oc); } 465 449 466 450 template <class OI> 467 ComPtr &operator= 451 ComPtr &operator=(OI *that_p) 468 452 { 469 453 if (that_p) 470 that_p->QueryInterface (COM_IIDOF (IUnknown), (void **)Base::asOutParam());454 that_p->QueryInterface(COM_IIDOF(IUnknown), (void**)Base::asOutParam()); 471 455 else 472 456 Base::setNull(); … … 475 459 476 460 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); 480 464 } 481 465 }; … … 489 473 * @param C class that implements some COM interface 490 474 */ 491 template <class C , template <class> class RefOps = ComStrongRef>492 class ComObjPtr : public ComPtrBase <C, RefOps>493 { 494 typedef ComPtrBase <C, RefOps> Base;475 template <class C> 476 class ComObjPtr : public ComPtrBase<C> 477 { 478 typedef ComPtrBase<C> Base; 495 479 496 480 public: 497 481 498 ComObjPtr 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= 505 return *this; 506 } 507 508 ComObjPtr &operator=(C *that_p)509 { 510 Base::operator= 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); 511 495 return *this; 512 496 } … … 530 514 #if !defined (VBOX_WITH_XPCOM) 531 515 # ifdef VBOX_COM_OUTOFPROC_MODULE 532 CComObjectNoLock <C> *obj = new CComObjectNoLock<C>();516 CComObjectNoLock<C> *obj = new CComObjectNoLock<C>(); 533 517 if (obj) 534 518 { … … 540 524 rc = E_OUTOFMEMORY; 541 525 # else 542 CComObject 543 rc = CComObject <C>::CreateInstance(&obj);526 CComObject<C> *obj = NULL; 527 rc = CComObject<C>::CreateInstance(&obj); 544 528 # endif 545 529 #else /* !defined (VBOX_WITH_XPCOM) */ 546 CComObject <C> *obj = new CComObject<C>();530 CComObject<C> *obj = new CComObject<C>(); 547 531 if (obj) 548 532 rc = obj->FinalConstruct(); -
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r27251 r27607 79 79 80 80 /* global weak references (for event handlers) */ 81 static ComPtr <ISession, ComWeakRef> gSession;82 static ComPtr <IConsole, ComWeakRef> gConsole;81 static ISession *gSession = NULL; 82 static IConsole *gConsole = NULL; 83 83 static EventQueue *gEventQ = NULL; 84 84 -
trunk/src/VBox/Main/ApplianceImpl.cpp
r26753 r27607 318 318 //////////////////////////////////////////////////////////////////////////////// 319 319 320 DEFINE_EMPTY_CTOR_DTOR(Appliance) 320 Appliance::Appliance() 321 : mVirtualBox(NULL) 322 { 323 } 324 325 Appliance::~Appliance() 326 { 327 } 321 328 322 329 /** -
trunk/src/VBox/Main/AudioAdapterImpl.cpp
r26235 r27607 34 34 ///////////////////////////////////////////////////////////////////////////// 35 35 36 DEFINE_EMPTY_CTOR_DTOR (AudioAdapter) 36 AudioAdapter::AudioAdapter() 37 : mParent(NULL) 38 { 39 } 40 41 AudioAdapter::~AudioAdapter() 42 { 43 } 37 44 38 45 HRESULT AudioAdapter::FinalConstruct() … … 43 50 void AudioAdapter::FinalRelease() 44 51 { 45 uninit 52 uninit(); 46 53 } 47 54 … … 169 176 mData.free(); 170 177 171 unconst(mPeer) .setNull();172 unconst(mParent) .setNull();178 unconst(mPeer) = NULL; 179 unconst(mParent) = NULL; 173 180 } 174 181 -
trunk/src/VBox/Main/AudioSnifferInterface.cpp
r26173 r27607 68 68 // constructor / destructor 69 69 // 70 AudioSniffer::AudioSniffer(Console *console) : mpDrv(NULL) 71 { 72 mParent = console; 70 AudioSniffer::AudioSniffer(Console *console) 71 : mpDrv(NULL), 72 mParent(console) 73 { 73 74 } 74 75 -
trunk/src/VBox/Main/BIOSSettingsImpl.cpp
r27059 r27607 40 40 { 41 41 Data() 42 : pMachine(NULL) 42 43 { } 43 44 44 ComObjPtr<Machine, ComWeakRef>pMachine;45 ComObjPtr<BIOSSettings> 45 Machine * const pMachine; 46 ComObjPtr<BIOSSettings> pPeer; 46 47 47 48 // use the XML settings structure in the members for simplicity … … 115 116 m = new Data(); 116 117 117 m->pMachine= aParent;118 unconst(m->pMachine) = aParent; 118 119 m->pPeer = that; 119 120 … … 145 146 m = new Data(); 146 147 147 m->pMachine= aParent;148 unconst(m->pMachine) = aParent; 148 149 // mPeer is left null 149 150 … … 172 173 m->bd.free(); 173 174 174 m->pPeer.setNull();175 m->pMachine.setNull();175 unconst(m->pPeer) = NULL; 176 unconst(m->pMachine) = NULL; 176 177 177 178 delete m; -
trunk/src/VBox/Main/ConsoleVRDPServer.cpp
r26782 r27607 2170 2170 return; 2171 2171 2172 unconst(mParent) .setNull();2172 unconst(mParent) = NULL; 2173 2173 } 2174 2174 -
trunk/src/VBox/Main/DHCPServerImpl.cpp
r26163 r27607 34 34 ///////////////////////////////////////////////////////////////////////////// 35 35 36 DEFINE_EMPTY_CTOR_DTOR (DHCPServer) 36 DHCPServer::DHCPServer() 37 : mVirtualBox(NULL) 38 { 39 } 40 41 DHCPServer::~DHCPServer() 42 { 43 } 37 44 38 45 HRESULT DHCPServer::FinalConstruct() … … 53 60 return; 54 61 55 unconst(mVirtualBox) .setNull();62 unconst(mVirtualBox) = NULL; 56 63 } 57 64 -
trunk/src/VBox/Main/DisplayImpl.cpp
r27560 r27607 76 76 ///////////////////////////////////////////////////////////////////////////// 77 77 78 DEFINE_EMPTY_CTOR_DTOR(Display) 78 Display::Display() 79 : mParent(NULL) 80 { 81 } 82 83 Display::~Display() 84 { 85 } 86 79 87 80 88 HRESULT Display::FinalConstruct() … … 663 671 mParent->UnregisterCallback (this); 664 672 665 unconst(mParent) .setNull();673 unconst(mParent) = NULL; 666 674 667 675 if (mpDrv) -
trunk/src/VBox/Main/GuestImpl.cpp
r27190 r27607 111 111 return; 112 112 113 unconst(mParent) .setNull();113 unconst(mParent) = NULL; 114 114 } 115 115 -
trunk/src/VBox/Main/HostImpl.cpp
r27537 r27607 157 157 {}; 158 158 159 ComObjPtr<VirtualBox, ComWeakRef> 160 pParent; 159 VirtualBox *pParent; 161 160 162 161 #ifdef VBOX_WITH_USB -
trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
r26753 r27607 34 34 ///////////////////////////////////////////////////////////////////////////// 35 35 36 DEFINE_EMPTY_CTOR_DTOR (HostNetworkInterface) 36 HostNetworkInterface::HostNetworkInterface() 37 : mVBox(NULL) 38 { 39 } 40 41 HostNetworkInterface::~HostNetworkInterface() 42 { 43 } 37 44 38 45 HRESULT HostNetworkInterface::FinalConstruct() … … 550 557 AutoCaller autoCaller(this); 551 558 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 552 mVBox= pVBox;559 unconst(mVBox) = pVBox; 553 560 554 561 /* If IPv4 address hasn't been initialized */ -
trunk/src/VBox/Main/KeyboardImpl.cpp
r26235 r27607 120 120 mfVMMDevInited = true; 121 121 122 unconst(mParent) .setNull();122 unconst(mParent) = NULL; 123 123 } 124 124 -
trunk/src/VBox/Main/MachineDebuggerImpl.cpp
r26235 r27607 49 49 ///////////////////////////////////////////////////////////////////////////// 50 50 51 DEFINE_EMPTY_CTOR_DTOR (MachineDebugger) 51 MachineDebugger::MachineDebugger() 52 : mParent(NULL) 53 { 54 } 55 56 MachineDebugger::~MachineDebugger() 57 { 58 } 52 59 53 60 HRESULT MachineDebugger::FinalConstruct() … … 111 118 return; 112 119 113 unconst(mParent) .setNull();120 unconst(mParent) = NULL; 114 121 mFlushMode = false; 115 122 } -
trunk/src/VBox/Main/MachineImpl.cpp
r27537 r27607 238 238 239 239 Machine::Machine() 240 : mPeer(NULL), mParent(NULL) 240 241 {} 241 242 … … 607 608 608 609 /* mParent is constant during life time, no need to lock */ 609 mParent.queryInterfaceTo(aParent); 610 ComObjPtr<VirtualBox> pVirtualBox(mParent); 611 pVirtualBox.queryInterfaceTo(aParent); 610 612 611 613 return S_OK; … … 6050 6052 6051 6053 /** 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 */ 6061 Machine* Machine::getMachine() 6062 { 6063 if (getClassID() == clsidSessionMachine) 6064 return (Machine*)mPeer; 6065 return this; 6066 } 6067 6068 /** 6052 6069 * Makes sure that there are no machine state dependants. If necessary, waits 6053 6070 * for the number of dependants to drop to zero. … … 9084 9101 uninitDataAndChildObjects(); 9085 9102 mData.free(); 9086 unconst(mParent) .setNull();9087 unconst(mPeer) .setNull();9103 unconst(mParent) = NULL; 9104 unconst(mPeer) = NULL; 9088 9105 LogFlowThisFuncLeave(); 9089 9106 return; … … 9279 9296 alock.leave(); 9280 9297 9281 unconst(mParent) .setNull();9282 unconst(mPeer) .setNull();9298 unconst(mParent) = NULL; 9299 unconst(mPeer) = NULL; 9283 9300 9284 9301 LogFlowThisFuncLeave(); … … 9294 9311 RWLockHandle *SessionMachine::lockHandle() const 9295 9312 { 9296 AssertReturn( !mPeer.isNull(), NULL);9313 AssertReturn(mPeer != NULL, NULL); 9297 9314 return mPeer->lockHandle(); 9298 9315 } … … 9588 9605 ComObjPtr<Progress> progress; 9589 9606 progress.createObject(); 9590 progress->init(mParent, static_cast<IMachine *>(mPeer),9607 progress->init(mParent, mPeer, 9591 9608 Bstr(tr("Closing session")), FALSE /* aCancelable */); 9592 9609 progress.queryInterfaceTo(aProgress); -
trunk/src/VBox/Main/MediumAttachmentImpl.cpp
r26562 r27607 61 61 { 62 62 Data() 63 : pMachine(NULL) 63 64 { } 64 65 65 66 /** Reference to Machine object, for checking mutable state. */ 66 const ComObjPtr<Machine, ComWeakRef>pMachine;67 Machine * const pMachine; 67 68 /* later: const ComObjPtr<MediumAttachment> mPeer; */ 68 69 … … 164 165 m->bd.free(); 165 166 166 unconst(m->pMachine) .setNull();167 unconst(m->pMachine) = NULL; 167 168 168 169 delete m; -
trunk/src/VBox/Main/MediumImpl.cpp
r27592 r27607 88 88 { 89 89 Data() 90 : state(MediumState_NotCreated), 90 : pVirtualBox(NULL), 91 state(MediumState_NotCreated), 91 92 size(0), 92 93 readers(0), … … 108 109 109 110 /** weak VirtualBox parent */ 110 const ComObjPtr<VirtualBox, ComWeakRef>pVirtualBox;111 VirtualBox * const pVirtualBox; 111 112 112 113 const Guid id; … … 1371 1372 m->queryInfoSem = NIL_RTSEMEVENTMULTI; 1372 1373 1373 unconst(m->pVirtualBox) .setNull();1374 unconst(m->pVirtualBox) = NULL; 1374 1375 } 1375 1376 -
trunk/src/VBox/Main/MouseImpl.cpp
r27403 r27607 63 63 ///////////////////////////////////////////////////////////////////////////// 64 64 65 DEFINE_EMPTY_CTOR_DTOR (Mouse) 65 Mouse::Mouse() 66 : mParent(NULL) 67 { 68 } 69 70 Mouse::~Mouse() 71 { 72 } 73 66 74 67 75 HRESULT Mouse::FinalConstruct() … … 138 146 mParent = NULL; 139 147 #else 140 unconst(mParent) .setNull();148 unconst(mParent) = NULL; 141 149 #endif 142 150 } -
trunk/src/VBox/Main/NetworkAdapterImpl.cpp
r26818 r27607 37 37 //////////////////////////////////////////////////////////////////////////////// 38 38 39 DEFINE_EMPTY_CTOR_DTOR (NetworkAdapter) 39 NetworkAdapter::NetworkAdapter() 40 : mParent(NULL) 41 { 42 } 43 44 NetworkAdapter::~NetworkAdapter() 45 { 46 } 40 47 41 48 HRESULT NetworkAdapter::FinalConstruct() … … 174 181 mData.free(); 175 182 176 unconst(mPeer) .setNull();177 unconst(mParent) .setNull();183 unconst(mPeer) = NULL; 184 unconst(mParent) = NULL; 178 185 } 179 186 -
trunk/src/VBox/Main/ParallelPortImpl.cpp
r26235 r27607 42 42 { 43 43 Data() 44 : fModified(false) 44 : fModified(false), 45 pMachine(NULL) 45 46 { } 46 47 47 48 bool fModified; 48 49 49 const ComObjPtr<Machine, ComWeakRef>pMachine;50 Machine * const pMachine; 50 51 const ComObjPtr<ParallelPort> pPeer; 51 52 … … 186 187 m->bd.free(); 187 188 188 unconst(m->pPeer) .setNull();189 unconst(m->pMachine) .setNull();189 unconst(m->pPeer) = NULL; 190 unconst(m->pMachine) = NULL; 190 191 191 192 delete m; -
trunk/src/VBox/Main/ProgressImpl.cpp
r26603 r27607 48 48 //////////////////////////////////////////////////////////////////////////////// 49 49 50 DEFINE_EMPTY_CTOR_DTOR (ProgressBase) 50 ProgressBase::ProgressBase() 51 #if !defined (VBOX_COM_INPROC) 52 : mParent(NULL) 53 #endif 54 { 55 } 56 57 ProgressBase::~ProgressBase() 58 { 59 } 60 51 61 52 62 /** … … 92 102 * NULL which means initiator = parent, otherwise must not 93 103 * be NULL). 94 * @param aDescription Task description.104 * @param aDescription ask description. 95 105 * @param aID Address of result GUID structure (optional). 96 106 * … … 127 137 * (to avoid cycling); otherwise mInitiator will remain null which means 128 138 * 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 } 131 145 #else 132 146 unconst(mInitiator) = aInitiator; … … 191 205 mParent->removeProgress (mId); 192 206 193 unconst(mParent) .setNull();207 unconst(mParent) = NULL; 194 208 } 195 209 #endif … … 238 252 mInitiator.queryInterfaceTo(aInitiator); 239 253 else 240 mParent.queryInterfaceTo(aInitiator); 254 { 255 ComObjPtr<VirtualBox> pVirtualBox(mParent); 256 pVirtualBox.queryInterfaceTo(aInitiator); 257 } 241 258 #else 242 259 mInitiator.queryInterfaceTo(aInitiator); -
trunk/src/VBox/Main/SerialPortImpl.cpp
r27059 r27607 43 43 { 44 44 Data() 45 : fModified(false) 45 : fModified(false), 46 pMachine(NULL) 46 47 { } 47 48 48 bool 49 50 const ComObjPtr<Machine, ComWeakRef>pMachine;51 const ComObjPtr<SerialPort> 52 53 Backupable<settings::SerialPort> 49 bool fModified; 50 51 Machine * const pMachine; 52 const ComObjPtr<SerialPort> pPeer; 53 54 Backupable<settings::SerialPort> bd; 54 55 }; 55 56 … … 189 190 m->bd.free(); 190 191 191 unconst(m->pPeer) .setNull();192 unconst(m->pMachine) .setNull();192 unconst(m->pPeer) = NULL; 193 unconst(m->pMachine) = NULL; 193 194 194 195 delete m; -
trunk/src/VBox/Main/SharedFolderImpl.cpp
r26753 r27607 36 36 37 37 SharedFolder::SharedFolder() 38 : mParent (NULL) 38 : mParent(NULL), 39 mMachine(NULL), 40 mConsole(NULL), 41 mVirtualBox(NULL) 39 42 { 40 43 } … … 248 251 unconst(mParent) = NULL; 249 252 250 unconst(mMachine) .setNull();251 unconst(mConsole) .setNull();252 unconst(mVirtualBox) .setNull();253 unconst(mMachine) = NULL; 254 unconst(mConsole) = NULL; 255 unconst(mVirtualBox) = NULL; 253 256 } 254 257 -
trunk/src/VBox/Main/SnapshotImpl.cpp
r27278 r27607 77 77 { 78 78 Data() 79 : pVirtualBox(NULL) 79 80 { 80 81 RTTimeSpecSetMilli(&timeStamp, 0); … … 91 92 92 93 /** weak VirtualBox parent */ 93 const ComObjPtr<VirtualBox, ComWeakRef>pVirtualBox;94 VirtualBox * const pVirtualBox; 94 95 95 96 // pParent and llChildren are protected by Machine::snapshotsTreeLockHandle() … … 1049 1050 mData.free(); 1050 1051 1051 unconst(mParent) .setNull();1052 unconst(mPeer) .setNull();1052 unconst(mParent) = NULL; 1053 unconst(mPeer) = NULL; 1053 1054 1054 1055 LogFlowThisFuncLeave(); … … 1061 1062 RWLockHandle *SnapshotMachine::lockHandle() const 1062 1063 { 1063 AssertReturn( !mPeer.isNull(), NULL);1064 AssertReturn(mPeer != NULL, NULL); 1064 1065 return mPeer->lockHandle(); 1065 1066 } -
trunk/src/VBox/Main/StorageControllerImpl.cpp
r26235 r27607 80 80 { 81 81 Data() 82 : pParent(NULL) 82 83 { } 83 84 84 const ComObjPtr<Machine, ComWeakRef>pParent;85 const ComObjPtr<StorageController> 85 Machine * const pParent; 86 const ComObjPtr<StorageController> pPeer; 86 87 87 88 Backupable<BackupableStorageControllerData> bd; … … 290 291 m->pParent->removeDependentChild(this); 291 292 292 unconst(m->pPeer) .setNull();293 unconst(m->pParent) .setNull();293 unconst(m->pPeer) = NULL; 294 unconst(m->pParent) = NULL; 294 295 295 296 delete m; … … 775 776 } 776 777 777 unconst(m->pPeer) .setNull();778 } 779 780 const ComObjPtr<Machine, ComWeakRef>&StorageController::getMachine()778 unconst(m->pPeer) = NULL; 779 } 780 781 Machine* StorageController::getMachine() 781 782 { 782 783 return m->pParent; -
trunk/src/VBox/Main/SystemPropertiesImpl.cpp
r26753 r27607 47 47 ///////////////////////////////////////////////////////////////////////////// 48 48 49 DEFINE_EMPTY_CTOR_DTOR (SystemProperties) 49 SystemProperties::SystemProperties() 50 : mParent(NULL) 51 { 52 } 53 54 SystemProperties::~SystemProperties() 55 { 56 } 57 50 58 51 59 HRESULT SystemProperties::FinalConstruct() … … 170 178 return; 171 179 172 unconst(mParent) .setNull();180 unconst(mParent) = NULL; 173 181 } 174 182 -
trunk/src/VBox/Main/USBControllerImpl.cpp
r26968 r27607 62 62 struct USBController::Data 63 63 { 64 Data() {}; 65 ~Data() {}; 64 Data() 65 : pParent(NULL) 66 {}; 67 68 ~Data() 69 {}; 66 70 67 71 /** Parent object. */ 68 const ComObjPtr<Machine, ComWeakRef>pParent;72 Machine * const pParent; 69 73 /** Peer object. */ 70 const ComObjPtr<USBController> pPeer;71 72 Backupable<BackupableUSBData> bd;74 const ComObjPtr<USBController> pPeer; 75 76 Backupable<BackupableUSBData> bd; 73 77 #ifdef VBOX_WITH_USB 74 78 // the following fields need special backup/rollback/commit handling, … … 250 254 m->bd.free(); 251 255 252 unconst(m->pPeer) .setNull();253 unconst(m->pParent) .setNull();256 unconst(m->pPeer) = NULL; 257 unconst(m->pParent) = NULL; 254 258 255 259 delete m; -
trunk/src/VBox/Main/VFSExplorerImpl.cpp
r26753 r27607 67 67 }; 68 68 69 DEFINE_EMPTY_CTOR_DTOR(VFSExplorer) 69 VFSExplorer::VFSExplorer() 70 : mVirtualBox(NULL) 71 { 72 } 73 74 VFSExplorer::~VFSExplorer() 75 { 76 } 77 70 78 71 79 /** -
trunk/src/VBox/Main/VMMDevInterface.cpp
r26782 r27607 89 89 // constructor / destructor 90 90 // 91 VMMDev::VMMDev(Console *console) : mpDrv(NULL) 92 { 93 mParent = console; 91 VMMDev::VMMDev(Console *console) 92 : mpDrv(NULL), 93 mParent(console) 94 { 94 95 int rc = RTSemEventCreate(&mCredentialsEvent); 95 96 AssertRC(rc); -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r27257 r27607 136 136 * is bound to the lifetime of the VirtualBox instance, so it's safe. 137 137 */ 138 ComObjPtr<VirtualBox, ComWeakRef>mVirtualBox;138 VirtualBox *mVirtualBox; 139 139 }; 140 140 … … 4345 4345 void *VirtualBox::CallbackEvent::handler() 4346 4346 { 4347 if ( mVirtualBox.isNull())4347 if (!mVirtualBox) 4348 4348 return NULL; 4349 4349 … … 4355 4355 autoCaller.state())); 4356 4356 /* We don't need mVirtualBox any more, so release it */ 4357 mVirtualBox .setNull();4357 mVirtualBox = NULL; 4358 4358 return NULL; 4359 4359 } … … 4365 4365 callbacks = mVirtualBox->m->llCallbacks; 4366 4366 /* We don't need mVirtualBox any more, so release it */ 4367 mVirtualBox .setNull();4367 mVirtualBox = NULL; 4368 4368 } 4369 4369 -
trunk/src/VBox/Main/include/ApplianceImpl.h
r26603 r27607 85 85 private: 86 86 /** weak VirtualBox parent */ 87 const ComObjPtr<VirtualBox, ComWeakRef>mVirtualBox;87 VirtualBox* const mVirtualBox; 88 88 89 89 struct Data; // opaque, defined in ApplianceImpl.cpp -
trunk/src/VBox/Main/include/AudioAdapterImpl.h
r26171 r27607 93 93 private: 94 94 95 const ComObjPtr<Machine, ComWeakRef>mParent;95 Machine * const mParent; 96 96 const ComObjPtr<AudioAdapter> mPeer; 97 97 98 Backupable<Data> mData;98 Backupable<Data> mData; 99 99 }; 100 100 -
trunk/src/VBox/Main/include/AudioSnifferInterface.h
r26173 r27607 47 47 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); 48 48 49 Co mObjPtr<Console, ComWeakRef>mParent;49 Console * const mParent; 50 50 }; 51 51 -
trunk/src/VBox/Main/include/ConsoleVRDPServer.h
r25728 r27607 287 287 private: 288 288 289 const ComObjPtr<Console, ComWeakRef>mParent;289 Console * const mParent; 290 290 }; 291 291 -
trunk/src/VBox/Main/include/DHCPServerImpl.h
r26163 r27607 88 88 private: 89 89 /** weak VirtualBox parent */ 90 const ComObjPtr<VirtualBox, ComWeakRef>mVirtualBox;90 VirtualBox * const mVirtualBox; 91 91 92 92 const Bstr mName; -
trunk/src/VBox/Main/include/DisplayImpl.h
r26782 r27607 304 304 static DECLCALLBACK(int) displaySSMLoad(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass); 305 305 306 const ComObjPtr<Console, ComWeakRef>mParent;306 Console * const mParent; 307 307 /** Pointer to the associated display driver. */ 308 308 struct DRVMAINDISPLAY *mpDrv; -
trunk/src/VBox/Main/include/GuestImpl.h
r27190 r27607 104 104 ULONG mCurrentGuestStat[GuestStatisticType_MaxVal]; 105 105 106 Co mObjPtr<Console, ComWeakRef>mParent;106 Console *mParent; 107 107 Data mData; 108 108 }; -
trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
r23223 r27607 95 95 HostNetworkInterfaceType_T mIfType; 96 96 97 ComObjPtr<VirtualBox, ComWeakRef>mVBox;97 VirtualBox * const mVBox; 98 98 99 99 struct Data -
trunk/src/VBox/Main/include/HostPower.h
r26044 r27607 51 51 protected: 52 52 53 ComObjPtr<VirtualBox, ComWeakRef>mVirtualBox;53 VirtualBox *mVirtualBox; 54 54 55 std::vector <ComPtr<IConsole> > mConsoles;55 std::vector< ComPtr<IConsole> > mConsoles; 56 56 }; 57 57 -
trunk/src/VBox/Main/include/KeyboardImpl.h
r26173 r27607 96 96 static DECLCALLBACK(void) drvDestruct(PPDMDRVINS pDrvIns); 97 97 98 const ComObjPtr<Console, ComWeakRef>mParent;98 Console * const mParent; 99 99 /** Pointer to the associated keyboard driver. */ 100 100 struct DRVMAINKEYBOARD *mpDrv; -
trunk/src/VBox/Main/include/MachineDebuggerImpl.h
r23223 r27607 96 96 bool queueSettings() const; 97 97 98 const ComObjPtr<Console, ComWeakRef>mParent;98 Console * const mParent; 99 99 // flags whether settings have been queued because 100 100 // they could not be sent to the VM (not up yet, etc.) -
trunk/src/VBox/Main/include/MachineImpl.h
r27537 r27607 542 542 * one) or after doing addCaller() manually. 543 543 */ 544 const ComObjPtr<VirtualBox, ComWeakRef>&getVirtualBox() const { return mParent; }544 VirtualBox* getVirtualBox() const { return mParent; } 545 545 546 546 /** … … 685 685 HRESULT checkStateDependency(StateDependency aDepType); 686 686 687 inlineMachine *getMachine();687 Machine *getMachine(); 688 688 689 689 void ensureNoStateDependencies(); … … 776 776 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 777 777 778 const ComObjPtr<Machine, ComWeakRef>mPeer;779 780 const ComObjPtr<VirtualBox, ComWeakRef>mParent;778 Machine* const mPeer; 779 780 VirtualBox* const mParent; 781 781 782 782 uint32_t m_flModifications; … … 1072 1072 } 1073 1073 1074 ////////////////////////////////////////////////////////////////////////////////1075 1076 /**1077 * Returns a pointer to the Machine object for this machine that acts like a1078 * parent for complex machine data objects such as shared folders, etc.1079 *1080 * For primary Machine objects and for SnapshotMachine objects, returns this1081 * object's pointer itself. For SessoinMachine objects, returns the peer1082 * (primary) machine pointer.1083 */1084 inline Machine *Machine::getMachine()1085 {1086 if (getClassID() == clsidSessionMachine)1087 return mPeer;1088 return this;1089 }1090 1091 1074 1092 1075 #endif // ____H_MACHINEIMPL -
trunk/src/VBox/Main/include/MouseImpl.h
r27159 r27607 138 138 Console *mParent; 139 139 #else 140 const ComObjPtr<Console, ComWeakRef>mParent;140 Console * const mParent; 141 141 #endif 142 142 /** Pointer to the associated mouse driver. */ -
trunk/src/VBox/Main/include/NetworkAdapterImpl.h
r26171 r27607 138 138 void generateMACAddress(); 139 139 140 const ComObjPtr<Machine, ComWeakRef>mParent;140 Machine * const mParent; 141 141 const ComObjPtr<NetworkAdapter> mPeer; 142 142 143 bool m_fModified;144 Backupable<Data> mData;143 bool m_fModified; 144 Backupable<Data> mData; 145 145 }; 146 146 -
trunk/src/VBox/Main/include/ProgressImpl.h
r26603 r27607 99 99 #if !defined (VBOX_COM_INPROC) 100 100 /** 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; 105 105 106 106 const Guid mId; -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r26044 r27607 97 97 private: 98 98 99 VirtualBoxBase * constmParent;99 VirtualBoxBase * const mParent; 100 100 101 101 /* 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; 105 105 106 106 Data m; -
trunk/src/VBox/Main/include/StorageControllerImpl.h
r26171 r27607 98 98 99 99 /** @note this doesn't require a read lock since mParent is constant. */ 100 const ComObjPtr<Machine, ComWeakRef>&getMachine();100 Machine* getMachine(); 101 101 102 102 ComObjPtr<StorageController> getPeer(); -
trunk/src/VBox/Main/include/SystemPropertiesImpl.h
r26044 r27607 124 124 HRESULT setWebServiceAuthLibrary(const Utf8Str &aPath); 125 125 126 const ComObjPtr<VirtualBox, ComWeakRef>mParent;126 VirtualBox * const mParent; 127 127 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; 133 133 134 MediumFormatList mMediumFormats;134 MediumFormatList mMediumFormats; 135 135 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; 140 140 141 141 friend class VirtualBox; -
trunk/src/VBox/Main/include/VFSExplorerImpl.h
r26044 r27607 75 75 private: 76 76 /* Private member vars */ 77 const ComObjPtr<VirtualBox, ComWeakRef>mVirtualBox;77 VirtualBox * const mVirtualBox; 78 78 79 79 struct TaskVFSExplorer; /* Worker thread helper */ -
trunk/src/VBox/Main/include/VMMDev.h
r26173 r27607 64 64 static DECLCALLBACK(void) drvReset(PPDMDRVINS pDrvIns); 65 65 66 Co mObjPtr<Console, ComWeakRef>mParent;66 Console * const mParent; 67 67 68 68 RTSEMEVENT mCredentialsEvent; -
trunk/src/VBox/Main/include/VRDPServerImpl.h
r26171 r27607 108 108 private: 109 109 110 const ComObjPtr<Machine, ComWeakRef>mParent;110 Machine * const mParent; 111 111 const ComObjPtr<VRDPServer> mPeer; 112 112 113 Backupable<Data> mData;113 Backupable<Data> mData; 114 114 }; 115 115 -
trunk/src/VBox/Main/include/objectslist.h
r25894 r27607 50 50 { 51 51 public: 52 typedef ComObjPtr<T , ComStrongRef> MyType;52 typedef ComObjPtr<T> MyType; 53 53 typedef std::list<MyType> MyList; 54 54
Note:
See TracChangeset
for help on using the changeset viewer.