ProgressImpl.h revision db61a9b07f69bab11e0039e5d8f78a5819f5d6cb
/* $Id$ */
/** @file
*
* VirtualBox COM class implementation
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ____H_PROGRESSIMPL
#define ____H_PROGRESSIMPL
#include "VirtualBoxBase.h"
#include <iprt/semaphore.h>
////////////////////////////////////////////////////////////////////////////////
/**
* Base component class for progress objects.
*/
{
// VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(ProgressBase, IProgress)
// cannot be added here or Windows will not buuld; as a result, ProgressBase cannot be
// instantiated, but we're not doing that anyway (but only its children)
// protected initializer/uninitializer for internal purposes only
#if !defined (VBOX_COM_INPROC)
#endif
// IProgress properties
// IProgress properties
// public methods only for internal purposes
// unsafe inline public methods for internal purposes only (ensure there is
// a caller and a read lock before calling them!)
double calcTotalPercent();
void checkForAutomaticTimeout(void);
#if !defined (VBOX_COM_INPROC)
/** Weak parent. */
VirtualBox * const mParent;
#endif
const Bstr mDescription;
void (*m_pfnCancelCallback)(void *);
void *m_pvCancelUserArg;
/* The fields below are to be properly initalized by subclasses */
ULONG m_cOperations; // number of operations (so that progress dialog can display something like 1/3)
ULONG m_ulOperationsCompletedWeight; // summed-up weight of operations that have been completed; initially 0
Bstr m_bstrOperationDescription; // name of current operation; initially from constructor, changed with setNextOperation()
ULONG m_ulOperationPercent; // percentage of current operation, set with setCurrentOperationProgress()
};
////////////////////////////////////////////////////////////////////////////////
/**
* Normal progress object.
*/
{
void FinalRelease();
// public initializer/uninitializer for internal purposes only
/**
* Simplified constructor for progress objects that have only one
* operation as a task.
* @param aParent
* @param aInitiator
* @param aDescription
* @param aCancelable
* @param aId
* @return
*/
#if !defined (VBOX_COM_INPROC)
#endif
{
return init(
#if !defined (VBOX_COM_INPROC)
#endif
1, // cOperations
1, // ulTotalOperationsWeight
aDescription, // bstrFirstOperationDescription
1, // ulFirstOperationWeight
aId);
}
/**
* Not quite so simplified constructor for progress objects that have
* more than one operation, but all sub-operations are weighed the same.
* @param aParent
* @param aInitiator
* @param aDescription
* @param aCancelable
* @param cOperations
* @param bstrFirstOperationDescription
* @param aId
* @return
*/
#if !defined (VBOX_COM_INPROC)
#endif
{
return init(
#if !defined (VBOX_COM_INPROC)
#endif
cOperations, // cOperations
cOperations, // ulTotalOperationsWeight = cOperations
bstrFirstOperationDescription, // bstrFirstOperationDescription
1, // ulFirstOperationWeight: weigh them all the same
aId);
}
#if !defined (VBOX_COM_INPROC)
#endif
void uninit();
// IProgress methods
// public methods only for internal purposes
const char *pcszComponent,
const char *aText,
...);
const char *pcszComponent,
const char *aText,
bool notifyPointOfNoReturn(void);
};
#endif /* ____H_PROGRESSIMPL */