My Documents/dxframework/dxf/dxf-engine/dxf_console.h

Go to the documentation of this file.
00001 /*      DXFramework Copyright (c) 2006, Jonathan Voigt, University of Michigan.
00002         See http://dxframework.sourceforge.net/ for a list of contributors.
00003         All rights reserved.
00004 
00005         Redistribution and use in source and binary forms, with or without modification, 
00006         are permitted provided that the following conditions are met:
00007 
00008                 * Redistributions of source code must retain the above copyright notice, 
00009                 this list of conditions and the following disclaimer.
00010 
00011                 * Redistributions in binary form must reproduce the above copyright notice, 
00012                 this list of conditions and the following disclaimer in the documentation 
00013                 and/or other materials provided with the distribution.
00014 
00015                 * Neither the name of the DXFramework project nor the names of its 
00016                 contributors may be used to endorse or promote products derived from this 
00017                 software without specific prior written permission.
00018 
00019         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
00020         ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
00021         WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00022         DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 
00023         ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
00024         (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
00025         LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
00026         ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00027         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00028         SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00030 
00031 #pragma once
00032 
00033 namespace dxf {
00034         // Define the CommandFunction which we'll call to process commands
00035         typedef void (*CommandFunction)(std::vector<std::wstring>& argv);
00036 
00037         // Used to store a map from command name to function handler for that command
00038         typedef std::map<std::wstring, CommandFunction> CommandMap;
00039         typedef CommandMap::const_iterator CommandMapConstIter;
00040 
00044         class Console {
00045         public:
00046                 static Console* const Instance();
00047 
00048                 bool Ready();
00049 
00050                 HRESULT Load();
00051                 void Unload();
00052 
00053                 inline bool Active() const;     
00054                 inline void Activate();         
00055         
00061                 void RegisterCommand(const wchar_t* command, CommandFunction function);
00064                 void ListCommands() const;
00065 
00066                 void Update();
00067                 bool Render2D();
00068 
00069                 void OnResetDevice(const D3DSURFACE_DESC* pBackBufferSurfaceDesc);
00070 
00071                 const Font* GetFont();
00072 
00078                 static std::wostringstream output;
00079 
00080         protected:
00081                 Console();
00082                 Console(const Console&);
00083                 Console* operator= (const Console*);
00084 
00085         private:
00086 
00087                 int TokenizeCommandLine(std::vector<std::wstring>& argv);
00088                 bool FindCommand(std::vector<std::wstring>& argv);
00089 
00090                 bool active;
00091                 bool ready;
00092                 std::list<std::wstring> display;
00093                 std::wstring commandLine;
00094                 CommandMap commandMap;
00095                 Font font;
00096                 int rows;
00097                 Sprite upper;
00098                 Sprite lower;
00099                 Texture texture;
00100         };
00101 
00102         void DXFUpdateConsole();
00103         void DXFRenderConsole();
00104 } // namespace dxf

Generated on Fri Aug 18 12:01:27 2006 for DXFramework by  doxygen 1.4.7