Console.h

00001 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
00002 /* 
00003  * Copyright (C) 2008 Micha Hersch, EPFL
00004  * RobotCub Consortium, European Commission FP6 Project IST-004370
00005  * email:   micha.hersch@robotcub.org
00006  * website: www.robotcub.org
00007  * Permission is granted to copy, distribute, and/or modify this program
00008  * under the terms of the GNU General Public License, version 2 or any
00009  * later version published by the Free Software Foundation.
00010  *
00011  * A copy of the license can be found at
00012  * http://www.robotcub.org/icub/license/gpl.txt
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00017  * Public License for more details
00018  */
00019 #ifndef __CONSOLE_H__
00020 #define __CONSOLE_H__
00021 
00022 //#pragma warning( disable : 4786)
00023 
00024 #include <vector>
00025 #include <string>
00026 #include <sstream>
00027 
00028 using namespace std;
00029 
00030 typedef vector<string> String_List;
00031 
00032 class Command {
00033 public:
00034   string  m_Name;
00035 public:
00036                 Command(string name);
00037   virtual       ~Command();
00038   virtual int   Execute(string args);
00039 };
00040 typedef Command *pCommand;
00041 typedef vector<pCommand> Command_List;
00042 
00043 
00044 class Console
00045 {
00046 private:
00047   static streambuf *    m_Stdout;
00048 
00049 
00050 protected:
00051   Command_List          m_Commands;
00052 
00053   String_List           m_Lines;
00054   int                   m_MaxLines;
00055   String_List           m_History;
00056   int                   m_MaxHistory;
00057   int                   m_CurrHistory;
00058 
00059   string                m_CurrCmd;
00060 
00061   vector<int>           m_AutoMatches;
00062 
00063 
00064   int                   m_CurrX;
00065   int                   m_CurrY;
00066 
00067   ostringstream         m_oStream;
00068 
00069 public:
00070             Console();
00071   virtual  ~Console();
00072 
00073   void      Free();
00074   void      Clear();
00075   void      SetMaxLines(int size);
00076   void      SetMaxHistory(int size);
00077 
00078   void      AddLine(string line);
00079   void      AddHistory(string line);
00080 
00081   void      AddCommand(pCommand cmd);
00082   pCommand  FindCommand(string name);
00083 
00084   void      HistoryPrev();
00085   void      HistoryNext();
00086 
00087   void      AddChar(char c);
00088   void      EraseChar();
00089   void      Accept();
00090   virtual   int       AutoCompletion();
00091 
00092   void      Print(string line);
00093   void      Update();
00094 
00095   streambuf *GetStreamBuf();
00096   void      SetStdout();
00097 
00098 };
00099 
00100 
00101 #endif
 All Data Structures Functions Variables

Generated on Wed Sep 22 16:51:25 2010 for Body_Schema_Learning by  doxygen 1.6.1