VirtualBox

Ignore:
Timestamp:
Jan 15, 2010 1:27:16 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56658
Message:

Main: cleanup: get rid of VirtualBoxBaseProto, move AutoCaller*/*Span* classes out of VirtualBoxBaseProto class scope and into separate header; move CombinedProgress into separate header (it's only used by Console any more)

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ProgressCombinedImpl.h

    r25855 r25859  
    66
    77/*
    8  * Copyright (C) 2006-2009 Sun Microsystems, Inc.
     8 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    99 *
    1010 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121 */
    2222
    23 #ifndef ____H_PROGRESSIMPL
    24 #define ____H_PROGRESSIMPL
     23#ifndef ____H_PROGRESSCOMBINEDIMPL
     24#define ____H_PROGRESSCOMBINEDIMPL
    2525
    26 #include "VirtualBoxBase.h"
    27 
    28 #include <VBox/com/SupportErrorInfo.h>
    29 
    30 #include <iprt/semaphore.h>
     26#include "ProgressImpl.h"
     27#include "AutoCaller.h"
    3128
    3229#include <vector>
    33 
    34 class VirtualBox;
    35 
    36 ////////////////////////////////////////////////////////////////////////////////
    37 
    38 /**
    39  * Base component class for progress objects.
    40  */
    41 class ATL_NO_VTABLE ProgressBase :
    42     public VirtualBoxBase,
    43     public com::SupportErrorInfoBase,
    44     public VirtualBoxSupportTranslation<ProgressBase>,
    45     VBOX_SCRIPTABLE_IMPL(IProgress)
    46 {
    47 protected:
    48 
    49     VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (ProgressBase)
    50 
    51     DECLARE_EMPTY_CTOR_DTOR (ProgressBase)
    52 
    53     HRESULT FinalConstruct();
    54 
    55     // protected initializer/uninitializer for internal purposes only
    56     HRESULT protectedInit (AutoInitSpan &aAutoInitSpan,
    57 #if !defined (VBOX_COM_INPROC)
    58                   VirtualBox *aParent,
    59 #endif
    60                   IUnknown *aInitiator,
    61                   CBSTR aDescription, OUT_GUID aId = NULL);
    62     HRESULT protectedInit (AutoInitSpan &aAutoInitSpan);
    63     void protectedUninit (AutoUninitSpan &aAutoUninitSpan);
    64 
    65 public:
    66 
    67     // IProgress properties
    68     STDMETHOD(COMGETTER(Id)) (BSTR *aId);
    69     STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
    70     STDMETHOD(COMGETTER(Initiator)) (IUnknown **aInitiator);
    71 
    72     // IProgress properties
    73     STDMETHOD(COMGETTER(Cancelable)) (BOOL *aCancelable);
    74     STDMETHOD(COMGETTER(Percent)) (ULONG *aPercent);
    75     STDMETHOD(COMGETTER(TimeRemaining)) (LONG *aTimeRemaining);
    76     STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
    77     STDMETHOD(COMGETTER(Canceled)) (BOOL *aCanceled);
    78     STDMETHOD(COMGETTER(ResultCode)) (LONG *aResultCode);
    79     STDMETHOD(COMGETTER(ErrorInfo)) (IVirtualBoxErrorInfo **aErrorInfo);
    80     STDMETHOD(COMGETTER(OperationCount)) (ULONG *aOperationCount);
    81     STDMETHOD(COMGETTER(Operation)) (ULONG *aCount);
    82     STDMETHOD(COMGETTER(OperationDescription)) (BSTR *aOperationDescription);
    83     STDMETHOD(COMGETTER(OperationPercent)) (ULONG *aOperationPercent);
    84     STDMETHOD(COMSETTER(Timeout)) (ULONG aTimeout);
    85     STDMETHOD(COMGETTER(Timeout)) (ULONG *aTimeout);
    86 
    87     // public methods only for internal purposes
    88 
    89     static HRESULT setErrorInfoOnThread (IProgress *aProgress);
    90     bool setCancelCallback(void (*pfnCallback)(void *), void *pvUser);
    91 
    92 
    93     // unsafe inline public methods for internal purposes only (ensure there is
    94     // a caller and a read lock before calling them!)
    95 
    96     BOOL getCompleted() const { return mCompleted; }
    97     HRESULT getResultCode() const { return mResultCode; }
    98     double calcTotalPercent();
    99 
    100 protected:
    101     void checkForAutomaticTimeout(void);
    102 
    103 #if !defined (VBOX_COM_INPROC)
    104     /** Weak parent. */
    105     const ComObjPtr<VirtualBox, ComWeakRef> mParent;
    106 #endif
    107 
    108     const ComPtr<IUnknown> mInitiator;
    109 
    110     const Guid mId;
    111     const Bstr mDescription;
    112 
    113     uint64_t m_ullTimestamp;                        // progress object creation timestamp, for ETA computation
    114 
    115     void (*m_pfnCancelCallback)(void *);
    116     void *m_pvCancelUserArg;
    117 
    118     /* The fields below are to be properly initalized by subclasses */
    119 
    120     BOOL mCompleted;
    121     BOOL mCancelable;
    122     BOOL mCanceled;
    123     HRESULT mResultCode;
    124     ComPtr<IVirtualBoxErrorInfo> mErrorInfo;
    125 
    126     ULONG m_cOperations;                            // number of operations (so that progress dialog can display something like 1/3)
    127     ULONG m_ulTotalOperationsWeight;                // sum of weights of all operations, given to constructor
    128 
    129     ULONG m_ulOperationsCompletedWeight;            // summed-up weight of operations that have been completed; initially 0
    130 
    131     ULONG m_ulCurrentOperation;                     // operations counter, incremented with each setNextOperation()
    132     Bstr m_bstrOperationDescription;                // name of current operation; initially from constructor, changed with setNextOperation()
    133     ULONG m_ulCurrentOperationWeight;               // weight of current operation, given to setNextOperation()
    134     ULONG m_ulOperationPercent;                     // percentage of current operation, set with setCurrentOperationProgress()
    135     ULONG m_cMsTimeout;                             /**< Automatic timeout value. 0 means none. */
    136 };
    137 
    138 ////////////////////////////////////////////////////////////////////////////////
    139 
    140 /**
    141  * Normal progress object.
    142  */
    143 class ATL_NO_VTABLE Progress :
    144     public com::SupportErrorInfoDerived<ProgressBase, Progress, IProgress>,
    145     public VirtualBoxSupportTranslation<Progress>
    146 {
    147 
    148 public:
    149 
    150     VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (Progress)
    151 
    152     DECLARE_NOT_AGGREGATABLE (Progress)
    153 
    154     DECLARE_PROTECT_FINAL_CONSTRUCT()
    155 
    156     BEGIN_COM_MAP (Progress)
    157         COM_INTERFACE_ENTRY  (ISupportErrorInfo)
    158         COM_INTERFACE_ENTRY  (IProgress)
    159         COM_INTERFACE_ENTRY2 (IDispatch, IProgress)
    160     END_COM_MAP()
    161 
    162     HRESULT FinalConstruct();
    163     void FinalRelease();
    164 
    165     // public initializer/uninitializer for internal purposes only
    166 
    167     /**
    168      * Simplified constructor for progress objects that have only one
    169      * operation as a task.
    170      * @param aParent
    171      * @param aInitiator
    172      * @param aDescription
    173      * @param aCancelable
    174      * @param aId
    175      * @return
    176      */
    177     HRESULT init(
    178 #if !defined (VBOX_COM_INPROC)
    179                   VirtualBox *aParent,
    180 #endif
    181                   IUnknown *aInitiator,
    182                   CBSTR aDescription,
    183                   BOOL aCancelable,
    184                   OUT_GUID aId = NULL)
    185     {
    186         return init(
    187 #if !defined (VBOX_COM_INPROC)
    188             aParent,
    189 #endif
    190             aInitiator,
    191             aDescription,
    192             aCancelable,
    193             1,      // cOperations
    194             1,      // ulTotalOperationsWeight
    195             aDescription, // bstrFirstOperationDescription
    196             1,      // ulFirstOperationWeight
    197             aId);
    198     }
    199 
    200     /**
    201      * Not quite so simplified constructor for progress objects that have
    202      * more than one operation, but all sub-operations are weighed the same.
    203      * @param aParent
    204      * @param aInitiator
    205      * @param aDescription
    206      * @param aCancelable
    207      * @param cOperations
    208      * @param bstrFirstOperationDescription
    209      * @param aId
    210      * @return
    211      */
    212     HRESULT init(
    213 #if !defined (VBOX_COM_INPROC)
    214                   VirtualBox *aParent,
    215 #endif
    216                   IUnknown *aInitiator,
    217                   CBSTR aDescription, BOOL aCancelable,
    218                   ULONG cOperations,
    219                   CBSTR bstrFirstOperationDescription,
    220                   OUT_GUID aId = NULL)
    221     {
    222         return init(
    223 #if !defined (VBOX_COM_INPROC)
    224             aParent,
    225 #endif
    226             aInitiator,
    227             aDescription,
    228             aCancelable,
    229             cOperations,      // cOperations
    230             cOperations,      // ulTotalOperationsWeight = cOperations
    231             bstrFirstOperationDescription, // bstrFirstOperationDescription
    232             1,      // ulFirstOperationWeight: weigh them all the same
    233             aId);
    234     }
    235 
    236     HRESULT init(
    237 #if !defined (VBOX_COM_INPROC)
    238                   VirtualBox *aParent,
    239 #endif
    240                   IUnknown *aInitiator,
    241                   CBSTR aDescription,
    242                   BOOL aCancelable,
    243                   ULONG cOperations,
    244                   ULONG ulTotalOperationsWeight,
    245                   CBSTR bstrFirstOperationDescription,
    246                   ULONG ulFirstOperationWeight,
    247                   OUT_GUID aId = NULL);
    248 
    249     HRESULT init(BOOL aCancelable,
    250                  ULONG aOperationCount,
    251                  CBSTR aOperationDescription);
    252 
    253     void uninit();
    254 
    255     // IProgress methods
    256     STDMETHOD(WaitForCompletion)(LONG aTimeout);
    257     STDMETHOD(WaitForOperationCompletion)(ULONG aOperation, LONG aTimeout);
    258     STDMETHOD(Cancel)();
    259 
    260     STDMETHOD(SetCurrentOperationProgress)(ULONG aPercent);
    261     STDMETHOD(SetNextOperation)(IN_BSTR bstrNextOperationDescription, ULONG ulNextOperationsWeight);
    262 
    263     // public methods only for internal purposes
    264 
    265     HRESULT setResultCode(HRESULT aResultCode);
    266 
    267     HRESULT notifyComplete(HRESULT aResultCode);
    268     HRESULT notifyComplete(HRESULT aResultCode,
    269                            const GUID &aIID,
    270                            const Bstr &aComponent,
    271                            const char *aText, ...);
    272     bool notifyPointOfNoReturn(void);
    273 
    274     /** For com::SupportErrorInfoImpl. */
    275     static const char *ComponentName() { return "Progress"; }
    276 
    277 private:
    278 
    279     RTSEMEVENTMULTI mCompletedSem;
    280     ULONG mWaitersCount;
    281 };
    282 
    283 ////////////////////////////////////////////////////////////////////////////////
    28430
    28531/**
     
    449195};
    450196
    451 #endif /* ____H_PROGRESSIMPL */
     197#endif /* ____H_PROGRESSCOMBINEDIMPL */
    452198
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette