Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GroupNode.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_GroupNode_h_
00003 #define INCLUDED_GroupNode_h_
00004 
00005 #include "Behaviors/StateNode.h"
00006 #include <vector>
00007 
00008 //! Allows a group of StateNodes to be activated together
00009 /*! When a transition occurs into the group node, it will activate all
00010  *  of its subnodes.
00011  *
00012  *  @note  Another (probably better) way to do this is with a
00013  *  multi-destination transition - after the initialization of the
00014  *  transition (usually specifying the first transition) you can call
00015  *  the Transition::addDestination() function to add addition
00016  *  destinations, replicating the functionality of this class.
00017  *
00018  *  The group node doesn't deactivate its subnodes together.  In
00019  *  essence, this is a fork - one transition targeting the GroupNode
00020  *  can activate several states, which are then separate branches of
00021  *  execution.  (Although of course only one is actually being
00022  *  executed at a time, as per the cooperative multi-tasking of
00023  *  behaviors.)
00024  *
00025  */
00026 class GroupNode : public StateNode {
00027 public:
00028   //!constructor
00029   GroupNode() : StateNode() {}
00030   //!constructor
00031   explicit GroupNode(const std::string& nm) : StateNode(nm) {}
00032 
00033   //! activates all of the sub nodes
00034   virtual void postStart() {
00035     StateNode::postStart();
00036     for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
00037       if(!(*it)->isActive())
00038         (*it)->start();
00039   }
00040   
00041 private:
00042   GroupNode(const GroupNode& node); //!< don't call this
00043   GroupNode operator=(const GroupNode& node); //!< don't call this
00044 };
00045 
00046 /*! @file
00047  * @brief Defines GroupNode, which allows a group of StateNodes to be activated together
00048  * @author ejt (Creator)
00049  */
00050 
00051 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:41 2016 by Doxygen 1.6.3