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

mortic::IConfigManager Class Reference

The Configuration Manager. More...

Inheritance diagram for mortic::IConfigManager:

mortic::IObject List of all members.

Public Member Functions

 IConfigManager (IRoot *root)
 Constructor.
virtual ~IConfigManager ()
 Never use this, use drop().
virtual std::string getOption (std::string section, std::string key, std::string def)=0
 Get an option from the file.
template<typename T>
getOption (std::string section, std::string key, T def)
 Get a converted option.
virtual void setOption (std::string section, std::string key, std::string value)=0
 Set an option.
template<typename T>
void setOption (std::string section, std::string key, T value)
 Set a converted option.

Detailed Description

The Configuration Manager.

This class deals with the configuration XML file. It loads the options at start up, and then the options can be messed with while the game is running. Currently there is no way to reload options in all the other parts of the engine. When mortic shuts down, this manager saves all the changes to configuration. This is a simple settings.xml file:

        <MorticConfig>
          <Section1>
            <option1>value1</option1>
            <option2>value2</option2>
          </Section1>
          <Section2>
            <option3>value3</option3>
          </Section2>
        </MorticConfig>
Any examples in the documentation below will be based off this settings.xml example. You should always get this class from IRoot::getConfigManager().

Definition at line 91 of file IConfigManager.h.


Constructor & Destructor Documentation

mortic::IConfigManager::IConfigManager IRoot root  )  [inline]
 

Constructor.

Do not use this, ever.

  • root - the root to be assigned to

Definition at line 98 of file IConfigManager.h.

virtual mortic::IConfigManager::~IConfigManager  )  [inline, virtual]
 

Never use this, use drop().

Definition at line 104 of file IConfigManager.h.


Member Function Documentation

template<typename T>
T mortic::IConfigManager::getOption std::string  section,
std::string  key,
def
[inline]
 

Get a converted option.

This function is identical to getOption(std::string section, std::string key, std::string def), but it converts the value to something else beforehand, for example, an integer.

Definition at line 130 of file IConfigManager.h.

References getOption().

virtual std::string mortic::IConfigManager::getOption std::string  section,
std::string  key,
std::string  def
[pure virtual]
 

Get an option from the file.

This function gets the value from a certain key and section. It also has a default return if the option is not found. In that case, the default is written to the file as the option. For example, with the file above, section "Section2", option "option3", has value "value3". But, if I look for "Section 2, option4" with a default of "wohba", the manager will make this option and set it to "wohba" for me when it rewrites it.

  • section - the section to look in
  • key - the name of the value to get
  • def - the default if the value doesn't exist
    Returns:
    the value, or def if it doesn't exist

Referenced by getOption().

template<typename T>
void mortic::IConfigManager::setOption std::string  section,
std::string  key,
value
[inline]
 

Set a converted option.

This function is identical to setOption(std::string section, std::string key, std::string value), except it accepts any value, not just strings.

Definition at line 157 of file IConfigManager.h.

References setOption().

virtual void mortic::IConfigManager::setOption std::string  section,
std::string  key,
std::string  value
[pure virtual]
 

Set an option.

This function sets a value in the file based off the given section and key.

  • section - the section to write in
  • key - the key to set
  • value - the value to set key to

Referenced by setOption().


Generated on Sat Dec 30 21:21:59 2006 for mortic by  doxygen 1.4.4