Changeset 6449 in vbox
- Timestamp:
- Jan 22, 2008 4:13:28 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 27425
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/include/VBox/com/ptr.h ¶
r6440 r6449 80 80 81 81 /** 82 * Equality operations for the ComPtrBase template. 83 */ 84 template <class C> 85 class ComPtrEqOps 86 { 87 protected: 88 89 template <class I> 90 static bool equals (C *aThis, I *aThat) 91 { 92 IUnknown *thatUnk = NULL, *thisUnk = NULL; 93 if (aThat) 94 aThat->QueryInterface (COM_IIDOF (IUnknown), (void **) &thatUnk); 95 if (aThis) 96 aThis->QueryInterface (COM_IIDOF (IUnknown), (void **) &thisUnk); 97 bool equal = thisUnk == thatUnk; 98 if (thisUnk) 99 thisUnk->Release(); 100 if (thatUnk) 101 thatUnk->Release(); 102 return equal; 103 } 104 105 /* specialization for IUnknown */ 106 template<> 107 static bool equals <IUnknown> (C *aThis, IUnknown *aThat) 108 { 109 IUnknown *thisUnk = NULL; 110 if (aThis) 111 aThis->QueryInterface (COM_IIDOF (IUnknown), (void **) &thisUnk); 112 bool equal = thisUnk == aThat; 113 if (thisUnk) 114 thisUnk->Release(); 115 return equal; 116 } 117 }; 118 119 /** Specialization for IUnknown */ 82 * Returns @c true if two interface pointers are equal. 83 * 84 * According to the COM Identity Rule, interface pointers are considered to be 85 * equal if and only if IUnknown pointers queried on these interfaces pointers 86 * are equal (e.g. have the same binary value). Equal interface pointers 87 * represent the same object even if they are pointers to different interfaces. 88 * 89 * @param I1 Class of the first interface pointer (must be derived from 90 * IUnknown). 91 * @param I2 Class of the second interface pointer (must be derived from 92 * IUnknown). 93 */ 94 template <class I1, class I2> 95 inline bool ComPtrEquals (I1 *aThis, I2 *aThat) 96 { 97 IUnknown *thatUnk = NULL, *thisUnk = NULL; 98 if (aThat) 99 aThat->QueryInterface (COM_IIDOF (IUnknown), (void **) &thatUnk); 100 if (aThis) 101 aThis->QueryInterface (COM_IIDOF (IUnknown), (void **) &thisUnk); 102 bool equal = thisUnk == thatUnk; 103 if (thisUnk) 104 thisUnk->Release(); 105 if (thatUnk) 106 thatUnk->Release(); 107 return equal; 108 } 109 110 /* specialization for <Any, IUnknown> */ 111 template <class I1> 112 inline bool ComPtrEquals (I1 *aThis, IUnknown *aThat) 113 { 114 IUnknown *thisUnk = NULL; 115 if (aThis) 116 aThis->QueryInterface (COM_IIDOF (IUnknown), (void **) &thisUnk); 117 bool equal = thisUnk == aThat; 118 if (thisUnk) 119 thisUnk->Release(); 120 return equal; 121 } 122 123 /** Specialization for <IUnknown, Any> */ 124 template <class I2> 125 inline bool ComPtrEquals (IUnknown *aThis, I2 *aThat) 126 { 127 IUnknown *thatUnk = NULL; 128 if (aThat) 129 aThat->QueryInterface (COM_IIDOF (IUnknown), (void **) &thatUnk); 130 bool equal = aThis == thatUnk; 131 if (thatUnk) 132 thatUnk->Release(); 133 return equal; 134 } 135 136 /* specialization for IUnknown */ 120 137 template<> 121 class ComPtrEqOps <IUnknown> 122 { 123 protected: 124 125 template <class I> 126 static bool equals (IUnknown *aThis, I *aThat) 127 { 128 IUnknown *thatUnk = NULL; 129 if (aThat) 130 aThat->QueryInterface (COM_IIDOF (IUnknown), (void **) &thatUnk); 131 bool equal = aThis == thatUnk; 132 if (thatUnk) 133 thatUnk->Release(); 134 return equal; 135 } 136 137 /* specialization for IUnknown */ 138 template<> 139 static bool equals <IUnknown> (IUnknown *aThis, IUnknown *aThat) 140 { 141 return aThis == aThat; 142 } 143 }; 138 inline bool ComPtrEquals <IUnknown, IUnknown> (IUnknown *aThis, IUnknown *aThat) 139 { 140 return aThis == aThat; 141 } 144 142 145 143 /** … … 147 145 */ 148 146 template <class C, template <class> class RefOps = ComStrongRef> 149 class ComPtrBase : protected RefOps <C> , protected ComPtrEqOps <C>147 class ComPtrBase : protected RefOps <C> 150 148 { 151 149 public: … … 206 204 bool equalsTo (I *aThat) const 207 205 { 208 return equals (p, aThat);206 return ComPtrEquals (p, aThat); 209 207 } 210 208 -
TabularUnified trunk/src/VBox/Main/MachineImpl.cpp ¶
r6440 r6449 2961 2961 /* memorize the direct session control and cache IUnknown for it */ 2962 2962 mData->mSession.mDirectControl = aControl; 2963 mData->mSession.mDirectControlUnk = aControl;2964 2963 mData->mSession.mState = SessionState_SessionOpen; 2965 2964 /* associate the SessionMachine with this Machine */ 2966 2965 mData->mSession.mMachine = sessionMachine; 2966 2967 /* request an IUnknown pointer early from the remote party for later 2968 * identity checks (it will be internally cached within mDirectControl 2969 * at least on XPCOM) */ 2970 ComPtr <IUnknown> unk = mData->mSession.mDirectControl; 2971 NOREF (unk); 2967 2972 } 2968 2973 … … 7308 7313 { 7309 7314 mData->mSession.mDirectControl.setNull(); 7310 mData->mSession.mDirectControlUnk.setNull();7311 7315 } 7312 7316 else … … 7535 7539 AutoMultiLock <2> alock (mParent->wlock(), this->wlock()); 7536 7540 7537 if (control.equalsTo (mData->mSession.mDirectControl Unk))7541 if (control.equalsTo (mData->mSession.mDirectControl)) 7538 7542 { 7539 7543 ComAssertRet (aProgress, E_POINTER); … … 7549 7553 /* set direct control to NULL to release the remote instance */ 7550 7554 mData->mSession.mDirectControl.setNull(); 7551 mData->mSession.mDirectControlUnk.setNull();7552 7555 LogFlowThisFunc (("Direct control is set to NULL\n")); 7553 7556 -
TabularUnified trunk/src/VBox/Main/include/MachineImpl.h ¶
r6440 r6449 103 103 /** Control of the direct session opened by openSession() */ 104 104 ComPtr <IInternalSessionControl> mDirectControl; 105 /** Cached IUnknown of mDirectControl (IPC) for fast comparison */106 ComPtr <IUnknown> mDirectControlUnk;107 105 108 106 typedef std::list <ComPtr <IInternalSessionControl> > RemoteControlList;
Note:
See TracChangeset
for help on using the changeset viewer.