VirtualBox

source: vbox/trunk/src/VBox/Main/include/ApplianceImpl.h@ 18269

Last change on this file since 18269 was 18269, checked in by vboxsync, 16 years ago

Main: rework IProgress internals to optionally handle weighted operations; rename some internal IProgress methods; change percentage APIs to use ULONGs instead of LONGs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/* $Id: ApplianceImpl.h 18269 2009-03-25 18:01:07Z vboxsync $ */
2
3/** @file
4 *
5 * VirtualBox COM class implementation
6 */
7
8/*
9 * Copyright (C) 2006-2009 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_APPLIANCEIMPL
25#define ____H_APPLIANCEIMPL
26
27#include "VirtualBoxBase.h"
28
29namespace xml
30{
31 class Node;
32 class ElementNode;
33}
34
35class VirtualBox;
36class Progress;
37
38class ATL_NO_VTABLE Appliance :
39 public VirtualBoxBaseWithChildrenNEXT,
40 public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
41 public VirtualBoxSupportTranslation <Appliance>,
42 public IAppliance
43{
44public:
45 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
46
47 DECLARE_NOT_AGGREGATABLE(Appliance)
48
49 DECLARE_PROTECT_FINAL_CONSTRUCT()
50
51 BEGIN_COM_MAP(Appliance)
52 COM_INTERFACE_ENTRY(ISupportErrorInfo)
53 COM_INTERFACE_ENTRY(IAppliance)
54 END_COM_MAP()
55
56 NS_DECL_ISUPPORTS
57
58 DECLARE_EMPTY_CTOR_DTOR (Appliance)
59
60 // public initializer/uninitializer for internal purposes only
61 HRESULT FinalConstruct() { return S_OK; }
62 void FinalRelease() { uninit(); }
63
64 HRESULT init(VirtualBox *aVirtualBox);
65 void uninit();
66
67 // for VirtualBoxSupportErrorInfoImpl
68 static const wchar_t *getComponentName() { return L"Appliance"; }
69
70 /* IAppliance properties */
71 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
72 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
73 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
74
75 /* IAppliance methods */
76 STDMETHOD(Read)(IN_BSTR path);
77 STDMETHOD(Interpret)(void);
78 STDMETHOD(ImportMachines)(IProgress **aProgress);
79 STDMETHOD(Write)(IN_BSTR path, IProgress **aProgress);
80 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
81
82 /* public methods only for internal purposes */
83
84 /* private instance data */
85private:
86 /** weak VirtualBox parent */
87 const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
88
89 struct Data; // obscure, defined in AppliannceImpl.cpp
90 Data *m;
91
92 HRESULT LoopThruSections(const char *pcszPath, const xml::ElementNode *pReferencesElem, const xml::ElementNode *pCurElem);
93 HRESULT HandleDiskSection(const char *pcszPath, const xml::ElementNode *pReferencesElem, const xml::ElementNode *pSectionElem);
94 HRESULT HandleNetworkSection(const char *pcszPath, const xml::ElementNode *pSectionElem);
95 HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::ElementNode *pContentElem);
96
97 HRESULT searchUniqueVMName(Utf8Str& aName) const;
98 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
99 HRESULT setUpProgress(ComObjPtr<Progress> &pProgress, const Bstr &bstrDescription);
100 void addWarning(const char* aWarning, ...);
101
102 struct TaskImportMachines; /* Worker thread for import */
103 static DECLCALLBACK(int) taskThreadImportMachines(RTTHREAD thread, void *pvUser);
104
105 struct TaskWriteOVF; /* Worker thread for export */
106 static DECLCALLBACK(int) taskThreadWriteOVF(RTTHREAD thread, void *pvUser);
107
108 friend class Machine;
109};
110
111struct VirtualSystemDescriptionEntry
112{
113 uint32_t ulIndex; // zero-based index of this entry within array
114 VirtualSystemDescriptionType_T type; // type of this entry
115 Utf8Str strRef; // reference number (hard disk controllers only)
116 Utf8Str strOvf; // original OVF value (type-dependent)
117 Utf8Str strVbox; // configuration value (type-dependent)
118 Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
119
120 uint32_t ulSizeMB; // hard disk images only: size of the uncompressed image in MB
121};
122
123class ATL_NO_VTABLE VirtualSystemDescription :
124 public VirtualBoxBaseWithChildrenNEXT,
125 public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
126 public VirtualBoxSupportTranslation <VirtualSystemDescription>,
127 public IVirtualSystemDescription
128{
129 friend class Appliance;
130
131public:
132 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
133
134 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
135
136 DECLARE_PROTECT_FINAL_CONSTRUCT()
137
138 BEGIN_COM_MAP(VirtualSystemDescription)
139 COM_INTERFACE_ENTRY(ISupportErrorInfo)
140 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
141 END_COM_MAP()
142
143 NS_DECL_ISUPPORTS
144
145 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
146
147 // public initializer/uninitializer for internal purposes only
148 HRESULT FinalConstruct() { return S_OK; }
149 void FinalRelease() { uninit(); }
150
151 HRESULT init();
152 void uninit();
153
154 // for VirtualBoxSupportErrorInfoImpl
155 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
156
157 /* IVirtualSystemDescription properties */
158 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
159
160 /* IVirtualSystemDescription methods */
161 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
162 ComSafeArrayOut(BSTR, aRefs),
163 ComSafeArrayOut(BSTR, aOvfValues),
164 ComSafeArrayOut(BSTR, aVboxValues),
165 ComSafeArrayOut(BSTR, aExtraConfigValues));
166
167 STDMETHOD(GetDescriptionByType)(VirtualSystemDescriptionType_T aType,
168 ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
169 ComSafeArrayOut(BSTR, aRefs),
170 ComSafeArrayOut(BSTR, aOvfValues),
171 ComSafeArrayOut(BSTR, aVboxValues),
172 ComSafeArrayOut(BSTR, aExtraConfigValues));
173
174 STDMETHOD(GetValuesByType)(VirtualSystemDescriptionType_T aType,
175 VirtualSystemDescriptionValueType_T aWhich,
176 ComSafeArrayOut(BSTR, aValues));
177
178 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
179 ComSafeArrayIn(IN_BSTR, aVboxValues),
180 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
181
182 STDMETHOD(AddDescription)(VirtualSystemDescriptionType_T aType,
183 IN_BSTR aVboxValue,
184 IN_BSTR aExtraConfigValue);
185
186 /* public methods only for internal purposes */
187
188 void addEntry(VirtualSystemDescriptionType_T aType,
189 const Utf8Str &strRef,
190 const Utf8Str &aOrigValue,
191 const Utf8Str &aAutoValue,
192 uint32_t ulSizeMB = 0,
193 const Utf8Str &strExtraConfig = "");
194
195 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
196 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
197
198 /* private instance data */
199private:
200 struct Data;
201 Data *m;
202
203 friend class Machine;
204};
205
206#endif // ____H_APPLIANCEIMPL
207/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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