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.virtualbox.org. 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 |
|
---|
31 | class SnapshotMachine;
|
---|
32 |
|
---|
33 | class ATL_NO_VTABLE Snapshot :
|
---|
34 | public VirtualBoxSupportErrorInfoImpl <Snapshot, ISnapshot>,
|
---|
35 | public VirtualBoxSupportTranslation <Snapshot>,
|
---|
36 | public VirtualBoxBaseWithTypedChildren <Snapshot>,
|
---|
37 | VBOX_SCRIPTABLE_IMPL(ISnapshot)
|
---|
38 | {
|
---|
39 | public:
|
---|
40 |
|
---|
41 | struct Data
|
---|
42 | {
|
---|
43 | Data();
|
---|
44 | ~Data();
|
---|
45 |
|
---|
46 | Guid mId;
|
---|
47 | Bstr mName;
|
---|
48 | Bstr mDescription;
|
---|
49 | RTTIMESPEC mTimeStamp;
|
---|
50 | ComObjPtr <SnapshotMachine> mMachine;
|
---|
51 | };
|
---|
52 |
|
---|
53 | typedef VirtualBoxBaseWithTypedChildren <Snapshot>::DependentChildren
|
---|
54 | 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 | HRESULT FinalConstruct();
|
---|
69 | void FinalRelease();
|
---|
70 |
|
---|
71 | // public initializer/uninitializer only for internal purposes
|
---|
72 | HRESULT init (const Guid &aId, IN_BSTR aName, IN_BSTR aDescription,
|
---|
73 | RTTIMESPEC aTimeStamp, SnapshotMachine *aMachine,
|
---|
74 | Snapshot *aParent);
|
---|
75 | void uninit();
|
---|
76 |
|
---|
77 | void discard();
|
---|
78 |
|
---|
79 | // ISnapshot properties
|
---|
80 | STDMETHOD(COMGETTER(Id)) (BSTR *aId);
|
---|
81 | STDMETHOD(COMGETTER(Name)) (BSTR *aName);
|
---|
82 | STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
|
---|
83 | STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
|
---|
84 | STDMETHOD(COMSETTER(Description)) (IN_BSTR aDescription);
|
---|
85 | STDMETHOD(COMGETTER(TimeStamp)) (LONG64 *aTimeStamp);
|
---|
86 | STDMETHOD(COMGETTER(Online)) (BOOL *aOnline);
|
---|
87 | STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
|
---|
88 | STDMETHOD(COMGETTER(Parent)) (ISnapshot **aParent);
|
---|
89 | STDMETHOD(COMGETTER(Children)) (ComSafeArrayOut (ISnapshot *, aChildren));
|
---|
90 |
|
---|
91 | // ISnapshot methods
|
---|
92 |
|
---|
93 | // public methods only for internal purposes
|
---|
94 |
|
---|
95 | /** Do |AutoWriteLock alock (this);| before acceessing the returned data! */
|
---|
96 | const Data &data() const { return mData; }
|
---|
97 |
|
---|
98 | const Bstr &stateFilePath() const;
|
---|
99 |
|
---|
100 | ComObjPtr <Snapshot> parent() const { return (Snapshot *) mParent; }
|
---|
101 |
|
---|
102 | /** Shortcut to #dependentChildrenLock() */
|
---|
103 | RWLockHandle *childrenLock() const { return dependentChildrenLock(); }
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * Shortcut to #dependentChildren().
|
---|
107 | * Do |AutoWriteLock alock (childrenLock());| before acceessing the returned list!
|
---|
108 | */
|
---|
109 | const SnapshotList &children() const { return dependentChildren(); }
|
---|
110 |
|
---|
111 | ULONG descendantCount();
|
---|
112 | ComObjPtr <Snapshot> findChildOrSelf (IN_GUID aId);
|
---|
113 | ComObjPtr <Snapshot> findChildOrSelf (IN_BSTR aName);
|
---|
114 |
|
---|
115 | void updateSavedStatePaths (const char *aOldPath, const char *aNewPath);
|
---|
116 |
|
---|
117 | // for VirtualBoxSupportErrorInfoImpl
|
---|
118 | static const wchar_t *getComponentName() { return L"Snapshot"; }
|
---|
119 |
|
---|
120 | private:
|
---|
121 |
|
---|
122 | ComObjPtr <Snapshot, ComWeakRef> mParent;
|
---|
123 |
|
---|
124 | Data mData;
|
---|
125 | };
|
---|
126 |
|
---|
127 | #endif // ____H_SNAPSHOTIMPL
|
---|
128 |
|
---|
129 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|