00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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