VirtualBox

source: vbox/trunk/src/VBox/Main/src-server/win/VBoxComEvents.h@ 52489

Last change on this file since 52489 was 35368, checked in by vboxsync, 14 years ago

Main: source re-org.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.7 KB
Line 
1/** @file
2 *
3 * Declaration of COM Events Helper routines.
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 __VBOXCOMEVENTS_h__
19#define __VBOXCOMEVENTS_h__
20
21#include <map>
22
23#include "VBox/com/string.h"
24#include "VBox/com/guid.h"
25
26#include <VBox/err.h>
27
28#include <atlcom.h>
29
30
31class ComEventDesc
32{
33public:
34 ComEventDesc()
35 : mArgc(0), mArgs(0), mPos(0)
36 {}
37 ~ComEventDesc()
38 {
39 if (mArgs)
40 delete [] mArgs;
41 }
42
43 void init(const char* name, int argc)
44 {
45 // copies content
46 mName = name;
47 mArgc = argc;
48 if (mArgs)
49 delete [] mArgs;
50 mArgs = new CComVariant[mArgc];
51 mPos = argc - 1;
52 }
53
54 template <class T>
55 ComEventDesc& add(T v)
56 {
57 Assert(mPos>= 0);
58 mArgs[mPos] = v;
59 mPos--;
60 return *this;
61 }
62
63private:
64 com::Utf8Str mName;
65 int mArgc;
66 CComVariant* mArgs;
67 int mPos;
68
69 friend class ComEventsHelper;
70};
71
72class ComEventsHelper
73{
74public:
75 ComEventsHelper();
76 ~ComEventsHelper();
77
78 HRESULT init(const com::Guid &aGuid);
79 HRESULT lookup(com::Utf8Str &aName, DISPID *did);
80 HRESULT fire(IDispatch* aObj, ComEventDesc& desc, CComVariant *pResult);
81
82private:
83 typedef std::map<com::Utf8Str, DISPID> ComEventsMap;
84
85 ComEventsMap evMap;
86};
87
88#endif /* __VBOXCOMEVENTS_h__ */
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