ARSTD::RepeatCommand Class Reference

Inheritance diagram for ARSTD::RepeatCommand:

Inheritance graph
[legend]
List of all members.

Public Member Functions

virtual ARSTD::Command::PtrType copy () const
virtual std::string getName () const

Static Public Member Functions

static PtrType create (int nCycles=-1)

Detailed Description

This command makes commands executing again until the given number of cycles is reached. Its behavior is depend on how the command is executed.
1. The command is executed directly by the command processor: All previously _executed_ commands are executed again.
2. The command is part of macro command: All previously _attached_ commands are executed again. That means the repeat command attached to a macro command repeats only commands of this command also if this macro is attached to another macro.

Example: two loops in one command plus a seperate repeat. 2 times 2 times 2 (8) torpedos with litte pauses are fired. (in python)

     innerLoop = MacroCommand.create('InnerLoop')
     innerLoop.attach(CSWFireCommand.create(self.getFrontLeftWeaponBattery(), None))
     innerLoop.attach(CSWWaitCommand.create(2.5))
     innerLoop.attach(RepeatCommand.create(1))

     outerLoop = MacroCommand.create('OuterLoop')
     outerLoop.attach(CSWWaitCommand.create(5))
     outerLoop.attach(innerLoop)
     outerLoop.attach(RepeatCommand.create(1))

     self.getCommandProcessor().execute(outerLoop)
     self.getCommandProcessor().execute(RepeatCommand.create(1))


Member Function Documentation

RepeatCommand::PtrType ARSTD::RepeatCommand::create ( int  nCycles = -1  )  [static]

Creates a new repeat command.

Parameters:
nCycles The number of cycles that all previous commands should repeat. If a negativ value is given the repeating does not terminate automatically.
Returns:
Returns the new constructed command.

ARSTD::Command::PtrType ARSTD::RepeatCommand::copy (  )  const [virtual]

Returns a copy of the command.

Returns:
The copied command.

Implements ARSTD::Command.

std::string ARSTD::RepeatCommand::getName (  )  const [virtual]

Returns the name of the command.

Returns:
The name of the command.

Implements ARSTD::Command.


Generated at 2 Jan 2007 for project CodeSubWars. www.codesubwars.org