Public Member Functions | Private Types | Private Member Functions | Private Attributes

Configuration Class Reference

Configuration Parser. More...

#include <Configuration.h>

List of all members.

Public Member Functions

 Configuration ()
 ~Configuration ()
void saveConfig ()
void loadConfig (const std::string &filePath)
int getGraphicsWidth () const
int getGraphicsHeight () const
int getGraphicsColorDepth () const
int getGraphicsTextureQuality () const
bool isGraphicsFullscreen () const
bool isVsyncEnabled () const
void setGraphicsWidth (int width)
void setGraphicsHeight (int height)
void setGraphicsColorDepth (int bpp)
void setGraphicsTextureQuality (const std::string &quality)
void isGraphicsFullscreen (bool isFullscreen)
void isVsyncEnabled (bool isVsync)
std::string getRenderer () const
int getAudioMixRate () const
int getAudioStereoChannels () const
int getAudioSfxVolume () const
int getAudioMusicVolume () const
int getAudioBufferSize () const
void setAudioMixRate (int mixrate)
void setAudioStereoChannels (int channels)
void setAudioSfxVolume (int sfxVolume)
void setAudioMusicVolume (int musicVolume)
void setAudioBufferSize (int audioBuffer)
std::string getGuiOption (const std::string &key)
AbsCoordinate getGuiPosition (const std::string &key)
void setGuiOption (const std::string &key, const std::string &value)
void setGuiPosition (const std::string &key, const AbsCoordinate &position)
void clearGuiOption (const std::string &key)
void clearGuiPosition (const std::string &key)
void setDefaultValues ()

Private Types

typedef std::map< string, string > GuiOptionTable
typedef std::map< string,
AbsCoordinate
GuiPositionTable

Private Member Functions

 Configuration (const Configuration &)
Configurationoperator= (const Configuration &)
void writeConfig ()
bool readConfig (const std::string &filePath)
bool parseGraphics (TiXmlNode *node)
bool parseAudio (TiXmlNode *node)
bool parseGuiOptions (TiXmlNode *node)
bool parseGuiOption (TiXmlNode *node)
bool parseGuiPosition (TiXmlNode *node)

Private Attributes

GuiOptionTable mGuiOptions
GuiPositionTable mGuiPositions
TiXmlDocument * mConfigFile
int mScreenWidth
int mScreenHeight
int mScreenBpp
int mTextureQuality
bool mFullScreen
bool mVSync
std::string mRendererName
int mMixRate
int mStereoChannels
int mSfxVolume
int mMusicVolume
Uint mBufferLength
std::string mMixerName
bool mOptionChanged

Detailed Description

Configuration Parser.

Parses and interprets Configuration data stored in XML files (e.g., config.xml).


Member Typedef Documentation

typedef std::map<string, string> Configuration::GuiOptionTable [private]
typedef std::map<string, AbsCoordinate> Configuration::GuiPositionTable [private]

Constructor & Destructor Documentation

Configuration::Configuration (  ) 

Constructor.

Configuration::~Configuration (  ) 

Destructor

Configuration::Configuration ( const Configuration  )  [private]

Member Function Documentation

void Configuration::clearGuiOption ( const std::string &  key  ) 
void Configuration::clearGuiPosition ( const std::string &  key  ) 
int Configuration::getAudioBufferSize (  )  const

Returns the audio Buffer Length.

int Configuration::getAudioMixRate (  )  const

Returns the Audio Rate that should be used by the Mixer.

int Configuration::getAudioMusicVolume (  )  const

Returns the Volume Level for Music.

int Configuration::getAudioSfxVolume (  )  const

Returns the Volume Level for Sound Effects.

int Configuration::getAudioStereoChannels (  )  const

Returns Stereo or Mono

int Configuration::getGraphicsColorDepth (  )  const

Returns Color Depth.

int Configuration::getGraphicsHeight (  )  const

Returns screen Height.

int Configuration::getGraphicsTextureQuality (  )  const

Returns texture render quality.

Note:
Equivalent to GL_NEAREST or GL_LINEAR
int Configuration::getGraphicsWidth (  )  const

Returns screen Width.

string Configuration::getGuiOption ( const std::string &  key  ) 

Gets a GUI option value given a key.

Parameters:
key An alphanumeric key to search for.
Returns:
A string containing the requested value. An empty string if the requested value was not found.
Note:
The search is case sensistive.
AbsCoordinate Configuration::getGuiPosition ( const std::string &  key  ) 

Gets a GUI Position value given a key.

Parameters:
key An alphanumeric key to search for.
Returns:
An AbsCoordinate object. An empty AbsCoordinate object if the requested value was not found.
Note:
The search is case sensistive.
std::string Configuration::getRenderer (  )  const

Returns the name of a Renderer.

void Configuration::isGraphicsFullscreen ( bool  isFullscreen  ) 

Toggles between windowed and fullscreen mode.

Todo:
Needs proper value and error checking.
bool Configuration::isGraphicsFullscreen (  )  const

Returns true if fullscreen mode is requested.

bool Configuration::isVsyncEnabled (  )  const

Returns true if vsync mode is requested.

void Configuration::isVsyncEnabled ( bool  isVsync  ) 

Toggles the use of Vertical Sync.

Todo:
Needs proper value and error checking.
void Configuration::loadConfig ( const std::string &  filePath  ) 

Loads a configuration file.

Parameters:
filePath A string indicating the file to load and process for configuration.
Configuration& Configuration::operator= ( const Configuration  )  [private]
bool Configuration::parseAudio ( TiXmlNode *  node  )  [private]

Parses audio information from an XML node.

bool Configuration::parseGraphics ( TiXmlNode *  node  )  [private]

Parse the <graphics> tab.

Todo:
Check for sane configurations, particularly screen resolution.
bool Configuration::parseGuiOption ( TiXmlNode *  node  )  [private]
bool Configuration::parseGuiOptions ( TiXmlNode *  node  )  [private]
bool Configuration::parseGuiPosition ( TiXmlNode *  node  )  [private]
bool Configuration::readConfig ( const std::string &  filePath  )  [private]
void Configuration::saveConfig (  ) 
void Configuration::setAudioBufferSize ( int  audioBuffer  ) 

Sets the size of the audio buffer.

Todo:
Needs proper value and error checking.
void Configuration::setAudioMixRate ( int  mixrate  ) 

Sets the audio mixrate.

Todo:
Needs proper value and error checking.
void Configuration::setAudioMusicVolume ( int  musicVolume  ) 

Sets the Music volume.

Todo:
Needs proper value and error checking.
void Configuration::setAudioSfxVolume ( int  sfxVolume  ) 

Sets the Sound Effects volume.

Todo:
Needs proper value and error checking.
void Configuration::setAudioStereoChannels ( int  channels  ) 

Sets the number of sound channels.

Todo:
Needs proper value and error checking.
void Configuration::setDefaultValues (  ) 

Sets default values for all important values.

void Configuration::setGraphicsColorDepth ( int  bpp  ) 

Sets the screen depth.

Todo:
Needs proper value and error checking.
void Configuration::setGraphicsHeight ( int  height  ) 

Sets the screen height.

Todo:
Needs proper value and error checking.
void Configuration::setGraphicsTextureQuality ( const std::string &  quality  ) 
void Configuration::setGraphicsWidth ( int  width  ) 

Sets the screen width.

Todo:
Needs proper value and error checking.
void Configuration::setGuiOption ( const std::string &  key,
const std::string &  value 
)

Sets a GUI Option.

Parameters:
key Name of the option to set.
value Value to give the named option.
void Configuration::setGuiPosition ( const std::string &  key,
const AbsCoordinate position 
)

Sets a GUI Position.

Parameters:
key Name of the option to set.
position Coordinates of a named object.
void Configuration::writeConfig (  )  [private]

Writes all stored values to disk.


Member Data Documentation

Audio Buffer Length

TiXmlDocument* Configuration::mConfigFile [private]

Screen Mode

Table of GUI Options.

Table of GUI Positions.

std::string Configuration::mMixerName [private]

Renderer to use.

int Configuration::mMixRate [private]

Audio Volume Levels

Flags whether or not an option was changed.

std::string Configuration::mRendererName [private]

Renderer to use.

Color Depth

Screen Resolution

Either AUDIO_STEREO or AUDIO_MONO

Texture render quality -- equivalent to GL_NEAREST and GL_LINEAR

bool Configuration::mVSync [private]

Vertical Sync


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines