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

OutputNode.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_OutputNode_h_
00003 #define INCLUDED_OutputNode_h_
00004 
00005 #include "Behaviors/StateNode.h"
00006 #include <string>
00007 #include <ostream>
00008 
00009 //! A very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00010 class OutputNode : public StateNode {
00011 public:
00012   //!constructor, uses cout for output
00013   OutputNode() : StateNode(), next(NULL), out(cout) {}
00014   //!constructor, sets name and ostream to use for output
00015   OutputNode(const char* nm, StateNode* par, ostream& output) : StateNode(nm,par), next(NULL), out(output) {}
00016   //!constructor, sets name and another state which will immediately be transitioned to upon activation
00017   OutputNode(const char* nm, StateNode* par, ostream& output, StateNode * nextstate) : StateNode(nm,par), next(nextstate), out(output) {}
00018 
00019   //!outputs this state's name, will transition to #next if non-NULL
00020   /*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/
00021   virtual void DoStart() {
00022     StateNode::DoStart();
00023     out << name << endl;
00024     DoStop();
00025     if(next!=NULL)
00026       next->DoStart();
00027   }
00028   
00029 protected:
00030   StateNode* next; //!< the state to transition to upon entering, can be NULL
00031   ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
00032 
00033 private:
00034   OutputNode(const OutputNode& node); //!< don't call this
00035   OutputNode operator=(const OutputNode& node); //!< don't call this
00036 };
00037 
00038 /*! @file
00039  * @brief Defines OutputNode, a very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00040  * @author ejt (Creator)
00041  *
00042  * $Author: ejt $
00043  * $Name: tekkotsu-1_4_1 $
00044  * $Revision: 1.2 $
00045  * $State: Exp $
00046  * $Date: 2003/03/09 02:45:22 $
00047  */
00048 
00049 #endif

Tekkotsu v1.4
Generated Sat Jul 19 00:06:31 2003 by Doxygen 1.3.2