Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

config.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     config.h  -  Configuration repository
00003                              -------------------
00004     begin                : Wed Jul 03 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, config.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 
00028 #ifndef __NECONFIG_H
00029 #define __NECONFIG_H
00030 
00031 
00038 #include "base.h"
00039 #include "hashtable.h"
00040 #include "callback.h"
00041 #include "loadableentity.h"
00042 
00043 
00044 namespace NeoEngine
00045 {
00046 
00047 
00048 // External classes
00049 class ConfigCallback;
00050 class Console;
00051 
00052 
00057 class NEOENGINE_API ConfigValue
00058 {
00059     public:
00060 
00062         HashString                                    m_strValue;
00063 
00065         int                                           m_iValue;
00066 
00068         float                                         m_fValue;
00069 
00071         bool                                          m_bValue;
00072 
00073         
00077                                                       ConfigValue() : m_strValue( "[NA]" ), m_iValue( 0 ), m_fValue( 0.0f ), m_bValue( false ) {}
00078 };
00079 
00080 
00081 HashTableExport( ConfigValue );
00082 
00083 
00084 #ifdef WIN32
00085 #  ifndef __HAVE_VECTOR_CONFIGCALLBACK
00086      UDTVectorEXPIMP( class ConfigCallback* );
00087 #    define __HAVE_VECTOR_CONFIGCALLBACK
00088 #  endif
00089 #endif
00090 
00091 
00103 class NEOENGINE_API Config : public LoadableEntity, public ConsoleCmdCallback
00104 {
00105     private:
00106 
00108         HashTable< ConfigValue >                     *m_pkHashTable;
00109 
00111         std::vector< ConfigCallback* >                m_vpkCallbacks;
00112 
00118         virtual bool                                  LoadNode( unsigned int uiFlags );
00119 
00120     public:
00121 
00127                                                       Config( Console *pkConsole = 0 );
00128 
00131         virtual                                      ~Config();
00132 
00138         void                                          SetValue( const HashString &rstrKey, const HashString &rstrValue );
00139 
00145         void                                          SetValue( const HashString &rstrKey, float fValue );
00146 
00152         void                                          SetValue( const HashString &rstrKey, int iValue );
00153 
00159         void                                          SetValue( const HashString &rstrKey, bool bValue );
00160 
00167         int                                           GetValue( const HashString &rstrKey, std::string *pstrValue );
00168 
00175         int                                           GetValue( const HashString &rstrKey, float *pfValue );
00176 
00183         int                                           GetValue( const HashString &rstrKey, int *piValue );
00184 
00191         int                                           GetValue( const HashString &rstrKey, bool *pbValue );
00192 
00196         void                                          Print();
00197         
00202         void                                          RegisterCallback( ConfigCallback *pkCallback );
00203 
00208         void                                          UnregisterCallback( ConfigCallback *pkCallback );
00209 
00215         virtual void                                  ConsoleCmd( const HashString &rstrCmd, const HashString &rstrArgs );
00216 };
00217 
00218 
00219 };
00220 
00221 
00222 
00223 #endif

Generated on Wed Jan 21 14:21:06 2004 for NeoEngine by doxygen 1.3.5