Homepage Demos Overview Downloads Tutorials Reference
Credits
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members | Related Pages | Search

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 ()
 constructor

 StateNode (const char *n, StateNode *p=NULL)
 constructor, pass a name to use, calls setName(n)

virtual ~StateNode ()
 destructor, frees memory used by 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 deleted later, returns what it's passed (for convenience), calls AddReference() on node.

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...

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.

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

void setName (const std::string &n)
 set name to n. Makes a copy of n, so you can throw it away later.

virtual std::string getName () const
 returns name of StateNode

virtual std::string getDescription () const
 returns name again (you should override this for top-level nodes to give users better descriptions)

virtual void processEvent (const EventBase &)
 Doesn't do anything, supplied here so you don't have to (since events will probably be going to Transition's, not here).

void transitionTo (StateNode *n)
 called by a subnode when it is being DoStart()'ed

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 deleted upon DoStop(). (or at least RemoveReference() is called on subnodes)

std::vector< StateNode * > nodes
 vector of StateNodes, just so they can be deleted again on DoStop() (unless retained) or ~StateNode()

std::string name
 holds the name of the Node/Machine


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  )  [inline]
 

constructor

Definition at line 15 of file StateNode.h.

References issetup, name, nodes, parent, retain, and transitions.

StateNode::StateNode const char *  n,
StateNode p = NULL
[inline]
 

constructor, pass a name to use, calls setName(n)

Definition at line 18 of file StateNode.h.

References issetup, name, nodes, parent, retain, setName(), and transitions.

StateNode::~StateNode  )  [virtual]
 

destructor, frees memory used by its outgoing transitions (be careful of incoming ones - they're still around!), and calls RemoveReference() on subnodes

Definition at line 4 of file StateNode.cc.

References DoStop(), BehaviorBase::isActive(), nodes, and transitions.

StateNode::StateNode const StateNode node  )  [private]
 

don't call this


Member Function Documentation

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

Adds a StateNode to nodes so it can be automatically deleted later, returns what it's passed (for convenience), calls AddReference() on node.

Definition at line 32 of file StateNode.h.

References ReferenceCounter::AddReference(), and nodes.

void StateNode::addTransition Transition trans  )  [virtual]
 

Adds the specified StateTransition to the transition table.

Definition at line 13 of file StateNode.cc.

References Transition::enable(), BehaviorBase::isActive(), and transitions.

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, WalkToTargetMachine, WorldModel2Behavior, WorldModel2Behavior::WalkNode, WorldModel2Behavior::GawkNode, WorldModel2Behavior::WaitNode, and OutputNode.

Definition at line 19 of file StateNode.cc.

References EventBase::activateETID, BehaviorBase::DoStart(), erouter, getName(), issetup, parent, EventRouter::postEvent(), setup(), EventBase::stateMachineEGID, transitions, and transitionTo().

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, WalkToTargetMachine, WorldModel2Behavior, WorldModel2Behavior::WalkNode, WorldModel2Behavior::GawkNode, and WorldModel2Behavior::WaitNode.

Definition at line 32 of file StateNode.cc.

References EventBase::deactivateETID, BehaviorBase::DoStop(), erouter, getName(), issetup, nodes, EventRouter::postEvent(), retain, EventBase::stateMachineEGID, and transitions.

virtual std::string StateNode::getDescription  )  const [inline, virtual]
 

returns name again (you should override this for top-level nodes to give users better descriptions)

Reimplemented from BehaviorBase.

Definition at line 56 of file StateNode.h.

References name.

virtual std::string StateNode::getName  )  const [inline, virtual]
 

returns name of StateNode

Implements BehaviorBase.

Definition at line 53 of file StateNode.h.

References name.

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

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

Definition at line 35 of file StateNode.h.

References nodes.

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

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

Definition at line 29 of file StateNode.h.

References transitions.

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

don't call this

virtual void StateNode::processEvent const EventBase  )  [inline, virtual]
 

Doesn't do anything, supplied here so you don't have to (since events will probably be going to Transition's, not here).

Reimplemented from BehaviorBase.

Reimplemented in BanditMachine::WaitNode, WalkToTargetMachine, WorldModel2Behavior::WalkNode, and WorldModel2Behavior::GawkNode.

Definition at line 59 of file StateNode.h.

void StateNode::setName const std::string &  n  ) 
 

set name to n. Makes a copy of n, so you can throw it away later.

Definition at line 46 of file StateNode.cc.

References name.

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 38 of file StateNode.h.

References retain.

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

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

Reimplemented in BanditMachine, WalkToTargetMachine, and WorldModel2Behavior.

Definition at line 44 of file StateNode.h.

References issetup.

void StateNode::transitionFrom StateNode n  ) 
 

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

Definition at line 54 of file StateNode.cc.

void StateNode::transitionTo StateNode n  ) 
 

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

Definition at line 50 of file StateNode.cc.


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 76 of file StateNode.h.

std::string StateNode::name [protected]
 

holds the name of the Node/Machine

Definition at line 84 of file StateNode.h.

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

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

Definition at line 80 of file StateNode.h.

StateNode* StateNode::parent [protected]
 

pointer to the machine that contains this node

Definition at line 70 of file StateNode.h.

bool StateNode::retain [protected]
 

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

Definition at line 78 of file StateNode.h.

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

a vector of outgoing transitions

Definition at line 72 of file StateNode.h.


The documentation for this class was generated from the following files:
Tekkotsu v1.4
Generated Sat Jul 19 00:09:12 2003 by Doxygen 1.3.2