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 /*! The Event Logger controller item (Status Reports menu) is a much better tool for debugging */
00011 class OutputNode : public StateNode {
00012 public:
00013   //!constructor, sets name and ostream to use for output
00014   OutputNode(const char* nm, ostream& output) : StateNode("OutputNode",nm), next(NULL), out(output), msg(nm) {}
00015   //!constructor, sets name and another state which will immediately be transitioned to upon activation
00016   OutputNode(const char* nm, ostream& output, StateNode * nextstate) : StateNode("OutputNode",nm), next(nextstate), out(output), msg(nm) {}
00017   //!constructor, sets name, message, and another state which will immediately be transitioned to upon activation
00018   OutputNode(const char* nm, const std::string& mg, ostream& output, StateNode * nextstate) : StateNode("OutputNode",nm), next(nextstate), out(output), msg(mg) {}
00019 
00020   //!outputs this state's name, will transition to #next if non-NULL
00021   /*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/
00022   virtual void DoStart() {
00023     StateNode::DoStart();
00024     out << msg << endl;
00025     if(next!=NULL) {
00026       DoStop();
00027       next->DoStart();
00028     }
00029   }
00030   
00031 protected:
00032   StateNode* next; //!< the state to transition to upon entering, can be NULL
00033   ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
00034   std::string msg;      //!< message to show on activation
00035 
00036 private:
00037   OutputNode(const OutputNode& node); //!< don't call this
00038   OutputNode operator=(const OutputNode& node); //!< don't call this
00039 };
00040 
00041 /*! @file
00042  * @brief Defines OutputNode, a very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00043  * @author ejt (Creator)
00044  *
00045  * $Author: ejt $
00046  * $Name: tekkotsu-2_2_2 $
00047  * $Revision: 1.7 $
00048  * $State: Exp $
00049  * $Date: 2004/12/04 00:10:42 $
00050  */
00051 
00052 #endif

Tekkotsu v2.2.2
Generated Tue Jan 4 15:43:14 2005 by Doxygen 1.4.0