ProgressImpl.h revision c663b1d0961e81d772030d918e3b186ea6d93774
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * VirtualBox COM class implementation
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Copyright (C) 2006-2010 Oracle Corporation
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * available from http://www.virtualbox.org. This file is free software;
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * General Public License (GPL) as published by the Free Software
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync////////////////////////////////////////////////////////////////////////////////
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Base component class for progress objects.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ProgressBase)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // protected initializer/uninitializer for internal purposes only
b2640405e06105d868b5fc8f7b676bb680884380vboxsync HRESULT protectedInit(AutoInitSpan &aAutoInitSpan);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void protectedUninit(AutoUninitSpan &aAutoUninitSpan);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // IProgress properties
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Initiator)) (IUnknown **aInitiator);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // IProgress properties
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Cancelable)) (BOOL *aCancelable);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(TimeRemaining)) (LONG *aTimeRemaining);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(ResultCode)) (LONG *aResultCode);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(ErrorInfo)) (IVirtualBoxErrorInfo **aErrorInfo);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(OperationCount)) (ULONG *aOperationCount);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(Operation)) (ULONG *aOperation);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // public methods only for internal purposes
b2640405e06105d868b5fc8f7b676bb680884380vboxsync static HRESULT setErrorInfoOnThread (IProgress *aProgress);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync bool setCancelCallback(void (*pfnCallback)(void *), void *pvUser);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // unsafe inline public methods for internal purposes only (ensure there is
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // a caller and a read lock before calling them!)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync HRESULT getResultCode() const { return mResultCode; }
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /** Weak parent. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync uint64_t m_ullTimestamp; // progress object creation timestamp, for ETA computation
b2640405e06105d868b5fc8f7b676bb680884380vboxsync void (*m_pfnCancelCallback)(void *);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /* The fields below are to be properly initalized by subclasses */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_cOperations; // number of operations (so that progress dialog can display something like 1/3)
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_ulTotalOperationsWeight; // sum of weights of all operations, given to constructor
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_ulOperationsCompletedWeight; // summed-up weight of operations that have been completed; initially 0
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_ulCurrentOperation; // operations counter, incremented with each setNextOperation()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync Bstr m_bstrOperationDescription; // name of current operation; initially from constructor, changed with setNextOperation()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_ulCurrentOperationWeight; // weight of current operation, given to setNextOperation()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_ulOperationPercent; // percentage of current operation, set with setCurrentOperationProgress()
b2640405e06105d868b5fc8f7b676bb680884380vboxsync ULONG m_cMsTimeout; /**< Automatic timeout value. 0 means none. */
b2640405e06105d868b5fc8f7b676bb680884380vboxsync////////////////////////////////////////////////////////////////////////////////
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Normal progress object.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync public com::SupportErrorInfoDerived<ProgressBase, Progress, IProgress>,
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync // public initializer/uninitializer for internal purposes only
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * Simplified constructor for progress objects that have only one
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * operation as a task.
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param aParent
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param aInitiator
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param aDescription
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param aCancelable
b2640405e06105d868b5fc8f7b676bb680884380vboxsync * @param aId
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * Not quite so simplified constructor for progress objects that have
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * more than one operation, but all sub-operations are weighed the same.
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param aParent
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param aInitiator
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param aDescription
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param aCancelable
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param cOperations
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param bstrFirstOperationDescription
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync * @param aId
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync cOperations, // ulTotalOperationsWeight = cOperations
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync bstrFirstOperationDescription, // bstrFirstOperationDescription
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync 1, // ulFirstOperationWeight: weigh them all the same
3383321ffc6907012f92f16b26b026908de7fe7fvboxsync // IProgress methods
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);
b2640405e06105d868b5fc8f7b676bb680884380vboxsync // public methods only for internal purposes
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync const char *aText,
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync const char *aText,
b2640405e06105d868b5fc8f7b676bb680884380vboxsync /** For com::SupportErrorInfoImpl. */
0c802efc285bf77b849eaf660a9c18a0e7f62445vboxsync static const char *ComponentName() { return "Progress"; }
083344b49cc7370da15d3cb7e3a9c9cb2d8dfbb0vboxsync#endif /* ____H_PROGRESSIMPL */