VirtualBox

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

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

OVF: appliance export, initial code.

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