Settings Class Reference

#include <settings.h>

List of all members.

Public Member Functions

 Settings ()
 initializes settings with default values
bool loadSettings (const char *filename)
 Load setting from config XML.
bool saveSettings (const char *filename)
 Save setttings to file.
double getDouble (const char *entry)
 Get double asociated with key.
int getInt (const char *entry)
 Return variable from setting converted to int.
string getString (const char *entry)
bool compare (const char *entry, const char *value)
bool isTrue (const char *entry)
void set (const std::string &key, const std::string &value)
template<class T>
void set (const std::string &key, const T &val)
bool exist (const char *entry)
 Check if entry is known.

Private Member Functions

map< string, string >::iterator find (const char *entry)

Private Attributes

map< string, string > m_map


Detailed Description

Definition at line 15 of file settings.h.


Constructor & Destructor Documentation

Settings::Settings  ) 
 

initializes settings with default values

Set default values for all settings.

Definition at line 25 of file settings.cpp.


Member Function Documentation

bool Settings::compare const char *  entry,
const char *  value
 

Definition at line 121 of file settings.cpp.

References find().

Here is the call graph for this function:

bool Settings::exist const char *  entry  ) 
 

Check if entry is known.

Parameters:
entry key to check
Returns:
true if key exists

Definition at line 172 of file settings.cpp.

References m_map.

Referenced by CommanderClient::command_getvar(), CommanderClient::command_setvar(), and saveSettings().

map< std::string, std::string >::iterator Settings::find const char *  entry  )  [private]
 

Definition at line 158 of file settings.cpp.

References DIE(), LOGE, and m_map.

Referenced by compare(), getDouble(), getInt(), and isTrue().

Here is the call graph for this function:

double Settings::getDouble const char *  entry  ) 
 

Get double asociated with key.

If the entry doesn't exist or can't be converted to double the method kills the program

Parameters:
entry key to with double
Returns:
asociated double

Definition at line 192 of file settings.cpp.

References find(), get_double(), and LOGT.

Referenced by GameServer::GameServer(), TaskSimulationServer::init(), and GameServer::setSpeedMultiplicator().

Here is the call graph for this function:

int Settings::getInt const char *  entry  ) 
 

Return variable from setting converted to int.

Die if entry not found. Die if not a number.

Definition at line 184 of file settings.cpp.

References find(), and get_long().

Referenced by Console::Console(), TerrainServer::init(), ApplicationServer::init(), ApplicationClient::init(), and GFX::loadVideoSettings().

Here is the call graph for this function:

std::string Settings::getString const char *  entry  ) 
 

Search for entry in settings. If entry doesn't exist, the program die. If you need store any entry in Settings, add it's default value to constructor. Else the program may fall.

Definition at line 112 of file settings.cpp.

Referenced by CommanderClient::command_getvar(), ApplicationServer::init(), ApplicationClient::init(), Application::initBasicSubsystems(), Application::loadUserConfigFile(), GFX::loadVideoSettings(), saveSettings(), and Application::saveUserConfigFile().

bool Settings::isTrue const char *  entry  ) 
 

Die if not found, die if invalind conversion.

Definition at line 150 of file settings.cpp.

References find(), and get_bool().

Referenced by TerrainGeoMipMap::init(), TaskRender::init(), SFX::init(), ApplicationServer::init(), ApplicationClient::init(), GFX::loadVideoSettings(), TerrainGeoMipMap::render(), and LayerGame::setView().

Here is the call graph for this function:

bool Settings::loadSettings const char *  filename  ) 
 

Load setting from config XML.

Not yet known keys are added and old values are rewriten. You may call this function more times on one object.

Parameters:
filename path to file with settings
Returns:
true if loading was sucessfull

Definition at line 34 of file settings.cpp.

References assertL, TiXmlElement::Attribute(), TiXmlHandle::Element(), TiXmlHandle::FirstChild(), TiXmlDocument::LoadFile(), LOGD, LOGE, set(), and TIN.

Referenced by Application::initBasicSubsystems(), and Application::loadUserConfigFile().

Here is the call graph for this function:

bool Settings::saveSettings const char *  filename  ) 
 

Save setttings to file.

Opens and scans file. Only rewrite values in file to new values. Doesn't add any new variables. Note that indentation may change but all data including comments are kept.

Parameters:
filename filename
Returns:
true if sucessfull

Definition at line 71 of file settings.cpp.

References assertL, TiXmlElement::Attribute(), TiXmlHandle::Element(), exist(), TiXmlHandle::FirstChild(), getString(), TiXmlDocument::LoadFile(), LOGE, LOGW, TIN, and TVARIABLE2.

Referenced by Application::saveUserConfigFile().

Here is the call graph for this function:

template<class T>
void Settings::set const std::string &  key,
const T &  val
 

Definition at line 202 of file settings.cpp.

References set().

Here is the call graph for this function:

void Settings::set const std::string &  key,
const std::string &  value
 

Definition at line 130 of file settings.cpp.

References m_map.

Referenced by CommanderClient::command_setvar(), loadSettings(), and set().


Member Data Documentation

map<string, string> Settings::m_map [private]
 

Definition at line 101 of file settings.h.

Referenced by exist(), find(), and set().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:23:04 2006 for bjs by  doxygen 1.4.5