Homepage Demos Overview Downloads Tutorials Reference
Credits

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, sets name and ostream to use for output
00013   OutputNode(const char* nm, StateNode* par, ostream& output) : StateNode("OutputNode",nm,par), next(NULL), out(output), msg(nm) {}
00014   //!constructor, sets name and another state which will immediately be transitioned to upon activation
00015   OutputNode(const char* nm, StateNode* par, ostream& output, StateNode * nextstate) : StateNode("OutputNode",nm,par), next(nextstate), out(output), msg(nm) {}
00016   //!constructor, sets name, message, and another state which will immediately be transitioned to upon activation
00017   OutputNode(const char* nm, const std::string& mg, StateNode* par, ostream& output, StateNode * nextstate) : StateNode("OutputNode",nm,par), next(nextstate), out(output), msg(mg) {}
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 << msg << endl;
00024     if(next!=NULL) {
00025       DoStop();
00026       next->DoStart();
00027     }
00028   }
00029   
00030 protected:
00031   StateNode* next; //!< the state to transition to upon entering, can be NULL
00032   ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
00033   std::string msg;      //!< message to show on activation
00034 
00035 private:
00036   OutputNode(const OutputNode& node); //!< don't call this
00037   OutputNode operator=(const OutputNode& node); //!< don't call this
00038 };
00039 
00040 /*! @file
00041  * @brief Defines OutputNode, a very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00042  * @author ejt (Creator)
00043  *
00044  * $Author: ejt $
00045  * $Name: tekkotsu-2_2_1 $
00046  * $Revision: 1.6 $
00047  * $State: Exp $
00048  * $Date: 2004/11/11 20:35:00 $
00049  */
00050 
00051 #endif

Tekkotsu v2.2.1
Generated Tue Nov 23 16:36:39 2004 by Doxygen 1.3.9.1