VirtualBox

source: vbox/trunk/src/VBox/Main/include/EventImpl.h@ 54486

Last change on this file since 54486 was 52720, checked in by vboxsync, 10 years ago

Main/Event: build fixes for XPCOM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: EventImpl.h 52720 2014-09-12 12:59:15Z vboxsync $ */
2/** @file
3 * VirtualBox COM IEvent implementation
4 */
5
6/*
7 * Copyright (C) 2010-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_EVENTIMPL
19#define ____H_EVENTIMPL
20
21#include "EventWrap.h"
22#include "EventSourceWrap.h"
23#include "VetoEventWrap.h"
24
25
26class ATL_NO_VTABLE VBoxEvent :
27 public EventWrap
28{
29public:
30 DECLARE_EMPTY_CTOR_DTOR(VBoxEvent)
31
32 HRESULT FinalConstruct();
33 void FinalRelease();
34
35 // public initializer/uninitializer for internal purposes only
36 HRESULT init(IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable);
37 void uninit();
38
39private:
40 // wrapped IEvent properties
41 HRESULT getType(VBoxEventType_T *aType);
42 HRESULT getSource(ComPtr<IEventSource> &aSource);
43 HRESULT getWaitable(BOOL *aWaitable);
44
45 // wrapped IEvent methods
46 HRESULT setProcessed();
47 HRESULT waitProcessed(LONG aTimeout, BOOL *aResult);
48
49 struct Data;
50 Data* m;
51};
52
53
54class ATL_NO_VTABLE VBoxVetoEvent :
55 public VetoEventWrap
56{
57public:
58 DECLARE_EMPTY_CTOR_DTOR(VBoxVetoEvent)
59
60 HRESULT FinalConstruct();
61 void FinalRelease();
62
63 // public initializer/uninitializer for internal purposes only
64 HRESULT init(IEventSource *aSource, VBoxEventType_T aType);
65 void uninit();
66
67private:
68 // wrapped IEvent properties
69 HRESULT getType(VBoxEventType_T *aType);
70 HRESULT getSource(ComPtr<IEventSource> &aSource);
71 HRESULT getWaitable(BOOL *aWaitable);
72
73 // wrapped IEvent methods
74 HRESULT setProcessed();
75 HRESULT waitProcessed(LONG aTimeout, BOOL *aResult);
76
77 // wrapped IVetoEvent methods
78 HRESULT addVeto(const com::Utf8Str &aReason);
79 HRESULT isVetoed(BOOL *aResult);
80 HRESULT getVetos(std::vector<com::Utf8Str> &aResult);
81
82 struct Data;
83 Data* m;
84};
85
86class ATL_NO_VTABLE EventSource :
87 public EventSourceWrap
88{
89public:
90 DECLARE_EMPTY_CTOR_DTOR(EventSource)
91
92 HRESULT FinalConstruct();
93 void FinalRelease();
94
95 // public initializer/uninitializer for internal purposes only
96 HRESULT init();
97 void uninit();
98
99private:
100 // wrapped IEventSource methods
101 HRESULT createListener(ComPtr<IEventListener> &aListener);
102 HRESULT createAggregator(const std::vector<ComPtr<IEventSource> > &aSubordinates,
103 ComPtr<IEventSource> &aResult);
104 HRESULT registerListener(const ComPtr<IEventListener> &aListener,
105 const std::vector<VBoxEventType_T> &aInteresting,
106 BOOL aActive);
107 HRESULT unregisterListener(const ComPtr<IEventListener> &aListener);
108 HRESULT fireEvent(const ComPtr<IEvent> &aEvent,
109 LONG aTimeout,
110 BOOL *aResult);
111 HRESULT getEvent(const ComPtr<IEventListener> &aListener,
112 LONG aTimeout,
113 ComPtr<IEvent> &aEvent);
114 HRESULT eventProcessed(const ComPtr<IEventListener> &aListener,
115 const ComPtr<IEvent> &aEvent);
116
117
118 struct Data;
119 Data* m;
120
121 friend class ListenerRecord;
122};
123
124class VBoxEventDesc
125{
126public:
127 VBoxEventDesc() : mEvent(0), mEventSource(0)
128 {}
129
130 ~VBoxEventDesc()
131 {}
132
133 /**
134 * This function to be used with some care, as arguments order must match
135 * attribute declaration order event class and its superclasses up to
136 * IEvent. If unsure, consult implementation in generated VBoxEvents.cpp.
137 */
138 HRESULT init(IEventSource* aSource, VBoxEventType_T aType, ...);
139
140 /**
141 * Function similar to the above, but assumes that init() for this type
142 * already called once, so no need to allocate memory, and only reinit
143 * fields. Assumes event is subtype of IReusableEvent, asserts otherwise.
144 */
145 HRESULT reinit(VBoxEventType_T aType, ...);
146
147 void uninit()
148 {
149 mEvent.setNull();
150 mEventSource.setNull();
151 }
152
153 void getEvent(IEvent **aEvent)
154 {
155 mEvent.queryInterfaceTo(aEvent);
156 }
157
158 BOOL fire(LONG aTimeout)
159 {
160 if (mEventSource && mEvent)
161 {
162 BOOL fDelivered = FALSE;
163 int rc = mEventSource->FireEvent(mEvent, aTimeout, &fDelivered);
164 AssertRCReturn(rc, FALSE);
165 return fDelivered;
166 }
167 return FALSE;
168 }
169
170private:
171 ComPtr<IEvent> mEvent;
172 ComPtr<IEventSource> mEventSource;
173};
174
175
176#endif // ____H_EVENTIMPL
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette