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

Config Class Reference

#include <config.h>

Inheritance diagram for Config:

Inheritance graph
[legend]
Collaboration diagram for Config:

Collaboration graph
[legend]
List of all members.

Detailed Description

Configuration data repository Configuration can be loaded from a file through the loadable entity interface. The configuration repository will by default listen to the "set" and "showconfig" console commands, and the core config repository object will automatically register the commands with the core console object when the core is initialized.

For an example on how to use config change callbacks, look at the documentation for the ConfigCallback class.

Author:
Mattias Jansson (mattias@realityrift.com)


Public Member Functions

 Config (Console *pkConsole=0)
virtual ~Config ()
void SetValue (const HashString &rstrKey, const HashString &rstrValue)
void SetValue (const HashString &rstrKey, float fValue)
void SetValue (const HashString &rstrKey, int iValue)
void SetValue (const HashString &rstrKey, bool bValue)
int GetValue (const HashString &rstrKey, std::string *pstrValue)
int GetValue (const HashString &rstrKey, float *pfValue)
int GetValue (const HashString &rstrKey, int *piValue)
int GetValue (const HashString &rstrKey, bool *pbValue)
void Print ()
void RegisterCallback (ConfigCallback *pkCallback)
void UnregisterCallback (ConfigCallback *pkCallback)
virtual void ConsoleCmd (const HashString &rstrCmd, const HashString &rstrArgs)
void SetFileManager (FileManager *pkManager)
bool Load (const std::string &rstrFilename, unsigned int uiFlags=0, bool bForceReload=false, bool bSearchFileSystem=false)
bool Load (File *pkFile, unsigned int uiFlags=0, bool bForceReload=false)

Protected Attributes

Filem_pkFile
bool m_bLoaded
bool m_bKeepFile
FileManagerm_pkFileManager

Private Member Functions

virtual bool LoadNode (unsigned int uiFlags)

Private Attributes

HashTable< ConfigValue > * m_pkHashTable
std::vector< ConfigCallback * > m_vpkCallbacks


Constructor & Destructor Documentation

Config Console pkConsole = 0  ) 
 

Initialize configuration repository, register console commands on specified console object

Parameters:
pkConsole Console object, will use core console if null

virtual ~Config  )  [virtual]
 


Member Function Documentation

virtual bool LoadNode unsigned int  uiFlags  )  [private, virtual]
 

Main loader method. Called by LoadableEntity to load object if file was opened successfully

Parameters:
uiFlags Loader flags (currently ignored for config)
Returns:
true if load was successful, false otherwise

Implements LoadableEntity.

void SetValue const HashString rstrKey,
const HashString rstrValue
 

Set string value for key

Parameters:
rstrKey Key to set
rstrValue String value

void SetValue const HashString rstrKey,
float  fValue
 

Set float value for key

Parameters:
rstrKey Key to set
fValue Float value

void SetValue const HashString rstrKey,
int  iValue
 

Set int value for key

Parameters:
rstrKey Key to set
iValue Integer value

void SetValue const HashString rstrKey,
bool  bValue
 

Set int value for key

Parameters:
rstrKey Key to set
bValue Boolean value

int GetValue const HashString rstrKey,
std::string *  pstrValue
 

Get string value for key

Parameters:
rstrKey Key to get
pstrValue String recieving value
Returns:
0 if invalid value (not a string), >0 if success

int GetValue const HashString rstrKey,
float *  pfValue
 

Get float value for key

Parameters:
rstrKey Key to get
pfValue Float recieving value
Returns:
0 if invalid value (not a float), >0 if success

int GetValue const HashString rstrKey,
int *  piValue
 

Get int value for key

Parameters:
rstrKey Key to get
piValue Integer recieving value
Returns:
0 if invalid value (not a int), >0 if success

int GetValue const HashString rstrKey,
bool *  pbValue
 

Get boolean value for key

Parameters:
rstrKey Key to get
pbValue Boolean recieving value
Returns:
0 if invalid value (not a int), >0 if success

void Print  ) 
 

Print out configuration repository data to core logger at DEBUG level

void RegisterCallback ConfigCallback pkCallback  ) 
 

Register a callback method for listening to change events

Parameters:
pkCallback Callback object

void UnregisterCallback ConfigCallback pkCallback  ) 
 

Unregister a callback method

Parameters:
pkCallback Callback object

virtual void ConsoleCmd const HashString rstrCmd,
const HashString rstrArgs
[virtual]
 

Process console command

Parameters:
rstrCmd Command
rstrArgs Argument string

Implements ConsoleCmdCallback.

void SetFileManager FileManager pkManager  )  [inherited]
 

Set new file manager object

Parameters:
pkManager Ptr to file manager object

bool Load const std::string &  rstrFilename,
unsigned int  uiFlags = 0,
bool  bForceReload = false,
bool  bSearchFileSystem = false
[inherited]
 

Load resource

Parameters:
rstrFilename Filename
uiFlags Flags to pass to loader
bForceReload Force reload if already loaded (default false)
bSearchFileSystem Look in normal file system for file if not found in file manager (default false)
Returns:
true if successful (or already loaded and not force flag set), false otherwise (load/reload failed)

bool Load File pkFile,
unsigned int  uiFlags = 0,
bool  bForceReload = false
[inherited]
 

Load resource

Parameters:
pkFile File object
uiFlags Flags to pass to loader
bForceReload Force reload if already loaded
Returns:
true if successful (or already loaded and not force flag set), false otherwise (load/reload failed)


Member Data Documentation

HashTable< ConfigValue >* m_pkHashTable [private]
 

Hash table of keys

std::vector< ConfigCallback* > m_vpkCallbacks [private]
 

Callback objects

File* m_pkFile [protected, inherited]
 

File

bool m_bLoaded [protected, inherited]
 

Flag indicating node is loaded

bool m_bKeepFile [protected, inherited]
 

Flag to block file deletion on load completion

FileManager* m_pkFileManager [protected, inherited]
 

File manager


The documentation for this class was generated from the following file:
Generated on Wed Jan 21 14:21:10 2004 for NeoEngine by doxygen 1.3.5