Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
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 "Shared/MarkScope.h"
00007 #include <string>
00008 #include <ostream>
00009 
00010 //! A very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00011 /*! The Event Logger controller item (Status Reports menu) is a much better tool for debugging */
00012 class OutputNode : public StateNode {
00013 public:
00014   //!constructor, sets name and ostream to use for output
00015   OutputNode(const std::string &nm, std::ostream& output) : StateNode(nm), next(NULL), out(output), msg(nm) {}
00016 
00017   //!constructor, sets name and another state which will immediately be transitioned to upon activation
00018   OutputNode(const std::string &nm, std::ostream& output, StateNode * nextstate) : StateNode(nm), next(nextstate), out(output), msg(nm) {}
00019   //!constructor, sets name, message, and another state which will immediately be transitioned to upon activation
00020   OutputNode(const std::string &nm, const std::string& mg, std::ostream& output, StateNode * nextstate=NULL) : StateNode(nm), next(nextstate), out(output), msg(mg) {}
00021 
00022   //!outputs this state's name, will transition to #next if non-NULL
00023   /*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/
00024   virtual void postStart() {
00025     StateNode::postStart();
00026     out << msg << std::endl;
00027     if(next!=NULL) {
00028       stop();
00029       next->start();
00030     }
00031   }
00032   
00033 protected:
00034   StateNode* next; //!< the state to transition to upon entering, can be NULL
00035   std::ostream& out;    //!< the stream to use for output - if not specified (default constructor) cout will be used
00036   std::string msg;      //!< message to show on activation
00037 
00038 private:
00039   OutputNode(const OutputNode& node); //!< don't call this
00040   OutputNode operator=(const OutputNode& node); //!< don't call this
00041 };
00042 
00043 /*! @file
00044  * @brief Defines OutputNode, a very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging
00045  * @author ejt (Creator)
00046  */
00047 
00048 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:45 2016 by Doxygen 1.6.3