コード例 #1
0
ファイル: Driver.php プロジェクト: bluesnowman/Chimera
 /**
  * This method executes the tasks define in the pipeline.
  *
  * @access public
  * @param BT\Exchange $exchange                             the given exchange to process
  * @param string $id                                        the id of behavior tree to run
  * @return integer                                          the status code
  */
 public function run(BT\Exchange $exchange, $id = 'BEHAVE')
 {
     // http://aigamedev.com/open/article/popular-behavior-tree-design/
     $factory = new Spring\XMLObjectFactory(Spring\Data\XML::load($this->file));
     $registry = $factory->getParser()->getRegistry();
     $registry->putEntry(array('action', BT\Task::NAMESPACE_URI), new BT\Object\Factory\ActionElement());
     $registry->putEntry(array('blackboard', BT\Task::NAMESPACE_URI), new BT\Object\Factory\BlackboardElement());
     $registry->putEntry(array('branch', BT\Task::NAMESPACE_URI), new BT\Object\Factory\BranchElement());
     $registry->putEntry(array('breakpoint', BT\Task::NAMESPACE_URI), new BT\Object\Factory\BreakpointElement());
     $registry->putEntry(array('composite', BT\Task::NAMESPACE_URI), new BT\Object\Factory\CompositeElement());
     $registry->putEntry(array('condition', BT\Task::NAMESPACE_URI), new BT\Object\Factory\ConditionElement());
     $registry->putEntry(array('decorator', BT\Task::NAMESPACE_URI), new BT\Object\Factory\DecoratorElement());
     $registry->putEntry(array('entry', BT\Task::NAMESPACE_URI), new BT\Object\Factory\EntryElement());
     $registry->putEntry(array('leaf', BT\Task::NAMESPACE_URI), new BT\Object\Factory\LeafElement());
     $registry->putEntry(array('logger', BT\Task::NAMESPACE_URI), new BT\Object\Factory\LoggerElement());
     $registry->putEntry(array('parallel', BT\Task::NAMESPACE_URI), new BT\Object\Factory\ParallelElement());
     $registry->putEntry(array('picker', BT\Task::NAMESPACE_URI), new BT\Object\Factory\PickerElement());
     $registry->putEntry(array('ref', BT\Task::NAMESPACE_URI), new BT\Object\Factory\RefElement());
     $registry->putEntry(array('resetter', BT\Task::NAMESPACE_URI), new BT\Object\Factory\ResetterElement());
     $registry->putEntry(array('selector', BT\Task::NAMESPACE_URI), new BT\Object\Factory\SelectorElement());
     $registry->putEntry(array('semaphore', BT\Task::NAMESPACE_URI), new BT\Object\Factory\SemaphoreElement());
     $registry->putEntry(array('sequence', BT\Task::NAMESPACE_URI), new BT\Object\Factory\SequenceElement());
     $registry->putEntry(array('policy', BT\Task::NAMESPACE_URI), new BT\Object\Factory\PolicyElement());
     $registry->putEntry(array('stub', BT\Task::NAMESPACE_URI), new BT\Object\Factory\StubElement());
     $registry->putEntry(array('tasks', BT\Task::NAMESPACE_URI), new BT\Object\Factory\TasksElement());
     $registry->putEntry(array('ticker', BT\Task::NAMESPACE_URI), new BT\Object\Factory\TickerElement());
     $registry->putEntry(array('timer', BT\Task::NAMESPACE_URI), new BT\Object\Factory\TimerElement());
     if ($factory->hasObject($id)) {
         $object = $factory->getObject($id);
         if ($object instanceof BT\Task) {
             return BT\Task\Handler::process($object, $exchange);
         }
     }
     return BT\Task\Status::ERROR;
 }
コード例 #2
0
ファイル: Parser.php プロジェクト: bluesnowman/Chimera
 /**
  * This method returns a reference to the XML resource being parsed.
  *
  * @access public
  * @return \SimpleXMLElement                                a reference to the XML resource
  *                                                          being parsed
  */
 public function getResource()
 {
     return $this->context->getResources()->getValue(0);
 }