VirtualBox

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

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

Main: cleanup: merge VirtualBoxBase{WithTypedChildren}NEXT onto VirtualBoxBase{WithTypedChildren}, adjust Host and Snapshot implementations according to new parents (new locking scheme)

  • 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
29#include <list>
30
31class SnapshotMachine;
32class VirtualBox;
33
34class ATL_NO_VTABLE Snapshot :
35 public VirtualBoxSupportErrorInfoImpl<Snapshot, ISnapshot>,
36 public VirtualBoxSupportTranslation<Snapshot>,
37 public VirtualBoxBaseWithTypedChildren<Snapshot>,
38 VBOX_SCRIPTABLE_IMPL(ISnapshot)
39{
40public:
41
42 struct Data
43 {
44 Data();
45 ~Data();
46
47 Guid mId;
48 Bstr mName;
49 Bstr mDescription;
50 RTTIMESPEC mTimeStamp;
51 ComObjPtr <SnapshotMachine> mMachine;
52 };
53
54 typedef VirtualBoxBaseWithTypedChildren<Snapshot>::DependentChildren SnapshotList;
55
56 DECLARE_NOT_AGGREGATABLE(Snapshot)
57
58 DECLARE_PROTECT_FINAL_CONSTRUCT()
59
60 BEGIN_COM_MAP(Snapshot)
61 COM_INTERFACE_ENTRY (ISupportErrorInfo)
62 COM_INTERFACE_ENTRY (ISnapshot)
63 COM_INTERFACE_ENTRY2 (IDispatch, ISnapshot)
64 END_COM_MAP()
65
66 NS_DECL_ISUPPORTS
67
68 Snapshot()
69 { };
70 ~Snapshot()
71 { };
72
73 HRESULT FinalConstruct();
74 void FinalRelease();
75
76 // public initializer/uninitializer only for internal purposes
77 HRESULT init(VirtualBox *aVirtualBox,
78 const Guid &aId,
79 IN_BSTR aName,
80 IN_BSTR aDescription,
81 RTTIMESPEC aTimeStamp,
82 SnapshotMachine *aMachine,
83 Snapshot *aParent);
84 void uninit();
85
86 void discard();
87
88 // ISnapshot properties
89 STDMETHOD(COMGETTER(Id)) (BSTR *aId);
90 STDMETHOD(COMGETTER(Name)) (BSTR *aName);
91 STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
92 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
93 STDMETHOD(COMSETTER(Description)) (IN_BSTR aDescription);
94 STDMETHOD(COMGETTER(TimeStamp)) (LONG64 *aTimeStamp);
95 STDMETHOD(COMGETTER(Online)) (BOOL *aOnline);
96 STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
97 STDMETHOD(COMGETTER(Parent)) (ISnapshot **aParent);
98 STDMETHOD(COMGETTER(Children)) (ComSafeArrayOut (ISnapshot *, aChildren));
99
100 // ISnapshot methods
101
102 // public methods only for internal purposes
103
104 /** Do |AutoWriteLock alock (this);| before acceessing the returned data! */
105 const Data &data() const { return mData; }
106
107 const Bstr &stateFilePath() const;
108
109 ComObjPtr <Snapshot> parent() const { return (Snapshot *) mParent; }
110
111 /**
112 * Shortcut to #dependentChildren().
113 * Do |AutoWriteLock alock (childrenLock());| before acceessing the returned list!
114 */
115 const SnapshotList &children() const { return dependentChildren(); }
116
117 ULONG descendantCount();
118 ComObjPtr <Snapshot> findChildOrSelf (IN_GUID aId);
119 ComObjPtr <Snapshot> findChildOrSelf (IN_BSTR aName);
120
121 void updateSavedStatePaths (const char *aOldPath, const char *aNewPath);
122
123 // for VirtualBoxSupportErrorInfoImpl
124 static const wchar_t *getComponentName() { return L"Snapshot"; }
125
126 RWLockHandle *treeLock();
127 RWLockHandle *childrenLock();
128
129private:
130
131 /** weak VirtualBox parent */
132 const ComObjPtr<VirtualBox, ComWeakRef> mVirtualBox;
133
134 ComObjPtr<Snapshot, ComWeakRef> mParent;
135
136 Data mData;
137};
138
139#endif // ____H_SNAPSHOTIMPL
140
141/* 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