| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program is free software: you can redistribute it and/or modify
- ** it under the terms of the GNU General Public License as published by
- ** the Free Software Foundation, either version 3 of the License, or
- ** (at your option) any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU General Public License for more details.
- **
- ** You should have received a copy of the GNU General Public License
- ** along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /******************************************************************************
- *
- * FILE
- * $Archive: /Commando/Code/WWOnline/WaitCondition.cpp $
- *
- * DESCRIPTION
- * This class encapsulates a wait condition.
- *
- * To wait on an event, create a wait condition. Pass the condition, or a
- * set of conditions, to WaitingCondition::Wait_For(). This will block
- * until the conditions are met, the user cancels the wait, or the timeout
- * is reached.
- *
- * PROGRAMMER
- * Steven Clinard
- * $Author: Denzil_l $
- *
- * VERSION INFO
- * $Modtime: 1/11/02 6:20p $
- * $Revision: 13 $
- *
- ******************************************************************************/
- #include "always.h"
- #include "WaitCondition.h"
- #include "WOLString.h"
- #include <WWLib\Win.h>
- #ifdef _MSC_VER
- #pragma warning (push,3)
- #endif
- #include "systimer.h"
- #ifdef _MSC_VER
- #pragma warning (pop)
- #endif
- /******************************************************************************
- *
- * NAME
- * WaitCondition::WaitCondition
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- WaitCondition::WaitCondition()
- {
- }
- /******************************************************************************
- *
- * NAME
- * WaitCondition::~WaitCondition
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- WaitCondition::~WaitCondition()
- {
- }
- /******************************************************************************
- *
- * NAME
- * WaitCondition::WaitFor
- *
- * DESCRIPTION
- * Wait for condition to be satisfied.
- *
- * INPUTS
- * Callback to invoke while waiting.
- * Timeout value in milliseconds
- *
- * RESULT
- * Wait result
- *
- ******************************************************************************/
- WaitCondition::WaitResult WaitCondition::WaitFor(CallbackHook& hook, unsigned long timeout)
- {
- WaitBeginning();
- DWORD startTime = TIMEGETTIME();
- while (GetResult() == Waiting)
- {
- // Yeild time to client callback
- if (hook.DoCallback())
- {
- EndWait(UserCancel, WOLSTRING("WOL_CANCELED"));
- break;
- }
- // Watch for timeout
- if ((TIMEGETTIME() - startTime) > timeout)
- {
- EndWait(TimeOut, WOLSTRING("WOL_TIMEDOUT"));
- }
- }
- return GetResult();
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::Create
- *
- * DESCRIPTION
- * Create a single wait instance
- *
- * INPUTS
- * Text - Text description of wait condition.
- * Timeout - Time to allow for wait condition to complete. If the wait
- * condition exceeds this time then it should be considered an
- * error.
- *
- * RESULT
- * SingleWait - New instance to a single wait condition
- *
- ******************************************************************************/
- RefPtr<SingleWait> SingleWait::Create(const wchar_t* text, unsigned long timeout)
- {
- return new SingleWait(text, timeout);
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::SingleWait
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * Text - Text description of wait condition.
- * Timeout - Time to allow for wait condition to complete. If the wait
- * condition exceeds this time then it should be considered an
- * error.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- SingleWait::SingleWait(const wchar_t* waitText, unsigned long timeout) :
- mWaitText(waitText),
- mEndResult(Waiting),
- mTimeout(timeout)
- {
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::~SingleWait
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- SingleWait::~SingleWait()
- {
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::WaitBeginning
- *
- * DESCRIPTION
- * Begin this wait condition.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SingleWait::WaitBeginning(void)
- {
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::GetResult
- *
- * DESCRIPTION
- * Get the result status of this wait condition.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Result -
- *
- ******************************************************************************/
- WaitCondition::WaitResult SingleWait::GetResult(void)
- {
- return mEndResult;
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::GetResultText
- *
- * DESCRIPTION
- * Get text description of wait result.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Text - Text description of the result of the wait condition.
- *
- ******************************************************************************/
- const wchar_t* SingleWait::GetResultText(void) const
- {
- return mEndText;
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::EndWait
- *
- * DESCRIPTION
- * Terminate the wait condition.
- *
- * INPUTS
- * Result - Reason for ending the wait.
- * Text - Text description of ending
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SingleWait::EndWait(WaitResult result, const wchar_t* endText)
- {
- mEndResult = result;
- mEndText = endText;
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::GetWaitText
- *
- * DESCRIPTION
- * Get wait description text
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Text - Text description of the wait operation.
- *
- ******************************************************************************/
- const wchar_t* SingleWait::GetWaitText(void) const
- {
- return mWaitText;
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::SetWaitText
- *
- * DESCRIPTION
- * Changes the wait text in the dialog.
- *
- * INPUTS
- * New text to display
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SingleWait::SetWaitText(const wchar_t* waitText)
- {
- mWaitText = waitText;
- }
- /******************************************************************************
- *
- * NAME
- * SingleWait::GetTimeout
- *
- * DESCRIPTION
- * Get the time allowed for this wait condition to complete.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Timeout - Timeout time in milliseconds.
- *
- ******************************************************************************/
- unsigned long SingleWait::GetTimeout(void) const
- {
- return mTimeout;
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::Create
- *
- * DESCRIPTION
- * Create an instance of a serialized wait. SerialWait is primarily used
- * to hold other wait conditions that need to be executed in sequence.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Wait - New wait condition
- *
- ******************************************************************************/
- RefPtr<SerialWait> SerialWait::Create(void)
- {
- return new SerialWait;
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::SerialWait
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- SerialWait::SerialWait() :
- mCurrentWait(-1),
- mEndResult(Waiting),
- mStartTime(0)
- {
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::~SerialWait
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- SerialWait::~SerialWait()
- {
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::Add
- *
- * DESCRIPTION
- * Add a wait condition. Wait conditions are processed in the order they
- * are added.
- *
- * INPUTS
- * Wait - Wait condition to add.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SerialWait::Add(const RefPtr<WaitCondition>& wait)
- {
- if (wait.IsValid())
- {
- mWaits.push_back(wait);
- }
- else
- {
- assert(wait.IsValid() && "SerialWait: Invalid wait condition");
- EndWait(Error, L"Invalid wait condition.");
- }
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::RemainingWaits
- *
- * DESCRIPTION
- * Get then number of remaining wait conditions.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Number of waits
- *
- ******************************************************************************/
- int SerialWait::RemainingWaits(void) const
- {
- int count = mWaits.size();
- return (mCurrentWait == -1) ? count :
- (mCurrentWait >= count) ? 0 : (count - mCurrentWait);
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::WaitBeginning
- *
- * DESCRIPTION
- * Begin wait condition
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SerialWait::WaitBeginning(void)
- {
- // WaitBeginning should only be called once.
- if (mCurrentWait != -1)
- {
- assert(mCurrentWait == -1);
- return;
- }
- // Start the first wait condition in the queue.
- mCurrentWait = 0;
- if (mWaits.size() > 0)
- {
- RefPtr<WaitCondition> wait = mWaits[0];
- wait->WaitBeginning();
- }
- mStartTime = TIMEGETTIME();
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::GetResult
- *
- * DESCRIPTION
- * Get the current wait status result.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Result -
- *
- ******************************************************************************/
- WaitCondition::WaitResult SerialWait::GetResult(void)
- {
- // If we are not waiting the we must be done.
- if (mEndResult != Waiting)
- {
- return mEndResult;
- }
- // If there isn't a current wait processing then we must be waiting to begin.
- if (mCurrentWait == -1)
- {
- return Waiting;
- }
- // If all of the wait conditions have completed successfully then the wait
- // condition has been met.
- if ((unsigned)mCurrentWait >= mWaits.size())
- {
- return ConditionMet;
- }
- // Process outstanding waits
- do
- {
- RefPtr<WaitCondition>& wait = mWaits[mCurrentWait];
- // Get the result of the current wait.
- mEndResult = wait->GetResult();
- switch (mEndResult)
- {
- case Error:
- mEndText = wait->GetResultText();
- break;
- // If the current wait has completed successfully then advance to the
- // next wait condition.
- case ConditionMet:
- mEndText = wait->GetResultText();
- ++mCurrentWait;
- if ((unsigned)mCurrentWait < mWaits.size())
- {
- mWaits[mCurrentWait]->WaitBeginning();
- mStartTime = TIMEGETTIME();
- }
- break;
- case Waiting:
- // Check for timeout
- if ((TIMEGETTIME() - mStartTime) > wait->GetTimeout())
- {
- wait->EndWait(TimeOut, WOLSTRING("WOL_TIMEDOUT"));
- EndWait(TimeOut, wait->GetWaitText());
- }
- break;
- default:
- break;
- }
- } while ((mEndResult == ConditionMet) && ((unsigned)mCurrentWait < mWaits.size()));
- return mEndResult;
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::EndWait
- *
- * DESCRIPTION
- * End the wait condition.
- *
- * INPUTS
- * Result - Reason for ending the wait condition.
- * Description - Text description of end.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void SerialWait::EndWait(WaitResult result, const wchar_t* endText)
- {
- mEndResult = result;
- mEndText = endText;
- // End the current wait.
- if ((mCurrentWait >= 0) && ((unsigned)mCurrentWait < mWaits.size()))
- {
- mWaits[mCurrentWait]->EndWait(result, endText);
- }
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::GetResultText
- *
- * DESCRIPTION
- * Get a text description of the wait condition result.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * ResultText
- *
- ******************************************************************************/
- const wchar_t* SerialWait::GetResultText(void) const
- {
- return mEndText;
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::GetWaitText
- *
- * DESCRIPTION
- * Get a text description of the current wait.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- *
- ******************************************************************************/
- const wchar_t* SerialWait::GetWaitText(void) const
- {
- if ((mCurrentWait >= 0) && ((unsigned)mCurrentWait < mWaits.size()))
- {
- return (mWaits[mCurrentWait]->GetWaitText());
- }
- return NULL;
- }
- /******************************************************************************
- *
- * NAME
- * SerialWait::GetTimeout
- *
- * DESCRIPTION
- * Get the timeout for the current wait condition being processed.
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * Timeout
- *
- ******************************************************************************/
- unsigned long SerialWait::GetTimeout(void) const
- {
- if ((mCurrentWait >= 0) && ((unsigned)mCurrentWait < mWaits.size()))
- {
- return (mWaits[mCurrentWait]->GetTimeout());
- }
- return 0;
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::Create
- *
- * DESCRIPTION
- * Create a logical AND wait condition. When this wait condition is begun
- * all the waits will be started at once. When all the waits complete the
- * AND wait condition is finished. If any condition fails then the entire
- * condition fails.
- *
- * INPUTS
- * Text - Text description of this wait condition.
- *
- * RESULT
- * ANDWait - Instance of newly created ANDWait condition.
- *
- ******************************************************************************/
- RefPtr<ANDWait> ANDWait::Create(const wchar_t* waitText)
- {
- return new ANDWait(waitText);
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::ANDWait
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * Text - Text describing the wait condition.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- ANDWait::ANDWait(const wchar_t* waitText) :
- mEndResult(Waiting),
- mWaitText(waitText),
- mMaxTimeout(0)
- {
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::~ANDWait
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- ANDWait::~ANDWait()
- {
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::Add
- *
- * DESCRIPTION
- * Add a wait condition.
- *
- * INPUTS
- * Wait - Wait condition to add.
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void ANDWait::Add(const RefPtr<WaitCondition>& wait)
- {
- if (wait.IsValid())
- {
- mWaits.push_back(wait);
- // The timeout should be the longest of the all the waits
- unsigned long timeout = wait->GetTimeout();
- if (timeout > mMaxTimeout)
- {
- mMaxTimeout = timeout;
- }
- }
- else
- {
- assert(wait.IsValid() && "ORWait: Invalid wait condition");
- EndWait(Error, L"Invalid wait condition.");
- }
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::WaitBeginning
- *
- * DESCRIPTION
- * Begin the wait conditions
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void ANDWait::WaitBeginning(void)
- {
- for (unsigned int index = 0; index < mWaits.size(); index++)
- {
- mWaits[index]->WaitBeginning();
- }
- mStartTime = TIMEGETTIME();
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- WaitCondition::WaitResult ANDWait::GetResult(void)
- {
- if (mEndResult == Waiting)
- {
- unsigned int metConditions = 0;
- unsigned int count = mWaits.size();
- // Get the result of all the wait conditions being processed. If they are
- // all finished then the entire wait finished.
- for (unsigned int index = 0; index < count; ++index)
- {
- RefPtr<WaitCondition>& wait = mWaits[index];
- WaitResult result = wait->GetResult();
- if (ConditionMet == result)
- {
- ++metConditions;
- }
- else if (Waiting != result)
- {
- EndWait(result, wait->GetResultText());
- return result;
- }
- }
- if (metConditions == count)
- {
- EndWait(ConditionMet, GetWaitText());
- }
- else
- {
- // Check for timeout while we are still waiting
- if ((TIMEGETTIME() - mStartTime) > GetTimeout())
- {
- EndWait(TimeOut, WOLSTRING("WOL_TIMEDOUT"));
- }
- }
- }
- return mEndResult;
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::EndWait
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- void ANDWait::EndWait(WaitResult result, const wchar_t* endText)
- {
- mEndResult = result;
- mEndText = endText;
- for (unsigned int index = 0; index < mWaits.size(); ++index)
- {
- mWaits[index]->EndWait(result, L"");
- }
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- const wchar_t* ANDWait::GetResultText(void) const
- {
- return mEndText;
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- const wchar_t* ANDWait::GetWaitText(void) const
- {
- return mWaitText;
- }
- /******************************************************************************
- *
- * NAME
- * ANDWait::
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- *
- ******************************************************************************/
- unsigned long ANDWait::GetTimeout(void) const
- {
- return mMaxTimeout;
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::Create
- *
- * DESCRIPTION
- * Create a OR wait condition. When this wait condition is begun all the
- * waits will be started at once. When any wait completes for any reason
- * the OR wait condition is finished.
- *
- * INPUTS
- * Text - Text description of this wait condition.
- *
- * RESULT
- *
- ******************************************************************************/
- RefPtr<ORWait> ORWait::Create(const wchar_t* waitText)
- {
- return new ORWait(waitText);
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::ORWait
- *
- * DESCRIPTION
- * Constructor
- *
- * INPUTS
- * Text -
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- ORWait::ORWait(const wchar_t* waitText) :
- mEndResult(Waiting),
- mWaitText(waitText),
- mMaxTimeout(0)
- {
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::~ORWait
- *
- * DESCRIPTION
- * Destructor
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- ORWait::~ORWait()
- {
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::Add
- *
- * DESCRIPTION
- * Add wait condition. All the wait conditions will be started at once.
- *
- * INPUTS
- * Wait condition
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void ORWait::Add(const RefPtr<WaitCondition>& wait)
- {
- if (wait.IsValid())
- {
- mWaits.push_back(wait);
- // Use the longest timeout value.
- unsigned long timeout = wait->GetTimeout();
- if (timeout > mMaxTimeout)
- {
- mMaxTimeout = timeout;
- }
- }
- else
- {
- assert(wait.IsValid() && "ORWait: Invalid wait condition");
- EndWait(Error, L"Invalid wait condition.");
- }
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::WaitBeginning
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void ORWait::WaitBeginning(void)
- {
- for (unsigned int index = 0; index < mWaits.size(); index++)
- {
- mWaits[index]->WaitBeginning();
- }
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::GetResult
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- *
- ******************************************************************************/
- WaitCondition::WaitResult ORWait::GetResult(void)
- {
- // If we are not waiting the we are finished
- if (mEndResult != Waiting)
- {
- return mEndResult;
- }
- // Get the result of all the wait conditions being processed. If any one
- // is finished then the entire wait finished.
- for (unsigned int index = 0; index < mWaits.size(); index++)
- {
- mEndResult = mWaits[index]->GetResult();
- if (mEndResult != Waiting)
- {
- mEndText = mWaits[index]->GetResultText();
- return mEndResult;
- }
- }
- return Waiting;
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::EndWait
- *
- * DESCRIPTION
- *
- * INPUTS
- *
- * RESULT
- * NONE
- *
- ******************************************************************************/
- void ORWait::EndWait(WaitResult result, const wchar_t* endText)
- {
- mEndText = endText;
- mEndResult = result;
- for (unsigned int index = 0; index < mWaits.size(); ++index)
- {
- mWaits[index]->EndWait(result, L"");
- }
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::GetResultText
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- *
- ******************************************************************************/
- const wchar_t* ORWait::GetResultText(void) const
- {
- return mEndText;
- }
- /******************************************************************************
- *
- * NAME
- * ORWait::WaitText
- *
- * DESCRIPTION
- *
- * INPUTS
- * NONE
- *
- * RESULT
- *
- ******************************************************************************/
- const wchar_t* ORWait::GetWaitText(void) const
- {
- return mWaitText;
- }
|