VirtualBox

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

最後變更 在這個檔案從62370是 60764,由 vboxsync 提交於 9 年 前

Main/src-server/win/VBoxComEvents: eliminate the use of not really needed ATL helper classes

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 1.7 KB
 
1/* $Id: VBoxComEvents.h 60764 2016-04-29 14:11:22Z vboxsync $ */
2/** @file
3 *
4 * Declaration of COM Events Helper routines.
5 */
6
7/*
8 * Copyright (C) 2010-2016 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.alldomusa.eu.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef __VBOXCOMEVENTS_h__
20#define __VBOXCOMEVENTS_h__
21
22#include <map>
23
24#include "VBox/com/string.h"
25#include "VBox/com/guid.h"
26
27#include <VBox/err.h>
28
29
30class ComEventDesc
31{
32public:
33 ComEventDesc()
34 : mArgc(0), mArgs(0), mPos(0)
35 {}
36 ~ComEventDesc()
37 {
38 if (mArgs)
39 delete [] mArgs;
40 }
41
42 void init(const char *name, int argc)
43 {
44 // copies content
45 mName = name;
46 mArgc = argc;
47 if (mArgs)
48 delete [] mArgs;
49 mArgs = new tagVARIANT[mArgc];
50 mPos = argc - 1;
51 }
52
53 template <class T>
54 ComEventDesc &add(T v)
55 {
56 Assert(mPos>= 0);
57 mArgs[mPos] = v;
58 mPos--;
59 return *this;
60 }
61
62private:
63 com::Utf8Str mName;
64 int mArgc;
65 tagVARIANT *mArgs;
66 int mPos;
67
68 friend class ComEventsHelper;
69};
70
71class ComEventsHelper
72{
73public:
74 ComEventsHelper();
75 ~ComEventsHelper();
76
77 HRESULT init(const com::Guid &aGuid);
78 HRESULT lookup(com::Utf8Str &aName, DISPID *did);
79 HRESULT fire(IDispatch *aObj, ComEventDesc &desc, tagVARIANT *pResult);
80
81private:
82 typedef std::map<com::Utf8Str, DISPID> ComEventsMap;
83
84 ComEventsMap evMap;
85};
86
87#endif /* __VBOXCOMEVENTS_h__ */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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