VirtualBox

source: vbox/trunk/src/VBox/Main/include/SnapshotImpl.h@ 21823

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

Main: merge VirtualBoxBaseNEXT onto VirtualBoxBase, adjust Host accordingly; fix Snapshot to use its own simple locking scheme instead of VirtualBoxBaseWithTypedChildren<T> (one snapshot tree lock per machine)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.215389.xyz. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_SNAPSHOTIMPL
23#define ____H_SNAPSHOTIMPL
24
25#include "VirtualBoxBase.h"
26
27#include <iprt/time.h>
28
29class SnapshotMachine;
30class VirtualBox;
31namespace settings
32{
33 class Key;
34}
35
36class ATL_NO_VTABLE Snapshot :
37 public VirtualBoxSupportErrorInfoImpl<Snapshot, ISnapshot>,
38 public VirtualBoxSupportTranslation<Snapshot>,
39 public VirtualBoxBase, // WithTypedChildren<Snapshot>,
40 VBOX_SCRIPTABLE_IMPL(ISnapshot)
41{
42public:
43 DECLARE_NOT_AGGREGATABLE(Snapshot)
44
45 DECLARE_PROTECT_FINAL_CONSTRUCT()
46
47 BEGIN_COM_MAP(Snapshot)
48 COM_INTERFACE_ENTRY (ISupportErrorInfo)
49 COM_INTERFACE_ENTRY (ISnapshot)
50 COM_INTERFACE_ENTRY2 (IDispatch, ISnapshot)
51 END_COM_MAP()
52
53 NS_DECL_ISUPPORTS
54
55 Snapshot()
56 : m(NULL)
57 { };
58 ~Snapshot()
59 { };
60
61 HRESULT FinalConstruct();
62 void FinalRelease();
63
64 // public initializer/uninitializer only for internal purposes
65 HRESULT init(VirtualBox *aVirtualBox,
66 const Guid &aId,
67 IN_BSTR aName,
68 IN_BSTR aDescription,
69 RTTIMESPEC aTimeStamp,
70 SnapshotMachine *aMachine,
71 Snapshot *aParent);
72 void uninit();
73
74 void beginDiscard();
75
76 // ISnapshot properties
77 STDMETHOD(COMGETTER(Id)) (BSTR *aId);
78 STDMETHOD(COMGETTER(Name)) (BSTR *aName);
79 STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
80 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
81 STDMETHOD(COMSETTER(Description)) (IN_BSTR aDescription);
82 STDMETHOD(COMGETTER(TimeStamp)) (LONG64 *aTimeStamp);
83 STDMETHOD(COMGETTER(Online)) (BOOL *aOnline);
84 STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
85 STDMETHOD(COMGETTER(Parent)) (ISnapshot **aParent);
86 STDMETHOD(COMGETTER(Children)) (ComSafeArrayOut (ISnapshot *, aChildren));
87
88 // ISnapshot methods
89
90 // public methods only for internal purposes
91
92 /** Do |AutoWriteLock alock (this);| before acceessing the returned data! */
93// const Data &data() const { return mData; }
94
95 const Bstr &stateFilePath() const;
96
97 ComObjPtr<Snapshot> parent() const
98 {
99 return (Snapshot*)mParent;
100 }
101
102 ULONG getGrandChildrenCount();
103
104 ComPtr<SnapshotMachine> getSnapshotMachine();
105
106 Guid getId() const;
107 Bstr getName() const;
108 RTTIMESPEC getTimeStamp() const;
109
110 /**
111 * Shortcut to #dependentChildren().
112 * Do |AutoWriteLock alock (childrenLock());| before acceessing the returned list!
113 */
114// const SnapshotList &children() const { return dependentChildren(); }
115
116// ULONG descendantCount();
117 ComObjPtr<Snapshot> findChildOrSelf(IN_GUID aId);
118 ComObjPtr<Snapshot> findChildOrSelf(IN_BSTR aName);
119
120 void updateSavedStatePaths(const char *aOldPath,
121 const char *aNewPath);
122 void updateSavedStatePathsImpl(const char *aOldPath,
123 const char *aNewPath);
124
125 HRESULT saveSnapshot(settings::Key &aNode, bool aAttrsOnly);
126 HRESULT saveSnapshotImpl(settings::Key &aNode, bool aAttrsOnly);
127
128 // for VirtualBoxSupportErrorInfoImpl
129 static const wchar_t *getComponentName()
130 {
131 return L"Snapshot";
132 }
133
134private:
135
136 /** weak VirtualBox parent */
137 const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
138
139 ComObjPtr<Snapshot, ComWeakRef> mParent;
140
141 struct Data; // opaque, defined in SnapshotImpl.cpp
142 Data *m;
143};
144
145#endif // ____H_SNAPSHOTIMPL
146
147/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette