ProgressImpl.h revision 26d2a42f095ded346df2e41cc4837cb426b4753a
c936b605260fac01308e3f63b869f401321c52b3vboxsync/* $Id$ */
c936b605260fac01308e3f63b869f401321c52b3vboxsync/** @file
c936b605260fac01308e3f63b869f401321c52b3vboxsync *
c936b605260fac01308e3f63b869f401321c52b3vboxsync * VirtualBox COM class implementation
c936b605260fac01308e3f63b869f401321c52b3vboxsync */
c936b605260fac01308e3f63b869f401321c52b3vboxsync
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync/*
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Copyright (C) 2006-2008 Sun Microsystems, Inc.
c936b605260fac01308e3f63b869f401321c52b3vboxsync *
c936b605260fac01308e3f63b869f401321c52b3vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
c936b605260fac01308e3f63b869f401321c52b3vboxsync * available from http://www.virtualbox.org. This file is free software;
c936b605260fac01308e3f63b869f401321c52b3vboxsync * you can redistribute it and/or modify it under the terms of the GNU
c936b605260fac01308e3f63b869f401321c52b3vboxsync * General Public License (GPL) as published by the Free Software
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
c936b605260fac01308e3f63b869f401321c52b3vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
c936b605260fac01308e3f63b869f401321c52b3vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
c936b605260fac01308e3f63b869f401321c52b3vboxsync *
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
c936b605260fac01308e3f63b869f401321c52b3vboxsync * additional information or have any questions.
c936b605260fac01308e3f63b869f401321c52b3vboxsync */
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync#ifndef ____H_PROGRESSIMPL
c936b605260fac01308e3f63b869f401321c52b3vboxsync#define ____H_PROGRESSIMPL
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync#include "VirtualBoxBase.h"
c936b605260fac01308e3f63b869f401321c52b3vboxsync#include "Collection.h"
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync#include <VBox/com/SupportErrorInfo.h>
c936b605260fac01308e3f63b869f401321c52b3vboxsync
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsync#include <iprt/semaphore.h>
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync#include <vector>
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsyncclass VirtualBox;
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync////////////////////////////////////////////////////////////////////////////////
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync/**
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Base component class for progress objects.
c936b605260fac01308e3f63b869f401321c52b3vboxsync */
c936b605260fac01308e3f63b869f401321c52b3vboxsyncclass ATL_NO_VTABLE ProgressBase :
c936b605260fac01308e3f63b869f401321c52b3vboxsync public VirtualBoxBaseNEXT,
c936b605260fac01308e3f63b869f401321c52b3vboxsync public com::SupportErrorInfoBase,
c936b605260fac01308e3f63b869f401321c52b3vboxsync public VirtualBoxSupportTranslation <ProgressBase>,
c936b605260fac01308e3f63b869f401321c52b3vboxsync public IProgress
c936b605260fac01308e3f63b869f401321c52b3vboxsync{
c936b605260fac01308e3f63b869f401321c52b3vboxsyncprotected:
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ProgressBase)
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync DECLARE_EMPTY_CTOR_DTOR (ProgressBase)
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT FinalConstruct();
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // protected initializer/uninitializer for internal purposes only
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT protectedInit (AutoInitSpan &aAutoInitSpan,
c936b605260fac01308e3f63b869f401321c52b3vboxsync#if !defined (VBOX_COM_INPROC)
c936b605260fac01308e3f63b869f401321c52b3vboxsync VirtualBox *aParent,
c936b605260fac01308e3f63b869f401321c52b3vboxsync#endif
c936b605260fac01308e3f63b869f401321c52b3vboxsync IUnknown *aInitiator,
c936b605260fac01308e3f63b869f401321c52b3vboxsync const BSTR aDescription, GUIDPARAMOUT aId = NULL);
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT protectedInit (AutoInitSpan &aAutoInitSpan);
c936b605260fac01308e3f63b869f401321c52b3vboxsync void protectedUninit (AutoUninitSpan &aAutoUninitSpan);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsyncpublic:
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // IProgress properties
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Id)) (GUIDPARAMOUT aId);
9246d7f57490c7fa3f8344fe370066568ba2121avboxsync STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Initiator)) (IUnknown **aInitiator);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // IProgress properties
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Cancelable)) (BOOL *aCancelable);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Percent)) (LONG *aPercent);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Canceled)) (BOOL *aCanceled);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(ResultCode)) (HRESULT *aResultCode);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(ErrorInfo)) (IVirtualBoxErrorInfo **aErrorInfo);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(OperationCount)) (ULONG *aOperationCount);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(Operation)) (ULONG *aCount);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(COMGETTER(OperationPercent)) (LONG *aOperationPercent);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // public methods only for internal purposes
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync static HRESULT setErrorInfoOnThread (IProgress *aProgress);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // unsafe inline public methods for internal purposes only (ensure there is
c936b605260fac01308e3f63b869f401321c52b3vboxsync // a caller and a read lock before calling them!)
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync BOOL completed() const { return mCompleted; }
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT resultCode() const { return mResultCode; }
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsyncprotected:
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync#if !defined (VBOX_COM_INPROC)
c936b605260fac01308e3f63b869f401321c52b3vboxsync /** Weak parent. */
c936b605260fac01308e3f63b869f401321c52b3vboxsync const ComObjPtr <VirtualBox, ComWeakRef> mParent;
c936b605260fac01308e3f63b869f401321c52b3vboxsync#endif
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync const ComPtr <IUnknown> mInitiator;
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync const Guid mId;
c936b605260fac01308e3f63b869f401321c52b3vboxsync const Bstr mDescription;
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync /* The fields below are to be properly initalized by subclasses */
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync BOOL mCompleted;
c936b605260fac01308e3f63b869f401321c52b3vboxsync BOOL mCancelable;
c936b605260fac01308e3f63b869f401321c52b3vboxsync BOOL mCanceled;
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT mResultCode;
c936b605260fac01308e3f63b869f401321c52b3vboxsync ComPtr <IVirtualBoxErrorInfo> mErrorInfo;
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync ULONG mOperationCount;
c936b605260fac01308e3f63b869f401321c52b3vboxsync ULONG mOperation;
c936b605260fac01308e3f63b869f401321c52b3vboxsync Bstr mOperationDescription;
c936b605260fac01308e3f63b869f401321c52b3vboxsync LONG mOperationPercent;
c936b605260fac01308e3f63b869f401321c52b3vboxsync};
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync////////////////////////////////////////////////////////////////////////////////
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync/**
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Normal progress object.
c936b605260fac01308e3f63b869f401321c52b3vboxsync */
c936b605260fac01308e3f63b869f401321c52b3vboxsyncclass ATL_NO_VTABLE Progress :
c936b605260fac01308e3f63b869f401321c52b3vboxsync public com::SupportErrorInfoDerived <ProgressBase, Progress, IProgress>,
c936b605260fac01308e3f63b869f401321c52b3vboxsync public VirtualBoxSupportTranslation <Progress>
c936b605260fac01308e3f63b869f401321c52b3vboxsync{
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsyncpublic:
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (Progress)
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync DECLARE_NOT_AGGREGATABLE (Progress)
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync DECLARE_PROTECT_FINAL_CONSTRUCT()
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync BEGIN_COM_MAP (Progress)
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync COM_INTERFACE_ENTRY (ISupportErrorInfo)
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync COM_INTERFACE_ENTRY (IProgress)
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync END_COM_MAP()
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync NS_DECL_ISUPPORTS
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT FinalConstruct();
c936b605260fac01308e3f63b869f401321c52b3vboxsync void FinalRelease();
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // public initializer/uninitializer for internal purposes only
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT init (
c936b605260fac01308e3f63b869f401321c52b3vboxsync#if !defined (VBOX_COM_INPROC)
c936b605260fac01308e3f63b869f401321c52b3vboxsync VirtualBox *aParent,
c936b605260fac01308e3f63b869f401321c52b3vboxsync#endif
c936b605260fac01308e3f63b869f401321c52b3vboxsync IUnknown *aInitiator,
c936b605260fac01308e3f63b869f401321c52b3vboxsync const BSTR aDescription, BOOL aCancelable,
c936b605260fac01308e3f63b869f401321c52b3vboxsync GUIDPARAMOUT aId = NULL)
c936b605260fac01308e3f63b869f401321c52b3vboxsync {
c936b605260fac01308e3f63b869f401321c52b3vboxsync return init (
c936b605260fac01308e3f63b869f401321c52b3vboxsync#if !defined (VBOX_COM_INPROC)
c936b605260fac01308e3f63b869f401321c52b3vboxsync aParent,
c936b605260fac01308e3f63b869f401321c52b3vboxsync#endif
c936b605260fac01308e3f63b869f401321c52b3vboxsync aInitiator, aDescription, aCancelable, 1, aDescription, aId);
c936b605260fac01308e3f63b869f401321c52b3vboxsync }
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT init (
c936b605260fac01308e3f63b869f401321c52b3vboxsync#if !defined (VBOX_COM_INPROC)
c936b605260fac01308e3f63b869f401321c52b3vboxsync VirtualBox *aParent,
c936b605260fac01308e3f63b869f401321c52b3vboxsync#endif
c936b605260fac01308e3f63b869f401321c52b3vboxsync IUnknown *aInitiator,
c936b605260fac01308e3f63b869f401321c52b3vboxsync const BSTR aDescription, BOOL aCancelable,
c936b605260fac01308e3f63b869f401321c52b3vboxsync ULONG aOperationCount, const BSTR aOperationDescription,
c936b605260fac01308e3f63b869f401321c52b3vboxsync GUIDPARAMOUT aId = NULL);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT init (BOOL aCancelable, ULONG aOperationCount,
c936b605260fac01308e3f63b869f401321c52b3vboxsync const BSTR aOperationDescription);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync void uninit();
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // IProgress methods
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(WaitForCompletion) (LONG aTimeout);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(WaitForOperationCompletion) (ULONG aOperation, LONG aTimeout);
c936b605260fac01308e3f63b869f401321c52b3vboxsync STDMETHOD(Cancel)();
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync // public methods only for internal purposes
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT notifyProgress (LONG aPercent);
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT advanceOperation (const BSTR aOperationDescription);
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT notifyComplete (HRESULT aResultCode);
c936b605260fac01308e3f63b869f401321c52b3vboxsync HRESULT notifyComplete (HRESULT aResultCode, const GUID &aIID,
c936b605260fac01308e3f63b869f401321c52b3vboxsync const Bstr &aComponent,
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync const char *aText, ...);
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync HRESULT notifyCompleteBstr (HRESULT aResultCode, const GUID &aIID,
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync const Bstr &aComponent, const Bstr &aText);
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync /** For com::SupportErrorInfoImpl. */
90e8b000bdf708e8465e9c2cd7ecf1339c27c4aavboxsync static const char *ComponentName() { return "Progress"; }
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsyncprivate:
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync RTSEMEVENTMULTI mCompletedSem;
c936b605260fac01308e3f63b869f401321c52b3vboxsync ULONG mWaitersCount;
c936b605260fac01308e3f63b869f401321c52b3vboxsync};
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync////////////////////////////////////////////////////////////////////////////////
c936b605260fac01308e3f63b869f401321c52b3vboxsync
c936b605260fac01308e3f63b869f401321c52b3vboxsync/**
c936b605260fac01308e3f63b869f401321c52b3vboxsync * The CombinedProgress class allows to combine several progress objects to a
c936b605260fac01308e3f63b869f401321c52b3vboxsync * single progress component. This single progress component will treat all
c936b605260fac01308e3f63b869f401321c52b3vboxsync * operations of individual progress objects as a single sequence of operations
c936b605260fac01308e3f63b869f401321c52b3vboxsync * that follow each other in the same order as progress objects are passed to
c936b605260fac01308e3f63b869f401321c52b3vboxsync * the #init() method.
c936b605260fac01308e3f63b869f401321c52b3vboxsync *
c936b605260fac01308e3f63b869f401321c52b3vboxsync * Individual progress objects are sequentially combined so that this progress
c936b605260fac01308e3f63b869f401321c52b3vboxsync * object:
c936b605260fac01308e3f63b869f401321c52b3vboxsync *
c936b605260fac01308e3f63b869f401321c52b3vboxsync * - is cancelable only if all progresses are cancelable.
c936b605260fac01308e3f63b869f401321c52b3vboxsync * - is canceled once a progress that follows next to successfully completed
* ones reports it was canceled.
* - is completed successfully only after all progresses are completed
* successfully.
* - is completed unsuccessfully once a progress that follows next to
* successfully completed ones reports it was completed unsuccessfully;
* the result code and error info of the unsuccessful progress
* will be reported as the result code and error info of this progress.
* - returns N as the operation number, where N equals to the number of
* operations in all successfully completed progresses starting from the
* first one plus the operation number of the next (not yet complete)
* progress; the operation description of the latter one is reported as
* the operation description of this progress object.
* - returns P as the percent value, where P equals to the sum of percents
* of all successfully completed progresses starting from the
* first one plus the percent value of the next (not yet complete)
* progress, normalized to 100%.
*
* @note It's the respoisibility of the combined progress object creator to
* complete individual progresses in the right order: if, let's say, the
* last progress is completed before all previous ones,
* #WaitForCompletion(-1) will most likely give 100% CPU load because it
* will be in a loop calling a method that returns immediately.
*/
class ATL_NO_VTABLE CombinedProgress :
public com::SupportErrorInfoDerived <ProgressBase, CombinedProgress, IProgress>,
public VirtualBoxSupportTranslation <CombinedProgress>
{
public:
VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (CombinedProgress)
DECLARE_NOT_AGGREGATABLE (CombinedProgress)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP (CombinedProgress)
COM_INTERFACE_ENTRY (ISupportErrorInfo)
COM_INTERFACE_ENTRY (IProgress)
END_COM_MAP()
NS_DECL_ISUPPORTS
HRESULT FinalConstruct();
void FinalRelease();
// public initializer/uninitializer for internal purposes only
HRESULT init (
#if !defined (VBOX_COM_INPROC)
VirtualBox *aParent,
#endif
IUnknown *aInitiator,
const BSTR aDescription,
IProgress *aProgress1, IProgress *aProgress2,
GUIDPARAMOUT aId = NULL);
/**
* Initializes the combined progress object given the first and the last
* normal progress object from the list.
*
* @param aParent See ProgressBase::init().
* @param aInitiator See ProgressBase::init().
* @param aDescription See ProgressBase::init().
* @param aFirstProgress Iterator of the first normal progress object.
* @param aSecondProgress Iterator of the last normal progress object.
* @param aId See ProgressBase::init().
*/
template <typename InputIterator>
HRESULT init (
#if !defined (VBOX_COM_INPROC)
VirtualBox *aParent,
#endif
IUnknown *aInitiator,
const BSTR aDescription,
InputIterator aFirstProgress, InputIterator aLastProgress,
GUIDPARAMOUT aId = NULL)
{
/* Enclose the state transition NotReady->InInit->Ready */
AutoInitSpan autoInitSpan (this);
AssertReturn (autoInitSpan.isOk(), E_FAIL);
mProgresses = ProgressVector (aFirstProgress, aLastProgress);
HRESULT rc = protectedInit (autoInitSpan,
#if !defined (VBOX_COM_INPROC)
aParent,
#endif
aInitiator, aDescription, aId);
/* Confirm a successful initialization when it's the case */
if (SUCCEEDED (rc))
autoInitSpan.setSucceeded();
return rc;
}
protected:
HRESULT protectedInit (AutoInitSpan &aAutoInitSpan,
#if !defined (VBOX_COM_INPROC)
VirtualBox *aParent,
#endif
IUnknown *aInitiator,
const BSTR aDescription, GUIDPARAMOUT aId);
public:
void uninit();
// IProgress properties
STDMETHOD(COMGETTER(Percent)) (LONG *aPercent);
STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
STDMETHOD(COMGETTER(Canceled)) (BOOL *aCanceled);
STDMETHOD(COMGETTER(ResultCode)) (HRESULT *aResultCode);
STDMETHOD(COMGETTER(ErrorInfo)) (IVirtualBoxErrorInfo **aErrorInfo);
STDMETHOD(COMGETTER(Operation)) (ULONG *aCount);
STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
STDMETHOD(COMGETTER(OperationPercent)) (LONG *aOperationPercent);
// IProgress methods
STDMETHOD(WaitForCompletion) (LONG aTimeout);
STDMETHOD(WaitForOperationCompletion) (ULONG aOperation, LONG aTimeout);
STDMETHOD(Cancel)();
// public methods only for internal purposes
/** For com::SupportErrorInfoImpl. */
static const char *ComponentName() { return "CombinedProgress"; }
private:
HRESULT checkProgress();
typedef std::vector <ComPtr <IProgress> > ProgressVector;
ProgressVector mProgresses;
size_t mProgress;
ULONG mCompletedOperations;
};
COM_DECL_READONLY_ENUM_AND_COLLECTION_AS (Progress, IProgress)
#endif /* ____H_PROGRESSIMPL */