Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

RepeatCommand Class Reference

#include <command.h>

Inheritance diagram for RepeatCommand:

Inheritance graph
Collaboration diagram for RepeatCommand:

Collaboration graph
List of all members.

Public Member Functions

double getDuration ()
void process (ExecutionEnvironment &, double t, double dt)=0
 RepeatCommand (CommandSequence *_body, int _repeatCount)
 ~RepeatCommand ()

Private Attributes

CommandSequencebody
double bodyDuration
Executionexecution
int repeatCount

Constructor & Destructor Documentation

RepeatCommand::RepeatCommand CommandSequence _body,
int  _repeatCount
 

Definition at line 738 of file command.cpp.

References body, and bodyDuration.

00738                                                                      :
00739     body(_body),
00740     repeatCount(_repeatCount),
00741     bodyDuration(0.0),
00742     execution(NULL)
00743 {
00744     for (CommandSequence::const_iterator iter = body->begin();
00745          iter != body->end(); iter++)
00746     {
00747         bodyDuration += (*iter)->getDuration();
00748     }
00749 }

RepeatCommand::~RepeatCommand  ) 
 

Definition at line 751 of file command.cpp.

References execution.

00752 {
00753     if (execution != NULL)
00754         delete execution;
00755     // delete body;
00756 }


Member Function Documentation

double RepeatCommand::getDuration  ) 
 

Definition at line 789 of file command.cpp.

References bodyDuration, and repeatCount.

00790 {
00791     return bodyDuration * repeatCount;
00792 }

void RepeatCommand::process ExecutionEnvironment ,
double  t,
double  dt
[pure virtual]
 

Implements Command.

Definition at line 758 of file command.cpp.

References body, bodyDuration, execution, Execution::reset(), and Execution::tick().

00759 {
00760     double t0 = t - dt;
00761     int loop0 = (int) (t0 / bodyDuration);
00762     int loop1 = (int) (t / bodyDuration);
00763 
00764     // TODO: This is bogus . . . should not be storing a reference to an
00765     // execution environment.
00766     if (execution == NULL)
00767         execution = new Execution(*body, env);
00768 
00769     if (loop0 == loop1)
00770     {
00771         execution->tick(dt);
00772     }
00773     else
00774     {
00775         double timeLeft = (loop0 + 1) * bodyDuration - t0;
00776         execution->tick(timeLeft);
00777 
00778         for (int i = loop0 + 1; i < loop1; i++)
00779         {
00780             execution->reset(*body);
00781             execution->tick(bodyDuration);
00782         }
00783 
00784         execution->reset(*body);
00785         execution->tick(t - loop1 * bodyDuration);
00786     }
00787 }


Member Data Documentation

CommandSequence* RepeatCommand::body [private]
 

Definition at line 539 of file command.h.

Referenced by process(), and RepeatCommand().

double RepeatCommand::bodyDuration [private]
 

Definition at line 540 of file command.h.

Referenced by getDuration(), process(), and RepeatCommand().

Execution* RepeatCommand::execution [private]
 

Definition at line 542 of file command.h.

Referenced by process(), and ~RepeatCommand().

int RepeatCommand::repeatCount [private]
 

Definition at line 541 of file command.h.

Referenced by getDuration().


The documentation for this class was generated from the following files:
Generated on Sat Jan 14 22:33:34 2006 for Celestia by  doxygen 1.4.1