Changeset 34402 in vbox
- Timestamp:
- Nov 26, 2010 4:38:07 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/EventImpl.h
r33963 r34402 20 20 21 21 #include "VirtualBoxBase.h" 22 #include <iprt/asm.h> 22 23 23 24 24 class ATL_NO_VTABLE VBoxEvent : … … 46 46 47 47 // public initializer/uninitializer for internal purposes only 48 HRESULT init 48 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable); 49 49 void uninit(); 50 50 51 51 // IEvent properties 52 STDMETHOD(COMGETTER(Type)) 53 STDMETHOD(COMGETTER(Source)) 54 STDMETHOD(COMGETTER(Waitable)) 52 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType); 53 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource); 54 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable); 55 55 56 56 // IEvent methods … … 89 89 90 90 // public initializer/uninitializer for internal purposes only 91 HRESULT init 91 HRESULT init(IEventSource *aSource, VBoxEventType_T aType); 92 92 void uninit(); 93 93 94 94 // IEvent properties 95 STDMETHOD(COMGETTER(Type)) 95 STDMETHOD(COMGETTER(Type))(VBoxEventType_T *aType) 96 96 { 97 97 return VBoxEvent::COMGETTER(Type)(aType); 98 98 } 99 STDMETHOD(COMGETTER(Source)) 99 STDMETHOD(COMGETTER(Source))(IEventSource * *aSource) 100 100 { 101 101 return VBoxEvent::COMGETTER(Source)(aSource); 102 102 } 103 STDMETHOD(COMGETTER(Waitable)) 103 STDMETHOD(COMGETTER(Waitable))(BOOL *aWaitable) 104 104 { 105 105 return VBoxEvent::COMGETTER(Waitable)(aWaitable); … … 145 145 END_COM_MAP() 146 146 147 DECLARE_EMPTY_CTOR_DTOR 147 DECLARE_EMPTY_CTOR_DTOR(EventSource) 148 148 149 149 HRESULT FinalConstruct(); … … 151 151 152 152 // public initializer/uninitializer for internal purposes only 153 HRESULT init (IUnknown *aParent);153 HRESULT init(IUnknown *aParent); 154 154 void uninit(); 155 155 156 156 // IEventSource methods 157 STDMETHOD(CreateListener)(IEventListener ** 158 STDMETHOD(CreateAggregator)(ComSafeArrayIn(IEventSource *, aSubordinates),159 IEventSource ** 160 STDMETHOD(RegisterListener)(IEventListener * 157 STDMETHOD(CreateListener)(IEventListener **aListener); 158 STDMETHOD(CreateAggregator)(ComSafeArrayIn(IEventSource *, aSubordinates), 159 IEventSource **aAggregator); 160 STDMETHOD(RegisterListener)(IEventListener *aListener, 161 161 ComSafeArrayIn(VBoxEventType_T, aInterested), 162 BOOL aActive); 163 STDMETHOD(UnregisterListener)(IEventListener * aListener); 164 STDMETHOD(FireEvent)(IEvent * aEvent, 165 LONG aTimeout, 166 BOOL *aProcessed); 167 STDMETHOD(GetEvent)(IEventListener * aListener, 168 LONG aTimeout, 169 IEvent * *aEvent); 170 STDMETHOD(EventProcessed)(IEventListener * aListener, 171 IEvent * aEvent); 162 BOOL aActive); 163 STDMETHOD(UnregisterListener)(IEventListener *aListener); 164 STDMETHOD(FireEvent)(IEvent *aEvent, LONG aTimeout, BOOL *aProcessed); 165 STDMETHOD(GetEvent)(IEventListener *aListener, LONG aTimeout, 166 IEvent **aEvent); 167 STDMETHOD(EventProcessed)(IEventListener *aListener, IEvent *aEvent); 172 168 173 169 private: … … 182 178 { 183 179 public: 184 VBoxEventDesc()185 : mEvent(0), mEventSource(0)186 {} 187 ~VBoxEventDesc()188 {}189 190 /**191 * This function to be used with some care, as arguments order must match attribute declaration order192 * event class and its superclasses up to IEvent. If unsure, consult implementation in193 *generated VBoxEvents.cpp.194 */195 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, ...);196 197 /**198 * Function similar to the above, but assumes that init() for this type already called once,199 * so no need to allocate memory, and only reinit fields. Assumes event is subtype of200 *IReusableEvent, asserts otherwise.201 */202 HRESULT reinit(VBoxEventType_T aType, ...);203 204 void uninit()205 {206 mEvent.setNull();207 mEventSource.setNull();208 }209 210 void getEvent(IEvent **aEvent)211 {212 mEvent.queryInterfaceTo(aEvent);213 }214 215 BOOL fire(LONG aTimeout)216 {217 if (mEventSource && mEvent)218 {219 BOOL fDelivered = FALSE;220 int rc = mEventSource->FireEvent(mEvent, aTimeout, &fDelivered);221 AssertRCReturn(rc, FALSE);222 return fDelivered;223 }224 return FALSE;225 }226 227 private: 228 ComPtr<IEvent>mEvent;229 ComPtr<IEventSource>mEventSource;180 VBoxEventDesc() : mEvent(0), mEventSource(0) 181 {} 182 183 ~VBoxEventDesc() 184 {} 185 186 /** 187 * This function to be used with some care, as arguments order must match 188 * attribute declaration order event class and its superclasses up to 189 * IEvent. If unsure, consult implementation in generated VBoxEvents.cpp. 190 */ 191 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, ...); 192 193 /** 194 * Function similar to the above, but assumes that init() for this type 195 * already called once, so no need to allocate memory, and only reinit 196 * fields. Assumes event is subtype of IReusableEvent, asserts otherwise. 197 */ 198 HRESULT reinit(VBoxEventType_T aType, ...); 199 200 void uninit() 201 { 202 mEvent.setNull(); 203 mEventSource.setNull(); 204 } 205 206 void getEvent(IEvent **aEvent) 207 { 208 mEvent.queryInterfaceTo(aEvent); 209 } 210 211 BOOL fire(LONG aTimeout) 212 { 213 if (mEventSource && mEvent) 214 { 215 BOOL fDelivered = FALSE; 216 int rc = mEventSource->FireEvent(mEvent, aTimeout, &fDelivered); 217 AssertRCReturn(rc, FALSE); 218 return fDelivered; 219 } 220 return FALSE; 221 } 222 223 private: 224 ComPtr<IEvent> mEvent; 225 ComPtr<IEventSource> mEventSource; 230 226 }; 231 227
Note:
See TracChangeset
for help on using the changeset viewer.