VirtualBox

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

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

Main: snapshots cleanup, documentation, memory leak fix, locking

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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 const Bstr &stateFilePath() const;
93
94 ComObjPtr<Snapshot> parent() const
95 {
96 return (Snapshot*)mParent;
97 }
98
99 ULONG getChildrenCount();
100 ULONG getAllChildrenCount();
101 ULONG getAllChildrenCountImpl();
102
103 ComPtr<SnapshotMachine> getSnapshotMachine();
104
105 Guid getId() const;
106 Bstr getName() const;
107 RTTIMESPEC getTimeStamp() const;
108
109 ComObjPtr<Snapshot> findChildOrSelf(IN_GUID aId);
110 ComObjPtr<Snapshot> findChildOrSelf(IN_BSTR aName);
111
112 void updateSavedStatePaths(const char *aOldPath,
113 const char *aNewPath);
114 void updateSavedStatePathsImpl(const char *aOldPath,
115 const char *aNewPath);
116
117 HRESULT saveSnapshot(settings::Key &aNode, bool aAttrsOnly);
118 HRESULT saveSnapshotImpl(settings::Key &aNode, bool aAttrsOnly);
119
120 // for VirtualBoxSupportErrorInfoImpl
121 static const wchar_t *getComponentName()
122 {
123 return L"Snapshot";
124 }
125
126private:
127
128 /** weak VirtualBox parent */
129 const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
130
131 ComObjPtr<Snapshot, ComWeakRef> mParent;
132
133 struct Data; // opaque, defined in SnapshotImpl.cpp
134 Data *m;
135};
136
137#endif // ____H_SNAPSHOTIMPL
138
139/* 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