Homepage Demos Overview Downloads Tutorials Reference
Credits

StateNode Class Reference

#include <StateNode.h>

Inheritance diagram for StateNode:

Inheritance graph
[legend]
List of all members.

Detailed Description

Recursive data structure - both a state machine controller as well as a node within a state machine itself.

Override setup() to setup your own Transition and StateNode network.

Definition at line 12 of file StateNode.h.

Public Member Functions

 StateNode () __attribute__((deprecated))
 deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class)
 StateNode (const std::string &name, StateNode *p=NULL)
 constructor, pass a name to use and the parent node if applicable (usually 'this' within setup())
virtual ~StateNode ()
 destructor, removes references to its outgoing transitions (be careful of incoming ones - they're still around!), and calls RemoveReference() on subnodes
virtual void addTransition (Transition *trans)
 Adds the specified StateTransition to the transition table.
std::vector< Transition * > & getTransitions ()
 Returns the std::vector of transitions so you can modify them yourself if need be.
virtual StateNodeaddNode (StateNode *node)
 Adds a StateNode to nodes so it can be automatically dereferenced later, returns what it's passed (for convenience), calls AddReference() on node. Also sets the node's parent to #this if it is null.
std::vector< StateNode * > & getNodes ()
 Returns the std::vector of nodes so you can modify them yourself if need be.
void setRetain (bool f)
 Sets the retain flag - if not retained, will RemoveReference() subnodes upon DoStop() and recreate them on DoStart (by calling setup()) - may be too expensive to be worth saving memory...
virtual void DoStart ()
 Transitions should call this when you are entering the state, so it can enable its transitions.
virtual void setup ()
 This is called by DoStart() when you should setup the network of subnodes.
virtual void DoStop ()
 Transitions should call this when you are leaving the state, so it can disable its transitions.
virtual void teardown ()
 This is called by DoStop() when you should destruct subnodes.

Protected Member Functions

 StateNode (const std::string &classname, const std::string &name, StateNode *p=NULL)
 constructor, pass a name to use and the parent node if applicable (usually 'this' within setup())
virtual void transitionTo (StateNode *n)
 called by a subnode when it is being DoStart()'ed
virtual void transitionFrom (StateNode *n)
 called by a subnode when it is being DoStop()'ed

Protected Attributes

StateNodeparent
 pointer to the machine that contains this node
std::vector< Transition * > transitions
 a vector of outgoing transitions
bool issetup
 this is set to true if the network has been setup but not destroyed (i.e. don't need to call setupSubNodes again)
bool retain
 this is set to true if the network should be retained between activations. Otherwise it's dereferenced upon DoStop(). (or at least RemoveReference() is called on subnodes)
std::vector< StateNode * > nodes
 vector of StateNodes, just so they can be dereferenced again on DoStop() (unless retained) or ~StateNode()

Private Member Functions

 StateNode (const StateNode &node)
 don't call this
StateNode operator= (const StateNode &node)
 don't call this


Constructor & Destructor Documentation

StateNode::StateNode  ) 
 

deprecated, behavior constructors should take a name argument (which by default should be the name of the type of the class)

Deprecated:
, behavior constructors should take a name argument (which by default should be the name of the type of the class)

Definition at line 6 of file StateNode.cc.

StateNode::StateNode const std::string &  name,
StateNode p = NULL
[inline]
 

constructor, pass a name to use and the parent node if applicable (usually 'this' within setup())

Definition at line 18 of file StateNode.h.

StateNode::~StateNode  )  [virtual]
 

destructor, removes references to its outgoing transitions (be careful of incoming ones - they're still around!), and calls RemoveReference() on subnodes

Definition at line 8 of file StateNode.cc.

StateNode::StateNode const std::string &  classname,
const std::string &  name,
StateNode p = NULL
[inline, protected]
 

constructor, pass a name to use and the parent node if applicable (usually 'this' within setup())

Definition at line 52 of file StateNode.h.

StateNode::StateNode const StateNode node  )  [private]
 

don't call this


Member Function Documentation

StateNode * StateNode::addNode StateNode node  )  [virtual]
 

Adds a StateNode to nodes so it can be automatically dereferenced later, returns what it's passed (for convenience), calls AddReference() on node. Also sets the node's parent to #this if it is null.

Definition at line 24 of file StateNode.cc.

Referenced by PaceTargetsMachine::setup(), ExploreMachine::setup(), and BanditMachine::setup().

void StateNode::addTransition Transition trans  )  [virtual]
 

Adds the specified StateTransition to the transition table.

Definition at line 18 of file StateNode.cc.

Referenced by WalkToTargetMachine::setup(), PaceTargetsMachine::setup(), ExploreMachine::setup(), and BanditMachine::setup().

void StateNode::DoStart  )  [virtual]
 

Transitions should call this when you are entering the state, so it can enable its transitions.

Reimplemented from BehaviorBase.

Reimplemented in BanditMachine, BanditMachine::PressNode, BanditMachine::DecideNode, BanditMachine::WaitNode, ExploreMachine, PaceTargetsMachine, WalkToTargetMachine, GroupNode, HeadPointerNode, LedNode, OutputNode, PlayMotionSequenceNode< SIZE >, SoundNode, TailWagNode, and WalkNode.

Definition at line 32 of file StateNode.cc.

Referenced by WalkToTargetMachine::DoStart(), WalkNode::DoStart(), TailWagNode::DoStart(), SoundNode::DoStart(), PlayMotionSequenceNode< SIZE >::DoStart(), PaceTargetsMachine::DoStart(), OutputNode::DoStart(), LedNode::DoStart(), HeadPointerNode::DoStart(), GroupNode::DoStart(), ExploreMachine::DoStart(), BanditMachine::WaitNode::DoStart(), BanditMachine::DecideNode::DoStart(), BanditMachine::PressNode::DoStart(), and BanditMachine::DoStart().

void StateNode::DoStop  )  [virtual]
 

Transitions should call this when you are leaving the state, so it can disable its transitions.

Reimplemented from BehaviorBase.

Reimplemented in BanditMachine, BanditMachine::PressNode, BanditMachine::WaitNode, ExploreMachine, WalkToTargetMachine, HeadPointerNode, LedNode, PlayMotionSequenceNode< SIZE >, SoundNode, TailWagNode, and WalkNode.

Definition at line 47 of file StateNode.cc.

Referenced by OutputNode::DoStart(), BanditMachine::DecideNode::DoStart(), WalkToTargetMachine::DoStop(), WalkNode::DoStop(), TailWagNode::DoStop(), SoundNode::DoStop(), PlayMotionSequenceNode< SIZE >::DoStop(), LedNode::DoStop(), HeadPointerNode::DoStop(), ExploreMachine::DoStop(), BanditMachine::WaitNode::DoStop(), BanditMachine::PressNode::DoStop(), and BanditMachine::DoStop().

std::vector<StateNode*>& StateNode::getNodes  )  [inline]
 

Returns the std::vector of nodes so you can modify them yourself if need be.

Definition at line 33 of file StateNode.h.

std::vector<Transition*>& StateNode::getTransitions  )  [inline]
 

Returns the std::vector of transitions so you can modify them yourself if need be.

Definition at line 27 of file StateNode.h.

StateNode StateNode::operator= const StateNode node  )  [private]
 

don't call this

void StateNode::setRetain bool  f  )  [inline]
 

Sets the retain flag - if not retained, will RemoveReference() subnodes upon DoStop() and recreate them on DoStart (by calling setup()) - may be too expensive to be worth saving memory...

Definition at line 36 of file StateNode.h.

Referenced by ExploreMachine::ExploreMachine(), and WalkNode::WalkNode().

virtual void StateNode::setup  )  [inline, virtual]
 

This is called by DoStart() when you should setup the network of subnodes.

Reimplemented in BanditMachine, ExploreMachine, PaceTargetsMachine, WalkToTargetMachine, and PlayMotionSequenceNode< SIZE >.

Definition at line 42 of file StateNode.h.

Referenced by DoStart(), WalkToTargetMachine::setup(), PaceTargetsMachine::setup(), ExploreMachine::setup(), and BanditMachine::setup().

virtual void StateNode::teardown  )  [inline, virtual]
 

This is called by DoStop() when you should destruct subnodes.

Reimplemented in ExploreMachine, PaceTargetsMachine, WalkToTargetMachine, PlayMotionSequenceNode< SIZE >, and WalkNode.

Definition at line 48 of file StateNode.h.

Referenced by DoStop(), PaceTargetsMachine::teardown(), and ExploreMachine::teardown().

void StateNode::transitionFrom StateNode n  )  [protected, virtual]
 

called by a subnode when it is being DoStop()'ed

Definition at line 70 of file StateNode.cc.

void StateNode::transitionTo StateNode n  )  [protected, virtual]
 

called by a subnode when it is being DoStart()'ed

Definition at line 66 of file StateNode.cc.

Referenced by DoStart().


Member Data Documentation

bool StateNode::issetup [protected]
 

this is set to true if the network has been setup but not destroyed (i.e. don't need to call setupSubNodes again)

Definition at line 68 of file StateNode.h.

Referenced by DoStart(), DoStop(), setup(), StateNode(), and teardown().

std::vector<StateNode*> StateNode::nodes [protected]
 

vector of StateNodes, just so they can be dereferenced again on DoStop() (unless retained) or ~StateNode()

Definition at line 72 of file StateNode.h.

Referenced by addNode(), DoStop(), StateNode(), and ~StateNode().

StateNode* StateNode::parent [protected]
 

pointer to the machine that contains this node

Definition at line 62 of file StateNode.h.

Referenced by addNode(), DoStart(), and StateNode().

bool StateNode::retain [protected]
 

this is set to true if the network should be retained between activations. Otherwise it's dereferenced upon DoStop(). (or at least RemoveReference() is called on subnodes)

Definition at line 70 of file StateNode.h.

Referenced by setRetain(), and StateNode().

std::vector<Transition*> StateNode::transitions [protected]
 

a vector of outgoing transitions

Definition at line 64 of file StateNode.h.

Referenced by addTransition(), DoStart(), DoStop(), StateNode(), and ~StateNode().


The documentation for this class was generated from the following files:

Tekkotsu v2.2.1
Generated Tue Nov 23 16:37:53 2004 by Doxygen 1.3.9.1