Homepage Demos Overview Downloads Tutorials 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 that this doesn't occur if there's a transition to one of the
00013  *  sub nodes...  only when the main group node itself transitions.
00014  *
00015  *  The group node doesn't deactivate its subnodes together however.
00016  *  In essence, this is a fork - one transition can activate several
00017  *  states, which are then separate branches of execution.  (Although
00018  *  only one is actually being executed at a time)
00019  */
00020 class GroupNode : public StateNode {
00021 public:
00022   //!constructor
00023   GroupNode() : StateNode("GroupNode") {}
00024   //!constructor
00025   explicit GroupNode(const std::string& nm, StateNode* p=NULL) : StateNode(nm,p) {}
00026 
00027   //! activates all of the sub nodes
00028   virtual void DoStart() {
00029     StateNode::DoStart();
00030     for(std::vector<StateNode*>::iterator it=nodes.begin(); it!=nodes.end(); it++)
00031       if(!(*it)->isActive())
00032         (*it)->DoStart();
00033   }
00034   
00035 private:
00036   GroupNode(const GroupNode& node); //!< don't call this
00037   GroupNode operator=(const GroupNode& node); //!< don't call this
00038 };
00039 
00040 /*! @file
00041  * @brief Defines GroupNode, which allows a group of StateNodes to be activated together
00042  * @author ejt (Creator)
00043  *
00044  * $Author: ejt $
00045  * $Name: tekkotsu-2_0 $
00046  * $Revision: 1.2 $
00047  * $State: Exp $
00048  * $Date: 2004/01/18 10:16:57 $
00049  */
00050 
00051 #endif

Tekkotsu v2.0
Generated Wed Jan 21 03:20:28 2004 by Doxygen 1.3.4