home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-08-27 | 3.2 KB | 142 lines | [TEXT/CWIE] |
- // ===========================================================================
- // • LTask.cp © 1995, Éric Forget. All rights reserved.
- // ===========================================================================
- //
- // ************************************************************************
- // * *
- // * Before using this code you should read the "License Agreement" *
- // * document and agree with it. *
- // * *
- // ************************************************************************
- //
- // LTask is an abstract class for dealing with task to be done.
- // To see example of LTask subclass look at:
- //
- // LDelayedTask, LNotificationTask, LTimerTask or LVerticalRetraceTask
- //
- // ---------------------------------------------------------------------------
- //
- // Usage Notes:
- // -----------
- //
- // When creating a derived class, you should override at minimum:
- //
- // StartTaskSelf();
- // ExecuteTaskSelf();
- // StopTaskSelf();
- //
- // ---------------------------------------------------------------------------
-
-
- #include "LTask.h"
-
- #include "UDeleteTaskQueue.h"
-
-
- // ---------------------------------------------------------------------------
- // • LTask
- // ---------------------------------------------------------------------------
-
- LTask::LTask()
- {
- mFirstDelay = 0;
- mNextDelay = 0;
- mDeleteOnCompletion = false;
- mIsExecuting = false;
- }
-
-
- // ---------------------------------------------------------------------------
- // • LTask
- // ---------------------------------------------------------------------------
-
- LTask::LTask(
- Int32 inFirstDelay,
- Int32 inNextDelay,
- Boolean inDeleteOnCompletion)
- {
- mFirstDelay = inFirstDelay;
- mNextDelay = inNextDelay;
- mDeleteOnCompletion = inDeleteOnCompletion;
- mIsExecuting = false;
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~LTask
- // ---------------------------------------------------------------------------
-
- LTask::~LTask()
- {
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • StartTask
- // ---------------------------------------------------------------------------
-
- void
- LTask::StartTask()
- {
- if(!IsExecuting()) {
-
- StartTaskSelf();
-
- mIsExecuting = true;
-
- if(mDeleteOnCompletion) {
-
- UDeleteTaskQueue::AddTask(this);
- }
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • StopTask
- // ---------------------------------------------------------------------------
-
- void
- LTask::StopTask()
- {
- if(IsExecuting()) {
-
- mIsExecuting = false;
-
- StopTaskSelf();
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • ExecuteTask
- // ---------------------------------------------------------------------------
-
- void
- LTask::ExecuteTask()
- {
- Boolean isLastCall = false;
-
-
- ExecuteTaskSelf(isLastCall);
-
- if(!isLastCall) {
-
- ContinueTask();
-
- } else {
-
- StopTask();
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • ContinueTask
- // ---------------------------------------------------------------------------
-
- void
- LTask::ContinueTask()
- {
- }