SnapshotImpl.h revision 537e6c27ec01e6914b4668cc2a70e34b6633ad5f
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync/** @file
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync *
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * VirtualBox COM class implementation
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync/*
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Copyright (C) 2006-2009 Sun Microsystems, Inc.
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync *
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * available from http://www.virtualbox.org. This file is free software;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * General Public License (GPL) as published by the Free Software
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync *
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * additional information or have any questions.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync#ifndef ____H_SNAPSHOTIMPL
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync#define ____H_SNAPSHOTIMPL
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync#include "VirtualBoxBase.h"
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync#include <iprt/time.h>
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncclass SnapshotMachine;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncclass VirtualBox;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncnamespace settings
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync{
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync struct Snapshot;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync}
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncclass ATL_NO_VTABLE Snapshot :
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync public VirtualBoxSupportErrorInfoImpl<Snapshot, ISnapshot>,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync public VirtualBoxSupportTranslation<Snapshot>,
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync public VirtualBoxBase, // WithTypedChildren<Snapshot>,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync VBOX_SCRIPTABLE_IMPL(ISnapshot)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync{
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncpublic:
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync DECLARE_NOT_AGGREGATABLE(Snapshot)
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync BEGIN_COM_MAP(Snapshot)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync COM_INTERFACE_ENTRY (ISnapshot)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync COM_INTERFACE_ENTRY2 (IDispatch, ISnapshot)
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync END_COM_MAP()
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync Snapshot()
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync : m(NULL)
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync { };
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync ~Snapshot()
9040f019271f91b98e1320c0a8c38a42636e3979vboxsync { };
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync HRESULT FinalConstruct();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync void FinalRelease();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // public initializer/uninitializer only for internal purposes
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync HRESULT init(VirtualBox *aVirtualBox,
99be02f9e15a3ca61b6a7c207cc7eb68dbd04817vboxsync const Guid &aId,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const Utf8Str &aName,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const Utf8Str &aDescription,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const RTTIMESPEC &aTimeStamp,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync SnapshotMachine *aMachine,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync Snapshot *aParent);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync void uninit();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync void beginDiscard();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync void deparent();
bbf3d430bae83177ab9ce3097f49d89cc873e7c0vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // ISnapshot properties
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Id)) (BSTR *aId);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Name)) (BSTR *aName);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMSETTER(Name)) (IN_BSTR aName);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMSETTER(Description)) (IN_BSTR aDescription);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(TimeStamp)) (LONG64 *aTimeStamp);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Online)) (BOOL *aOnline);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Machine)) (IMachine **aMachine);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Parent)) (ISnapshot **aParent);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync STDMETHOD(COMGETTER(Children)) (ComSafeArrayOut (ISnapshot *, aChildren));
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // ISnapshot methods
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // public methods only for internal purposes
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /**
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Simple run-time type identification without having to enable C++ RTTI.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * The class IDs are defined in VirtualBoxBase.h.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * @return
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync */
6c90795355c6e59ba82e8e5a58e10d686a6d6e65vboxsync virtual VBoxClsID getClassID() const
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync {
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync return clsidSnapshot;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync }
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync /**
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * Override of the default locking class to be used for validating lock
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync * order with the standard member lock handle.
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync virtual VBoxLockingClass getLockingClass() const
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync {
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync return LOCKCLASS_SNAPSHOTOBJECT;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync }
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const ComObjPtr<Snapshot>& getParent() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const Utf8Str& stateFilePath() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ULONG getChildrenCount();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ULONG getAllChildrenCount();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ULONG getAllChildrenCountImpl();
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const ComObjPtr<SnapshotMachine>& getSnapshotMachine() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync Guid getId() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const Utf8Str& getName() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync RTTIMESPEC getTimeStamp() const;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ComObjPtr<Snapshot> findChildOrSelf(IN_GUID aId);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync ComObjPtr<Snapshot> findChildOrSelf(const Utf8Str &aName);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync void updateSavedStatePaths(const char *aOldPath,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const char *aNewPath);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync void updateSavedStatePathsImpl(const char *aOldPath,
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync const char *aNewPath);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync HRESULT saveSnapshot(settings::Snapshot &data, bool aAttrsOnly);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync HRESULT saveSnapshotImpl(settings::Snapshot &data, bool aAttrsOnly);
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync // for VirtualBoxSupportErrorInfoImpl
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync static const wchar_t *getComponentName()
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync {
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync return L"Snapshot";
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync }
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsyncprivate:
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync struct Data; // opaque, defined in SnapshotImpl.cpp
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync Data *m;
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync};
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync#endif // ____H_SNAPSHOTIMPL
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync/* vi: set tabstop=4 shiftwidth=4 expandtab: */
c1f5ec452b23d55c71e6f07628b84ac5e97cf551vboxsync