Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

DumpFileControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_DumpFileControl_h_
00003 #define INCLUDED_DumpFileControl_h_
00004 
00005 #include "FileBrowserControl.h"
00006 #include <fstream>
00007 
00008 //! Upon activation, loads a position from a file name read from cin (stored in ms/data/motion...)
00009 class DumpFileControl : public FileBrowserControl {
00010  public:
00011   //! Constructor
00012   DumpFileControl(const std::string& n,const std::string& r)
00013     : FileBrowserControl(n,"Dumps a user specified file to the console",r)
00014   {}
00015   //! Destructor
00016   virtual ~DumpFileControl() {}
00017 
00018 protected:
00019   //!does the actual loading of the MotionSequence
00020   virtual ControlBase* selectedFile(const std::string& f) {
00021     const unsigned int BUFSIZE=128;
00022     doRewrite=false;
00023     std::ifstream in(f.c_str());
00024     while(in) {
00025       byte* buf=sout->getWriteBuffer(BUFSIZE);
00026       if(buf==NULL) {
00027         serr->printf("DumpFileControl - write failed\n");
00028         return this;
00029       }
00030       in.read(reinterpret_cast<char*>(buf),BUFSIZE);
00031       sout->write(in.gcount());
00032     }
00033     sout->printf("\n");
00034     return this;
00035   }
00036 };
00037 
00038 /*! @file
00039  * @brief Defines DumpFileControl, which when activated, plays a sound selected from the memory stick
00040  * @author ejt (Creator)
00041  */
00042 
00043 #endif

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