/**
  * Constructs an ExecutionRandomSelector to run a specific ModelRandomSelector.
  *
  * @param modelTask
  *            the ModelRandomSelector to run.
  * @param executor
  *            the BTExecutor that will manage this ExecutionRandomSelector.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionRandomSelector(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelRandomSelector))
     {
         throw new ArgumentException("The ModelTask must subclass ModelRandomSelector but it inherits from " + modelTask.GetType().Name);
     }
 }
 /**
  * Constructs an ExecutionLeaf to run a specific ModelLeaf.
  *
  * @param modelTask
  *            the ModelLeaf to run.
  * @param executor
  *            the BTExecutor that will manage this ExecutionLeaf.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 protected ExecutionLeaf(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelLeaf))
     {
         throw new ArgumentException("The ModelTask must subclass ModelLeaf but it inherits from " + modelTask.GetType().Name);
     }
 }
 /**
  * Constructs an ExecutionSafeContextManager that knows how to run a
  * ModelSafeContextManager.
  *
  * @param modelTask
  *            the ModelSafeContextManager to run.
  * @param executor
  *            the BTExecutor that will manage this
  *            ExecutionSafeContextManager.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionSafeContextManager(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelSafeContextManager))
     {
         throw new ArgumentException("The ModelTask must subclass ModelSafeContextManager but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
 /**
  * Creates an ExecutionStaticPriorityList that is able to run a
  * ModelStaticPriorityList task and that is managed by a BTExecutor.
  *
  * @param modelTask
  *            the ModelStaticPriorityList that this
  *            ExecutionStaticPriorityList is going to run.
  * @param executor
  *            the BTExecutor in charge of running this
  *            ExecutionStaticPriorityList.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionStaticPriorityList(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelStaticPriorityList))
     {
         throw new ArgumentException("The ModelTask must subclass ModelStaticPriorityList but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
 /**
  * Creates an ExecutionPerformInterruption that is able to run a
  * ModelPerformInterruption task and that is managed by a BTExecutor.
  *
  * @param modelTask
  *            the ModelPerformInterruption that this
  *            ExecutionPerformInterruption is going to run.
  * @param executor
  *            the BTExecutor in charge of running this
  *            ExecutionPerformInterruption.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionPerformInterruption(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelPerformInterruption))
     {
         throw new ArgumentException("The ModelTask must subclass ModelPerformInterruption but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
 /**
  * Constructs an ExecutionSubtreeLookup that knows how to run a
  * ModelSubtreeLookup.
  *
  * @param modelTask
  *            the ModelSubtreeLookup to run.
  * @param executor
  *            the BTExecutor that will manage this ExecutionSubtreeLookup.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionSubtreeLookup(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelSubtreeLookup))
     {
         throw new ArgumentException("The ModelTask must subclass ModelSubtreeLookup but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
 /**
  * Creates an ExecutionComposite that is able to run a particular
  * ModelComposite task.
  *
  * @param modelTask
  *            the ModelComposite task to run.
  * @param executor
  *            the BTExecutor that will manage this ExecutionComposite.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 protected ExecutionComposite(ModelTask modelTask, IBTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelComposite))
     {
         throw new ArgumentException("The ModelTask must subclass " + typeof (ModelComposite).Name + " but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
 /**
  * Constructs and ExecutionUntilFail that knows how to run a ModelUntilFail.
  *
  * @param modelTask
  *            the ModelUntilFail that this ExecutionUntilFail will run.
  * @param executor
  *            the BTExecutor that will manage this ExecutionUntilFail.
  * @param parent
  *            the parent ExecutionTask of this task.
  */
 public ExecutionUntilFail(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
     : base(modelTask, executor, parent)
 {
     if (!(modelTask is ModelUntilFail))
     {
         throw new ArgumentException("The ModelTask must subclass ModelUntilFail but it inherits from " +
                                     modelTask.GetType().Name);
     }
 }
        /**
         * Creates an ExecutionWait that is able to run a ModelWait task and that is
         * managed by a BTExecutor.
         *
         * @param modelTask
         *            the ModelWait that this ExecutionWait is going to run.
         * @param executor
         *            the BTExecutor in charge of running this ExecutionWait.
         * @param parent
         *            the parent ExecutionTask of this task.
         */
        public ExecutionWait(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
            : base(modelTask, executor, parent)
        {
            if (!(modelTask is ModelWait))
            {
                throw new ArgumentException("The ModelTask must subclass ModelWait but it inherits from " + modelTask.GetType().Name);
            }

            Initialize(modelTask);
        }
        /**
         * Creates an ExecutionLimit that knows how to run a ModelLimit.
         *
         * @param modelTask
         *            the ModelLimit to run.
         * @param executor
         *            the BTExecutor that will manage this ExecutionLimit.
         * @param parent
         *            the parent ExecutionTask of this task.
         */
        public ExecutionLimit(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
            : base(modelTask, executor, parent)
        {
            if (!(modelTask is ModelLimit))
            {
                throw new ArgumentException("The ModelTask must subclass ModelLimitbut it inherits from " + modelTask.GetType().Name);
            }

            _maxNumTimes = ((ModelLimit) ModelTask).getMaxNumTimes();
            _numRunsSoFar = 0;
        }
        /**
         * Constructs an ExecutionVariableRenamer that knows how to run a
         * ModelVariableRenamer.
         *
         * @param modelTask
         *            the ModelVariableRenamer to run.
         * @param executor
         *            the BTExecutor in charge of running this
         *            ExecutionVariableRenamer.
         * @param parent
         *            the parent ExecutionTask of this task.
         */
        public ExecutionVariableRenamer(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
            : base(modelTask, executor, parent)
        {
            if (!(modelTask is ModelVariableRenamer))
            {
                throw new ArgumentException("The ModelTask must subclass ModelVariableRenamer but it inherits from " +
                                            modelTask.GetType().Name);
            }

            _variableName = ((ModelVariableRenamer) modelTask).VariableName;
            _newVariableName = ((ModelVariableRenamer) modelTask).NewVariableName;
        }
        /**
         * Creates an ExecutionParallel that is able to run a ModelParallel task and
         * that is managed by a BTExecutor.
         *
         * @param modelTask
         *            the ModelParallel that this ExecutionParallel is going to run.
         * @param executor
         *            the BTExecutor in charge of running this ExecutionParallel.
         * @param parent
         *            the parent ExecutionTask of this task.
         */
        public ExecutionParallel(ModelTask modelTask, BTExecutor executor, ExecutionTask parent)
            : base(modelTask, executor, parent)
        {
            if (!(modelTask is ModelParallel))
            {
                throw new ArgumentException("The ModelTask must subclass " + typeof (ModelParallel).Name + " but it inherits from " +
                                            modelTask.GetType().Name);
            }

            _policy = ((ModelParallel)modelTask).Policy;
            _modelChildren = modelTask.Children;
            Initialize();
        }