Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

SaveWalkControl.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_SaveWalkControl_h
00002 #define INCLUDED_SaveWalkControl_h
00003 
00004 #include "StringInputControl.h"
00005 #include "Motion/MotionManager.h"
00006 #include "Motion/WalkMC.h"
00007 #include <string>
00008 
00009 //! When activated, saves walk parameters to a file specified from cin
00010 class SaveWalkControl : public StringInputControl {
00011  public:
00012   //! constructor, pass the MC_ID of the walk you want to save
00013   SaveWalkControl(const std::string& n, MotionManager::MC_ID w) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in data/motion)..."), walk_id(w), thewalk(NULL) {}
00014   //! constructor, pass a pointer to the walk you want to save
00015   SaveWalkControl(const std::string& n, WalkMC * awalk) : StringInputControl(n,"Saves Walk parameters to filename read from user","Please enter name for posture file (in data/motion)..."), walk_id(MotionManager::invalid_MC_ID), thewalk(awalk) {}
00016   //! destructor
00017   virtual ~SaveWalkControl() {}
00018 
00019   virtual ControlBase * takeInput(const std::string& msg) {
00020     if(msg.size()>0) {
00021       std::string filename=config->motion.makePath(msg);
00022       if(filename.find(".")==std::string::npos)
00023         filename+=".prm";
00024       MotionManager::MC_ID id = (thewalk==NULL ? walk_id : thewalk->getID() );
00025       WalkMC* walk=thewalk;
00026       if(id!=MotionManager::invalid_MC_ID)
00027         walk = (WalkMC*)motman->checkoutMotion(id);
00028       if(walk==NULL)
00029         serr->printf("Invalid walk for saving\n");
00030       else {
00031         walk->SaveFile(filename.c_str());
00032         motman->checkinMotion(id);
00033       }
00034     }
00035     return StringInputControl::takeInput(msg);
00036   }
00037 
00038  protected:
00039   MotionManager::MC_ID walk_id; //!< MC_ID of walk to save from
00040   WalkMC * thewalk; //!< walk to save from
00041 
00042 private:
00043   SaveWalkControl(const SaveWalkControl&); //!< don't call
00044   SaveWalkControl operator=(const SaveWalkControl&); //!< don't call
00045 };
00046 
00047 /*! @file
00048  * @brief Defines SaveWalkControl, which when activated, saves walk parameters to a file specified from cin
00049  * @author ejt (Creator)
00050  *
00051  * $Author: ejt $
00052  * $Name: tekkotsu-2_4_1 $
00053  * $Revision: 1.10 $
00054  * $State: Exp $
00055  * $Date: 2005/06/01 05:47:45 $
00056  */
00057 #endif

Tekkotsu v2.4.1
Generated Tue Aug 16 16:32:48 2005 by Doxygen 1.4.4