Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
OutputNode.hGo 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), msg() {} 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), msg(nm) {} 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), msg(nm) {} 00018 //!constructor, sets name, message, and another state which will immediately be transitioned to upon activation 00019 OutputNode(const char* nm, const std::string& mg, StateNode* par, ostream& output, StateNode * nextstate) : StateNode(nm,par), next(nextstate), out(output), msg(mg) {} 00020 00021 //!outputs this state's name, will transition to #next if non-NULL 00022 /*!if #next is NULL, the state will simply stay active until some other transition causes it to leave*/ 00023 virtual void DoStart() { 00024 StateNode::DoStart(); 00025 out << msg << endl; 00026 if(next!=NULL) { 00027 DoStop(); 00028 next->DoStart(); 00029 } 00030 } 00031 00032 protected: 00033 StateNode* next; //!< the state to transition to upon entering, can be NULL 00034 ostream& out; //!< the stream to use for output - if not specified (default constructor) cout will be used 00035 std::string msg; //!< message to show on activation 00036 00037 private: 00038 OutputNode(const OutputNode& node); //!< don't call this 00039 OutputNode operator=(const OutputNode& node); //!< don't call this 00040 }; 00041 00042 /*! @file 00043 * @brief Defines OutputNode, a very simple StateNode that outputs its name to a given ostream upon activation, handy for debugging 00044 * @author ejt (Creator) 00045 * 00046 * $Author: ejt $ 00047 * $Name: tekkotsu-2_2 $ 00048 * $Revision: 1.4 $ 00049 * $State: Rel $ 00050 * $Date: 2003/09/26 03:09:10 $ 00051 */ 00052 00053 #endif |
Tekkotsu v2.2 |
Generated Tue Oct 19 14:19:15 2004 by Doxygen 1.3.9.1 |