001    /*----------------------------------------------------------------------------*/
002    /* Copyright (c) FIRST 2008-2012. All Rights Reserved.                        */
003    /* Open Source Software - may be modified and shared by FRC teams. The code   */
004    /* must be accompanied by the FIRST BSD license file in the root directory of */
005    /* the project.                                                               */
006    /*----------------------------------------------------------------------------*/
007    
008    package edu.wpi.first.wpilibj.command;
009    
010    /**
011     * This command will only finish if whatever {@link CommandGroup} it is in has no active children.
012     * If it is not a part of a {@link CommandGroup}, then it will finish immediately.  If it is itself an
013     * active child, then the {@link CommandGroup} will never end.
014     *
015     * <p>This class is useful for the situation where you want to allow anything running in parallel to finish, before continuing
016     * in the main {@link CommandGroup} sequence.</p>
017     * @author Joe Grinstead
018     */
019    public class WaitForChildren extends Command {
020    
021        protected void initialize() {
022        }
023    
024        protected void execute() {
025        }
026    
027        protected void end() {
028        }
029    
030        protected void interrupted() {
031        }
032    
033        protected boolean isFinished() {
034            return getGroup() == null || getGroup().m_children.isEmpty();
035        }
036    }