VirtualBox

root/trunk/include/VBox/com/VirtualBoxErrorInfo.h

Revision 15051, 5.7 kB (checked in by vboxsync, 1 month ago)

Main: Cleaned up the long standing const BSTR = const (OLECHAR *) on WIn32 vs (const PRunichar) * on XPCOM clash. Cleaned up BSTR/GUID macros (IN_BSTR replaces INPTR BSTR, IN_GUID replaces INPTR GUIDPARAM, OUT_GUID replaces GUIDPARAMOUT).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /* $Id$ */
2
3 /** @file
4  * MS COM / XPCOM Abstraction Layer:
5  * VirtualBoxErrorInfo COM class declaration
6  */
7
8 /*
9  * Copyright (C) 2008 Sun Microsystems, Inc.
10  *
11  * This file is part of VirtualBox Open Source Edition (OSE), as
12  * available from http://www.virtualbox.org. This file is free software;
13  * you can redistribute it and/or modify it under the terms of the GNU
14  * General Public License (GPL) as published by the Free Software
15  * Foundation, in version 2 as it comes in the "COPYING" file of the
16  * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17  * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18  *
19  * The contents of this file may alternatively be used under the terms
20  * of the Common Development and Distribution License Version 1.0
21  * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
22  * VirtualBox OSE distribution, in which case the provisions of the
23  * CDDL are applicable instead of those of the GPL.
24  *
25  * You may elect to license modified versions of this file under the
26  * terms and conditions of either the GPL or the CDDL or both.
27  *
28  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
29  * Clara, CA 95054 USA or visit http://www.sun.com if you need
30  * additional information or have any questions.
31  */
32
33 #ifndef ___VBox_com_VirtualBoxErrorInfo_h
34 #define ___VBox_com_VirtualBoxErrorInfo_h
35
36 #include "VBox/com/defs.h"
37 #include "VBox/com/string.h"
38 #include "VBox/com/ptr.h"
39 #include "VBox/com/Guid.h"
40
41 /// @todo this is for IVirtualBoxErrorInfo, see the @todo below.
42 #include "VBox/com/VirtualBox.h"
43
44 namespace com
45 {
46
47 /**
48  * The VirtualBoxErrorInfo class implements the IVirtualBoxErrorInfo interface
49  * that provides extended error information about interface/component method
50  * invocation.
51  *
52  * @todo Rename IVirtualBoxErrorInfo/VirtualBoxErrorInfo to something like
53  *       IExtendedErrorInfo since it's not actually VirtualBox-dependent any
54  *       more. This will also require to create IExtendedErrorInfo.idl/h etc to
55  *       let adding this class to custom type libraries.
56  */
57 class ATL_NO_VTABLE VirtualBoxErrorInfo
58 #if !defined (VBOX_WITH_XPCOM)
59     : public CComObjectRootEx <CComMultiThreadModel>
60 #else
61     : public CComObjectRootEx
62 #endif
63     , public IVirtualBoxErrorInfo
64 {
65 public:
66
67     DECLARE_NOT_AGGREGATABLE (VirtualBoxErrorInfo)
68
69     DECLARE_PROTECT_FINAL_CONSTRUCT()
70
71     BEGIN_COM_MAP (VirtualBoxErrorInfo)
72         COM_INTERFACE_ENTRY (IErrorInfo)
73         COM_INTERFACE_ENTRY (IVirtualBoxErrorInfo)
74     END_COM_MAP()
75
76     NS_DECL_ISUPPORTS
77
78     VirtualBoxErrorInfo() : mResultCode (S_OK) {}
79
80     // public initializer/uninitializer for internal purposes only
81
82     HRESULT init (HRESULT aResultCode, const GUID *aIID,
83                   const char *aComponent, const char *aText,
84                   IVirtualBoxErrorInfo *aNext = NULL);
85
86     // IVirtualBoxErrorInfo properties
87     STDMETHOD(COMGETTER(ResultCode)) (HRESULT *aResultCode);
88     STDMETHOD(COMGETTER(InterfaceID)) (OUT_GUID aIID);
89     STDMETHOD(COMGETTER(Component)) (BSTR *aComponent);
90     STDMETHOD(COMGETTER(Text)) (BSTR *aText);
91     STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext);
92
93 #if !defined (VBOX_WITH_XPCOM)
94
95     HRESULT init (IErrorInfo *aInfo);
96
97     STDMETHOD(GetGUID) (GUID *guid);
98     STDMETHOD(GetSource) (BSTR *source);
99     STDMETHOD(GetDescription) (BSTR *description);
100     STDMETHOD(GetHelpFile) (BSTR *pBstrHelpFile);
101     STDMETHOD(GetHelpContext) (DWORD *pdwHelpContext);
102
103 #else /* !defined (VBOX_WITH_XPCOM) */
104
105     HRESULT init (nsIException *aInfo);
106
107     NS_DECL_NSIEXCEPTION
108
109 #endif
110
111 private:
112
113     HRESULT mResultCode;
114     Bstr mText;
115     Guid mIID;
116     Bstr mComponent;
117     ComPtr <IVirtualBoxErrorInfo> mNext;
118 };
119
120 /**
121  * The VirtualBoxErrorInfoGlue class glues two IVirtualBoxErrorInfo chains by
122  * attaching the head of the second chain to the tail of the first one.
123  *
124  * This is done by wrapping around each member of the first chain and
125  * substituting the next attribute implementation.
126  */
127 class ATL_NO_VTABLE VirtualBoxErrorInfoGlue
128 #if !defined (VBOX_WITH_XPCOM)
129     : public CComObjectRootEx <CComMultiThreadModel>
130 #else
131     : public CComObjectRootEx
132 #endif
133     , public IVirtualBoxErrorInfo
134 {
135 public:
136
137     DECLARE_NOT_AGGREGATABLE (VirtualBoxErrorInfoGlue)
138
139     DECLARE_PROTECT_FINAL_CONSTRUCT()
140
141     BEGIN_COM_MAP (VirtualBoxErrorInfoGlue)
142         COM_INTERFACE_ENTRY (IErrorInfo)
143         COM_INTERFACE_ENTRY (IVirtualBoxErrorInfo)
144     END_COM_MAP()
145
146     NS_DECL_ISUPPORTS
147
148     VirtualBoxErrorInfoGlue() {}
149
150     // public initializer/uninitializer for internal purposes only
151
152     HRESULT init (IVirtualBoxErrorInfo *aReal, IVirtualBoxErrorInfo *aNext);
153
154 protected:
155
156     HRESULT protectedInit (IVirtualBoxErrorInfo *aReal, IVirtualBoxErrorInfo *aNext);
157
158 private:
159
160     // IVirtualBoxErrorInfo properties
161     COM_FORWARD_IVirtualBoxErrorInfo_GETTER_ResultCode_TO_OBJ (mReal)
162     COM_FORWARD_IVirtualBoxErrorInfo_GETTER_InterfaceID_TO_OBJ (mReal)
163     COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Component_TO_OBJ (mReal)
164     COM_FORWARD_IVirtualBoxErrorInfo_GETTER_Text_TO_OBJ (mReal)
165     STDMETHOD(COMGETTER(Next)) (IVirtualBoxErrorInfo **aNext);
166
167 #if !defined (VBOX_WITH_XPCOM)
168
169     STDMETHOD(GetGUID) (GUID *guid) { return mReal->GetGUID (guid); }
170     STDMETHOD(GetSource) (BSTR *source) { return mReal->GetSource (source); }
171     STDMETHOD(GetDescription) (BSTR *description) { return mReal->GetDescription (description); }
172     STDMETHOD(GetHelpFile) (BSTR *pBstrHelpFile) { return mReal->GetHelpFile (pBstrHelpFile); }
173     STDMETHOD(GetHelpContext) (DWORD *pdwHelpContext) { return mReal->GetHelpContext (pdwHelpContext); }
174
175 #else /* !defined (VBOX_WITH_XPCOM) */
176
177     NS_FORWARD_NSIEXCEPTION (mReal->)
178
179 #endif
180
181 private:
182
183     ComPtr <IVirtualBoxErrorInfo> mReal;
184     ComPtr <IVirtualBoxErrorInfo> mNext;
185 };
186
187 } /* namespace com */
188
189 #endif /* ___VBox_com_VirtualBoxErrorInfo_h */
190
Note: See TracBrowser for help on using the browser.

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy