1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #ifndef ____H_SNAPSHOTIMPL
|
---|
19 | #define ____H_SNAPSHOTIMPL
|
---|
20 |
|
---|
21 | #include "VirtualBoxBase.h"
|
---|
22 | #include "Collection.h"
|
---|
23 |
|
---|
24 | #include <list>
|
---|
25 |
|
---|
26 | class SnapshotMachine;
|
---|
27 |
|
---|
28 | class ATL_NO_VTABLE Snapshot :
|
---|
29 | public VirtualBoxSupportErrorInfoImpl <Snapshot, ISnapshot>,
|
---|
30 | public VirtualBoxSupportTranslation <Snapshot>,
|
---|
31 | public VirtualBoxBaseWithTypedChildren <Snapshot>,
|
---|
32 | public ISnapshot
|
---|
33 | {
|
---|
34 | public:
|
---|
35 |
|
---|
36 | struct Data
|
---|
37 | {
|
---|
38 | Data();
|
---|
39 | ~Data();
|
---|
40 |
|
---|
41 | Guid mId;
|
---|
42 | Bstr mName;
|
---|
43 | Bstr mDescription;
|
---|
44 | LONG64 mTimeStamp;
|
---|
45 | ComObjPtr <SnapshotMachine> mMachine;
|
---|
46 | };
|
---|
47 |
|
---|
48 | typedef VirtualBoxBaseWithTypedChildren <Snapshot>::DependentChildren
|
---|
49 | SnapshotList;
|
---|
50 |
|
---|
51 | DECLARE_NOT_AGGREGATABLE(Snapshot)
|
---|
52 |
|
---|
53 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
54 |
|
---|
55 | BEGIN_COM_MAP(Snapshot)
|
---|
56 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
57 | COM_INTERFACE_ENTRY(ISnapshot)
|
---|
58 | END_COM_MAP()
|
---|
59 |
|
---|
60 | NS_DECL_ISUPPORTS
|
---|
61 |
|
---|
62 | HRESULT FinalConstruct();
|
---|
63 | void FinalRelease();
|
---|
64 |
|
---|
65 | // public initializer/uninitializer only for internal purposes
|
---|
66 | HRESULT init (const Guid &aId, INPTR BSTR aName, INPTR BSTR aDescription,
|
---|
67 | LONG64 aTimeStamp, SnapshotMachine *aMachine,
|
---|
68 | Snapshot *aParent);
|
---|
69 | void uninit();
|
---|
70 |
|
---|
71 | void discard();
|
---|
72 |
|
---|
73 | // ISnapshot properties
|
---|
74 | STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT aId);
|
---|
75 | STDMETHOD(COMGETTER(Name)) (BSTR *aName);
|
---|
76 | STDMETHOD(COMSETTER(Name)) (INPTR BSTR aName);
|
---|
77 | STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
|
---|
78 | STDMETHOD(COMSETTER(Description)) (INPTR BSTR aDescription);
|
---|
79 | STDMETHOD(COMGETTER(TimeStamp)) (LONG64 *aTimeStamp);
|
---|
80 | STDMETHOD(COMGETTER(Online)) (BOOL *aOnline);
|
---|
81 | STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
|
---|
82 | STDMETHOD(COMGETTER(Parent)) (ISnapshot **aParent);
|
---|
83 | STDMETHOD(COMGETTER(Children)) (ISnapshotCollection **aChildren);
|
---|
84 |
|
---|
85 | // ISnapshot methods
|
---|
86 |
|
---|
87 | // public methods only for internal purposes
|
---|
88 |
|
---|
89 | /** Do |AutoLock alock (this);| before acceessing the returned data! */
|
---|
90 | const Data &data() const { return mData; }
|
---|
91 |
|
---|
92 | const Bstr &stateFilePath() const;
|
---|
93 |
|
---|
94 | ComObjPtr <Snapshot> parent() const { return (Snapshot *) mParent; }
|
---|
95 |
|
---|
96 | /** Shortcut to #dependentChildrenLock() */
|
---|
97 | AutoLock::Handle &childrenLock() const { return dependentChildrenLock(); }
|
---|
98 |
|
---|
99 | /**
|
---|
100 | * Shortcut to #dependentChildren().
|
---|
101 | * Do |AutoLock alock (childrenLock());| before acceessing the returned list!
|
---|
102 | */
|
---|
103 | const SnapshotList &children() const { return dependentChildren(); }
|
---|
104 |
|
---|
105 | ULONG descendantCount();
|
---|
106 | ComObjPtr <Snapshot> findChildOrSelf (INPTR GUIDPARAM aId);
|
---|
107 | ComObjPtr <Snapshot> findChildOrSelf (INPTR BSTR aName);
|
---|
108 |
|
---|
109 | void updateSavedStatePaths (const char *aOldPath, const char *aNewPath);
|
---|
110 |
|
---|
111 | // for VirtualBoxSupportErrorInfoImpl
|
---|
112 | static const wchar_t *getComponentName() { return L"Snapshot"; }
|
---|
113 |
|
---|
114 | private:
|
---|
115 |
|
---|
116 | ComObjPtr <Snapshot, ComWeakRef> mParent;
|
---|
117 |
|
---|
118 | Data mData;
|
---|
119 | };
|
---|
120 |
|
---|
121 | COM_DECL_READONLY_ENUM_AND_COLLECTION (Snapshot)
|
---|
122 |
|
---|
123 | #endif // ____H_SNAPSHOTIMPL
|
---|
124 |
|
---|