1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM IEvent implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2010 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 "VirtualBoxBase.h"
|
---|
22 |
|
---|
23 | class ATL_NO_VTABLE VBoxEvent :
|
---|
24 | public VirtualBoxSupportErrorInfoImpl<VBoxEvent, IEvent>,
|
---|
25 | public VirtualBoxSupportTranslation<VBoxEvent>,
|
---|
26 | public VirtualBoxBase,
|
---|
27 | VBOX_SCRIPTABLE_IMPL(IEvent)
|
---|
28 | {
|
---|
29 | public:
|
---|
30 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(VBoxEvent)
|
---|
31 |
|
---|
32 | DECLARE_NOT_AGGREGATABLE(VBoxEvent)
|
---|
33 |
|
---|
34 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
35 |
|
---|
36 | BEGIN_COM_MAP(VBoxEvent)
|
---|
37 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
38 | COM_INTERFACE_ENTRY(IEvent)
|
---|
39 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
40 | END_COM_MAP()
|
---|
41 |
|
---|
42 | VBoxEvent() {}
|
---|
43 | virtual ~VBoxEvent() {}
|
---|
44 |
|
---|
45 | HRESULT FinalConstruct();
|
---|
46 | void FinalRelease();
|
---|
47 |
|
---|
48 | // public initializer/uninitializer for internal purposes only
|
---|
49 | HRESULT init (IEventSource *aSource, VBoxEventType_T aType, BOOL aWaitable);
|
---|
50 | void uninit();
|
---|
51 |
|
---|
52 | // IEvent properties
|
---|
53 | STDMETHOD(COMGETTER(Type)) (VBoxEventType_T *aType);
|
---|
54 | STDMETHOD(COMGETTER(Source)) (IEventSource * *aSource);
|
---|
55 | STDMETHOD(COMGETTER(Waitable)) (BOOL *aWaitable);
|
---|
56 |
|
---|
57 | // IEvent methods
|
---|
58 | STDMETHOD(SetProcessed)();
|
---|
59 | STDMETHOD(WaitProcessed)(LONG aTimeout, BOOL *aResult);
|
---|
60 |
|
---|
61 | // for VirtualBoxSupportErrorInfoImpl
|
---|
62 | static const wchar_t *getComponentName() { return L"Event"; }
|
---|
63 |
|
---|
64 | private:
|
---|
65 | struct Data;
|
---|
66 |
|
---|
67 | Data* m;
|
---|
68 | };
|
---|
69 |
|
---|
70 | class ATL_NO_VTABLE EventSource :
|
---|
71 | public VirtualBoxSupportErrorInfoImpl<EventSource, IEventSource>,
|
---|
72 | public VirtualBoxSupportTranslation<EventSource>,
|
---|
73 | public VirtualBoxBase,
|
---|
74 | VBOX_SCRIPTABLE_IMPL(IEventSource)
|
---|
75 | {
|
---|
76 | public:
|
---|
77 |
|
---|
78 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(EventSource)
|
---|
79 |
|
---|
80 | DECLARE_NOT_AGGREGATABLE(EventSource)
|
---|
81 |
|
---|
82 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
83 |
|
---|
84 | BEGIN_COM_MAP(EventSource)
|
---|
85 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
86 | COM_INTERFACE_ENTRY(IEventSource)
|
---|
87 | COM_INTERFACE_ENTRY(IDispatch)
|
---|
88 | END_COM_MAP()
|
---|
89 |
|
---|
90 | EventSource() {}
|
---|
91 | virtual ~EventSource() {}
|
---|
92 |
|
---|
93 | HRESULT FinalConstruct();
|
---|
94 | void FinalRelease();
|
---|
95 |
|
---|
96 | // public initializer/uninitializer for internal purposes only
|
---|
97 | HRESULT init ();
|
---|
98 | void uninit();
|
---|
99 |
|
---|
100 | // IEventSource methods
|
---|
101 | STDMETHOD(RegisterListener)(IEventListener * aListener,
|
---|
102 | ComSafeArrayIn(VBoxEventType, aInterested),
|
---|
103 | BOOL aActive);
|
---|
104 | STDMETHOD(UnregisterListener)(IEventListener * aListener);
|
---|
105 | STDMETHOD(FireEvent)(IEvent * aEvent,
|
---|
106 | LONG aTimeout,
|
---|
107 | BOOL *aProcessed);
|
---|
108 | STDMETHOD(GetEvent)(IEventListener * aListener,
|
---|
109 | LONG aTimeout,
|
---|
110 | IEvent * *aEvent);
|
---|
111 | STDMETHOD(EventProcessed)(IEventListener * aListener,
|
---|
112 | IEvent * aEvent);
|
---|
113 |
|
---|
114 | // for VirtualBoxSupportErrorInfoImpl
|
---|
115 | static const wchar_t *getComponentName() { return L"EventSource"; }
|
---|
116 |
|
---|
117 | private:
|
---|
118 | struct Data;
|
---|
119 |
|
---|
120 | Data* m;
|
---|
121 | };
|
---|
122 |
|
---|
123 | #endif // ____H_EVENTIMPL
|
---|