Homepage Demos Overview Downloads Tutorials 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  * $Author: ejt $
00043  * $Name: tekkotsu-2_0 $
00044  * $Revision: 1.2 $
00045  * $State: Rel $
00046  * $Date: 2003/09/25 15:26:10 $
00047  */
00048 
00049 #endif

Tekkotsu v2.0
Generated Wed Jan 21 03:20:28 2004 by Doxygen 1.3.4