KeosConsole.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 
00022 //==========================================================
00023 // ORIGINAL COPYRIGHT FOLLOWS
00024 //==========================================================
00025 // Yes::Engine - Free C++ 3D engine
00026 //
00027 // Copyright (C) 2004-2005 Laurent Gomila
00028 //
00029 // This program is free software; you can redistribute it and/or
00030 // modify it under the terms of the GNU General Public License
00031 // as published by the Free Software Foundation; either version 2
00032 // of the License, or (at your option) any later version.
00033 //
00034 // This program is distributed in the hope that it will be useful,
00035 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00036 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00037 // GNU General Public License for more details.
00038 //
00039 // You should have received a copy of the GNU General Public License
00040 // along with this program; if not, write to the Free Software
00041 // Foundation, Inc.,
00042 // 59 Temple Place - Suite 330,
00043 // Boston, MA  02111-1307, USA.
00044 //
00045 // E-mail : laurent.gom@gmail.com
00046 //==========================================================
00047 
00048 #ifndef KEOS_CONSOLE_H
00049 #define KEOS_CONSOLE_H
00050 
00051 //==========================================================
00052 // En-têtes
00053 //==========================================================
00054 #include "KeosPrerequisites.h"
00055 #include "KeosSingleton.h"
00056 #include "KeosConsoleFunctor.h"
00057 #include "KeosConsoleLook.h"
00058 
00059 namespace Keos
00060 {
00064   class KEOS_EXPORT CConsole : public CSingleton<CConsole>
00065   {
00066     friend CSingleton<CConsole>;
00067 
00068   public :
00069 
00070     //----------------------------------------------------------
00071     // Constructeur par défaut
00072     //----------------------------------------------------------
00073     CConsole();
00074 
00075     //----------------------------------------------------------
00076     // Change l'apparence de la console
00077     //----------------------------------------------------------
00078     void ChangeLook(Console::ILook* NewLook);
00079 
00080     //----------------------------------------------------------
00081     // Enregistre une nouvelle commande
00082     //----------------------------------------------------------
00083     void RegisterCommand(const std::string& Name, const Console::CFunctor& Function,
00084                          const std::string& Help = "No help for this command");
00085 
00086     //----------------------------------------------------------
00087     // Envoie un nouveau caractère à la console
00088     //----------------------------------------------------------
00089     void SendChar(char Character);
00090 
00091     //----------------------------------------------------------
00092     // Met à jour la console
00093     //----------------------------------------------------------
00094     void Update();
00095 
00096     //----------------------------------------------------------
00097     // Affiche la console
00098     //----------------------------------------------------------
00099     void Draw() const;
00100 
00101     //----------------------------------------------------------
00102     // Active ou désactive la console
00103     //----------------------------------------------------------
00104     void Enable(bool Enabled);
00105 
00106   private :
00107 
00108     //----------------------------------------------------------
00109     // Donne la liste des commandes enregistrées
00110     //----------------------------------------------------------
00111     std::string GetCommands() const;
00112 
00113     //----------------------------------------------------------
00114     // Commande Help: permet d'avoir la description d'une commande
00115     //----------------------------------------------------------
00116     String HelpCommand(const String& CommandName);
00117 
00118     //----------------------------------------------------------
00119     // Traite la ligne courante et appelle la fonction correspondante
00120     //----------------------------------------------------------
00121     void ProcessCurrent();
00122 
00123     //----------------------------------------------------------
00124     // Types
00125     //----------------------------------------------------------
00126     typedef std::map<std::string, Console::CFunctor> TCommandTable;
00127     typedef std::map<std::string, std::string> THelpTable;
00128 
00129     //----------------------------------------------------------
00130     // Données membres
00131     //----------------------------------------------------------
00132     TCommandTable             m_Commands; 
00133     THelpTable                m_Helps;    
00134     std::string               m_Current;  
00135     CSmartPtr<Console::ILook> m_Look;     
00136     bool                      m_Enabled;  
00137   };
00138 
00139 } // namespace Keos
00140 
00141 
00142 #endif // KEOS_CONSOLE_H

Generated on Fri Mar 9 14:29:02 2007 for Keos by  doxygen 1.5.1-p1