Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

LoopCommand.cxx

Go to the documentation of this file.
00001 //     $Id: LoopCommand.cxx,v 1.1.1.1 2001/01/04 01:01:11 burnett Exp $
00002 //  Author: Toby Burnett
00003 //
00004 // Implementation of the LoopCommand class
00005 
00006 
00007 #include "gui/LoopCommand.h"
00008 #include <limits.h>
00009 
00010 namespace gui {
00011 
00012 LoopCommand::LoopCommand(Command* command, long count)
00013 : m_command(command)
00014 , m_count(count)
00015 {
00016     stop();
00017 }
00018 
00019 LoopCommand::~LoopCommand()
00020 {
00021     delete m_command;
00022 }
00023 
00024  
00025 void LoopCommand::execute()
00026 {
00027     m_current = 0;
00028     m_status = PAUSED;
00029     resume();
00030 }
00031 
00032 
00033 void LoopCommand::resume()
00034 {
00035     if( m_status != PAUSED)
00036         return;
00037     m_status = RUNNING;
00038     for(; m_status==RUNNING && m_current< m_count; ++m_current)  {
00039           m_command->execute();
00040     }
00041     if( m_status==RUNNING)
00042           m_status= STOPPED;
00043 }
00044 
00045 void LoopCommand::pause()
00046 {
00047     m_status = PAUSED;
00048 }
00049 void LoopCommand::stop() {   m_status= STOPPED;  m_current = ULONG_MAX;}
00050 void LoopCommand::abort(){   m_status = ABORTED; m_current = ULONG_MAX;}
00051 
00052 
00053 LoopCommand::Status LoopCommand::status() const
00054 {
00055         return m_status;
00056 }
00057 Command* LoopCommand::pauseCommand() { return new LCommand(this, &LoopCommand::pause);}
00058 Command* LoopCommand::abortCommand() { return new LCommand(this, &LoopCommand::abort);}
00059 Command* LoopCommand::resumeCommand(){ return new LCommand(this, &LoopCommand::resume);}
00060         
00061 } // namespace gui

Generated at Wed Nov 21 12:20:55 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000