ProgressCombinedImpl.h revision 545a02e9eda0fc9d6be6f8513686228283f73627
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * VirtualBox COM class implementation
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * available from http://www.virtualbox.org. This file is free software;
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * additional information or have any questions.
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync * The CombinedProgress class allows to combine several progress objects to a
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * single progress component. This single progress component will treat all
7d6e0aa02bf89fa403a13d5eac18a18b5a79893fvboxsync * operations of individual progress objects as a single sequence of operations
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * that follow each other in the same order as progress objects are passed to
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * the #init() method.
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * Individual progress objects are sequentially combined so that this progress
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * - is cancelable only if all progresses are cancelable.
7d6e0aa02bf89fa403a13d5eac18a18b5a79893fvboxsync * - is canceled once a progress that follows next to successfully completed
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * ones reports it was canceled.
f4db180328f833f9fc9cb07a1a4a0bc948a47afevboxsync * - is completed successfully only after all progresses are completed
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * successfully.
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * - is completed unsuccessfully once a progress that follows next to
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * successfully completed ones reports it was completed unsuccessfully;
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * the result code and error info of the unsuccessful progress
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * will be reported as the result code and error info of this progress.
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * - returns N as the operation number, where N equals to the number of
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * operations in all successfully completed progresses starting from the
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * first one plus the operation number of the next (not yet complete)
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * progress; the operation description of the latter one is reported as
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * the operation description of this progress object.
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * - returns P as the percent value, where P equals to the sum of percents
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * of all successfully completed progresses starting from the
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * first one plus the percent value of the next (not yet complete)
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * progress, normalized to 100%.
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * @note It's the respoisibility of the combined progress object creator to
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * complete individual progresses in the right order: if, let's say, the
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * last progress is completed before all previous ones,
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * #WaitForCompletion(-1) will most likely give 100% CPU load because it
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * will be in a loop calling a method that returns immediately.
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync public com::SupportErrorInfoDerived<ProgressBase, CombinedProgress, IProgress>,
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync public VirtualBoxSupportTranslation<CombinedProgress>
3a109c62545ec1a0ebca5c8c3e5e9b88d3c7b672vboxsync VIRTUALBOXSUPPORTTRANSLATION_OVERRIDE (CombinedProgress)
3a109c62545ec1a0ebca5c8c3e5e9b88d3c7b672vboxsync // public initializer/uninitializer for internal purposes only
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * Initializes the combined progress object given the first and the last
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * normal progress object from the list.
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * @param aParent See ProgressBase::init().
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * @param aInitiator See ProgressBase::init().
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync * @param aDescription See ProgressBase::init().
da41353d6837bbc94e31da46f0698be45c106305vboxsync * @param aFirstProgress Iterator of the first normal progress object.
da41353d6837bbc94e31da46f0698be45c106305vboxsync * @param aSecondProgress Iterator of the last normal progress object.
e1cda3b0b3faa83df2fe0bf69e6938a6e7c4cb20vboxsync * @param aId See ProgressBase::init().
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync InputIterator aFirstProgress, InputIterator aLastProgress,
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync /* Enclose the state transition NotReady->InInit->Ready */
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync mProgresses = ProgressVector (aFirstProgress, aLastProgress);
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync /* Confirm a successful initialization when it's the case */
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync HRESULT protectedInit (AutoInitSpan &aAutoInitSpan,
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync // IProgress properties
7995839c0b791ae2334df998d34dbccac12b3b41vboxsync STDMETHOD(COMGETTER(Completed)) (BOOL *aCompleted);
return E_NOTIMPL;
return E_NOTIMPL;