VirtualBox

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

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

OVF: avoid excessive string/list copying

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/* $Id: ApplianceImpl.h 16309 2009-01-28 13:42:36Z 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
29#include <string>
30
31class VirtualBox;
32
33class ATL_NO_VTABLE Appliance :
34 public VirtualBoxBaseWithChildrenNEXT,
35 public VirtualBoxSupportErrorInfoImpl <Appliance, IAppliance>,
36 public VirtualBoxSupportTranslation <Appliance>,
37 public IAppliance
38{
39
40public:
41
42 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (Appliance)
43
44 DECLARE_NOT_AGGREGATABLE(Appliance)
45
46 DECLARE_PROTECT_FINAL_CONSTRUCT()
47
48 BEGIN_COM_MAP(Appliance)
49 COM_INTERFACE_ENTRY(ISupportErrorInfo)
50 COM_INTERFACE_ENTRY(IAppliance)
51 END_COM_MAP()
52
53 NS_DECL_ISUPPORTS
54
55 DECLARE_EMPTY_CTOR_DTOR (Appliance)
56
57 // public initializer/uninitializer for internal purposes only
58 HRESULT FinalConstruct() { return S_OK; }
59 void FinalRelease() { uninit(); }
60
61 HRESULT init(VirtualBox *aVirtualBox, IN_BSTR &path);
62 void uninit();
63
64 // for VirtualBoxSupportErrorInfoImpl
65 static const wchar_t *getComponentName() { return L"Appliance"; }
66
67 /* IAppliance properties */
68 STDMETHOD(COMGETTER(Path))(BSTR *aPath);
69 STDMETHOD(COMGETTER(Disks))(ComSafeArrayOut(BSTR, aDisks));
70 STDMETHOD(COMGETTER(VirtualSystemDescriptions))(ComSafeArrayOut(IVirtualSystemDescription*, aVirtualSystemDescriptions));
71
72 /* IAppliance methods */
73 /* void interpret (); */
74 STDMETHOD(Interpret)(void);
75
76 /* public methods only for internal purposes */
77 STDMETHOD(ImportAppliance)();
78
79 /* private instance data */
80private:
81 /** weak VirtualBox parent */
82 const ComObjPtr <VirtualBox, ComWeakRef> mVirtualBox;
83
84 struct Data; // obscure, defined in AppliannceImpl.cpp
85 Data *m;
86
87 HRESULT LoopThruSections(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pCurElem);
88 HRESULT HandleDiskSection(const char *pcszPath, const xml::Node *pReferencesElem, const xml::Node *pSectionElem);
89 HRESULT HandleNetworkSection(const char *pcszPath, const xml::Node *pSectionElem);
90 HRESULT HandleVirtualSystemContent(const char *pcszPath, const xml::Node *pContentElem);
91
92 HRESULT searchUniqueVMName (std::string& aName) const;
93 HRESULT searchUniqueDiskImageFilePath(std::string& aName) const;
94};
95
96struct VirtualSystemDescriptionEntry
97{
98 VirtualSystemDescriptionType_T type; /* Of which type is this value */
99 std::string strRef; /* Reference value to the internal implementation */
100 std::string strOriginalValue; /* The original OVF value */
101 std::string strAutoValue; /* The value which VBox suggest */
102 std::string strFinalValue; /* The value the user select */
103 std::string strConfiguration; /* Additional configuration data for this type */
104};
105
106class ATL_NO_VTABLE VirtualSystemDescription :
107 public VirtualBoxBaseWithChildrenNEXT,
108 public VirtualBoxSupportErrorInfoImpl <VirtualSystemDescription, IVirtualSystemDescription>,
109 public VirtualBoxSupportTranslation <VirtualSystemDescription>,
110 public IVirtualSystemDescription
111{
112 friend class Appliance;
113public:
114 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (VirtualSystemDescription)
115
116 DECLARE_NOT_AGGREGATABLE(VirtualSystemDescription)
117
118 DECLARE_PROTECT_FINAL_CONSTRUCT()
119
120 BEGIN_COM_MAP(VirtualSystemDescription)
121 COM_INTERFACE_ENTRY(ISupportErrorInfo)
122 COM_INTERFACE_ENTRY(IVirtualSystemDescription)
123 END_COM_MAP()
124
125 NS_DECL_ISUPPORTS
126
127 DECLARE_EMPTY_CTOR_DTOR (VirtualSystemDescription)
128
129 // public initializer/uninitializer for internal purposes only
130 HRESULT FinalConstruct() { return S_OK; }
131 void FinalRelease() { uninit(); }
132
133 HRESULT init();
134 void uninit();
135
136 // for VirtualBoxSupportErrorInfoImpl
137 static const wchar_t *getComponentName() { return L"VirtualSystemDescription"; }
138
139 /* IVirtualSystemDescription properties */
140
141 /* IVirtualSystemDescription methods */
142 STDMETHOD(GetDescription)(ComSafeArrayOut(VirtualSystemDescriptionType_T, aTypes),
143 ComSafeArrayOut(BSTR, aOrigValues),
144 ComSafeArrayOut(BSTR, aAutoValues),
145 ComSafeArrayOut(BSTR, aConfigurations));
146 STDMETHOD(SetFinalValues)(ComSafeArrayIn(IN_BSTR, aFinalValues));
147
148 /* public methods only for internal purposes */
149
150 /* private instance data */
151private:
152 void addEntry(VirtualSystemDescriptionType_T aType,
153 const std::string &aRef,
154 const std::string &aOrigValue,
155 const std::string &aAutoValue,
156 const std::string &aConfig = "");
157
158 std::list<VirtualSystemDescriptionEntry*> findByType(VirtualSystemDescriptionType_T aType);
159
160 struct Data;
161 Data *m;
162};
163
164#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