VirtualBox

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

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

OVF: preparations for export thread

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.3 KB
Line 
1/* $Id: ApplianceImpl.h 17343 2009-03-04 12:57:43Z 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}
33
34class VirtualBox;
35
36class ATL_NO_VTABLE Appliance :
37 public VirtualBoxBaseWithChildrenNEXT,
38 public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
39 public VirtualBoxSupportTranslation <Appliance>,
40 public IAppliance
41{
42
43public:
44
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 /* public methods only for internal purposes */
81
82 /* private instance data */
83private:
84 /** weak VirtualBox parent */
85 const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
86
87 struct Data; // obscure, defined in AppliannceImpl.cpp
88 Data *m;
89
90 HRESULT LoopThruSections(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pCurElem);
91 HRESULT HandleDiskSection(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pSectionElem);
92 HRESULT HandleNetworkSection(const char *pcszPath, const xml::Node *pSectionElem);
93 HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::Node *pContentElem);
94
95 HRESULT searchUniqueVMName(Utf8Str& aName) const;
96 HRESULT searchUniqueDiskImageFilePath(Utf8Str& aName) const;
97 uint32_t calcMaxProgress();
98
99 struct TaskImportMachines; /* Worker thread for import */
100 static DECLCALLBACK(int) taskThreadImportMachines(RTTHREAD thread, void *pvUser);
101
102 struct TaskExportOVF; /* Worker thread for export */
103 static DECLCALLBACK(int) taskThreadExportOVF(RTTHREAD thread, void *pvUser);
104
105 friend class Machine;
106};
107
108struct VirtualSystemDescriptionEntry
109{
110 uint32_t ulIndex; // zero-based index of this entry within array
111 VirtualSystemDescriptionType_T type; // type of this entry
112 Utf8Str strRef; // reference number (hard disk controllers only)
113 Utf8Str strOvf; // original OVF value (type-dependent)
114 Utf8Str strVbox; // configuration value (type-dependent)
115 Utf8Str strExtraConfig; // extra configuration key=value strings (type-dependent)
116};
117
118class ATL_NO_VTABLE VirtualSystemDescription :
119 public VirtualBoxBaseWithChildrenNEXT,
120 public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
121 public VirtualBoxSupportTranslation <VirtualSystemDescription>,
122 public IVirtualSystemDescription
123{
124 friend class Appliance;
125public:
126 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
127
128 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
129
130 DECLARE_PROTECT_FINAL_CONSTRUCT()
131
132 BEGIN_COM_MAP(VirtualSystemDescription)
133 COM_INTERFACE_ENTRY(ISupportErrorInfo)
134 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
135 END_COM_MAP()
136
137 NS_DECL_ISUPPORTS
138
139 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
140
141 // public initializer/uninitializer for internal purposes only
142 HRESULT FinalConstruct() { return S_OK; }
143 void FinalRelease() { uninit(); }
144
145 HRESULT init();
146 void uninit();
147
148 // for VirtualBoxSupportErrorInfoImpl
149 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
150
151 /* IVirtualSystemDescription properties */
152 STDMETHOD(COMGETTER(Count))(ULONG *aCount);
153
154 /* IVirtualSystemDescription methods */
155 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
156 ComSafeArrayOut(BSTR, aRefs),
157 ComSafeArrayOut(BSTR, aOvfValues),
158 ComSafeArrayOut(BSTR, aVboxValues),
159 ComSafeArrayOut(BSTR, aExtraConfigValues));
160
161 STDMETHOD(SetFinalValues)(ComSafeArrayIn(BOOL, aEnabled),
162 ComSafeArrayIn(IN_BSTR, aVboxValues),
163 ComSafeArrayIn(IN_BSTR, aExtraConfigValues));
164
165 STDMETHOD(GetWarnings)(ComSafeArrayOut(BSTR, aWarnings));
166
167 /* public methods only for internal purposes */
168
169 void addEntry(VirtualSystemDescriptionType_T aType,
170 const Utf8Str &strRef,
171 const Utf8Str &aOrigValue,
172 const Utf8Str &aAutoValue,
173 const Utf8Str &strExtraConfig = "");
174
175 void addWarning(const char* aWarning, ...);
176
177 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
178 const VirtualSystemDescriptionEntry* findControllerFromID(uint32_t id);
179
180 /* private instance data */
181private:
182 struct Data;
183 Data *m;
184};
185
186#endif // ____H_APPLIANCEIMPL
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