[1] | 1 | /** @file
|
---|
| 2 | *
|
---|
| 3 | * VirtualBox COM class implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[8155] | 7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
[1] | 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
|
---|
[5999] | 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.
|
---|
[8155] | 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.
|
---|
[1] | 20 | */
|
---|
| 21 |
|
---|
| 22 | #ifndef ____H_SNAPSHOTIMPL
|
---|
| 23 | #define ____H_SNAPSHOTIMPL
|
---|
| 24 |
|
---|
| 25 | #include "VirtualBoxBase.h"
|
---|
| 26 | #include "Collection.h"
|
---|
| 27 |
|
---|
[6076] | 28 | #include <iprt/time.h>
|
---|
| 29 |
|
---|
[1] | 30 | #include <list>
|
---|
| 31 |
|
---|
| 32 | class SnapshotMachine;
|
---|
| 33 |
|
---|
| 34 | class ATL_NO_VTABLE Snapshot :
|
---|
| 35 | public VirtualBoxSupportErrorInfoImpl <Snapshot, ISnapshot>,
|
---|
| 36 | public VirtualBoxSupportTranslation <Snapshot>,
|
---|
| 37 | public VirtualBoxBaseWithTypedChildren <Snapshot>,
|
---|
| 38 | public ISnapshot
|
---|
| 39 | {
|
---|
| 40 | public:
|
---|
| 41 |
|
---|
| 42 | struct Data
|
---|
| 43 | {
|
---|
| 44 | Data();
|
---|
| 45 | ~Data();
|
---|
| 46 |
|
---|
| 47 | Guid mId;
|
---|
| 48 | Bstr mName;
|
---|
| 49 | Bstr mDescription;
|
---|
[6076] | 50 | RTTIMESPEC mTimeStamp;
|
---|
[1] | 51 | ComObjPtr <SnapshotMachine> mMachine;
|
---|
| 52 | };
|
---|
| 53 |
|
---|
| 54 | typedef VirtualBoxBaseWithTypedChildren <Snapshot>::DependentChildren
|
---|
| 55 | SnapshotList;
|
---|
| 56 |
|
---|
| 57 | DECLARE_NOT_AGGREGATABLE(Snapshot)
|
---|
| 58 |
|
---|
| 59 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
| 60 |
|
---|
| 61 | BEGIN_COM_MAP(Snapshot)
|
---|
| 62 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
| 63 | COM_INTERFACE_ENTRY(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
|
---|
[15051] | 72 | HRESULT init (const Guid &aId, IN_BSTR aName, IN_BSTR aDescription,
|
---|
[6076] | 73 | RTTIMESPEC aTimeStamp, SnapshotMachine *aMachine,
|
---|
[1] | 74 | Snapshot *aParent);
|
---|
| 75 | void uninit();
|
---|
| 76 |
|
---|
| 77 | void discard();
|
---|
| 78 |
|
---|
| 79 | // ISnapshot properties
|
---|
[15051] | 80 | STDMETHOD(COMGETTER(Id)) (OUT_GUID aId);
|
---|
[1] | 81 | STDMETHOD(COMGETTER(Name)) (BSTR *aName);
|
---|
[15051] | 82 | STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
|
---|
[1] | 83 | STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
|
---|
[15051] | 84 | STDMETHOD(COMSETTER(Description)) (IN_BSTR aDescription);
|
---|
[1] | 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)) (ISnapshotCollection **aChildren);
|
---|
| 90 |
|
---|
| 91 | // ISnapshot methods
|
---|
| 92 |
|
---|
| 93 | // public methods only for internal purposes
|
---|
| 94 |
|
---|
[8083] | 95 | /** Do |AutoWriteLock alock (this);| before acceessing the returned data! */
|
---|
[1] | 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() */
|
---|
[7992] | 103 | RWLockHandle *childrenLock() const { return dependentChildrenLock(); }
|
---|
[1] | 104 |
|
---|
| 105 | /**
|
---|
| 106 | * Shortcut to #dependentChildren().
|
---|
[8083] | 107 | * Do |AutoWriteLock alock (childrenLock());| before acceessing the returned list!
|
---|
[1] | 108 | */
|
---|
| 109 | const SnapshotList &children() const { return dependentChildren(); }
|
---|
| 110 |
|
---|
| 111 | ULONG descendantCount();
|
---|
[15051] | 112 | ComObjPtr <Snapshot> findChildOrSelf (IN_GUID aId);
|
---|
| 113 | ComObjPtr <Snapshot> findChildOrSelf (IN_BSTR aName);
|
---|
[1] | 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 | COM_DECL_READONLY_ENUM_AND_COLLECTION (Snapshot)
|
---|
| 128 |
|
---|
| 129 | #endif // ____H_SNAPSHOTIMPL
|
---|
| 130 |
|
---|
[14949] | 131 | /* vi: set tabstop=4 shiftwidth=4 expandtab: */
|
---|