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

ONE::util::EngineOptions Class Reference

Inheritance diagram for ONE::util::EngineOptions:

Inheritance graph
[legend]
List of all members.

Detailed Description

Options singleton for engine-related options

The options are read at system startup and saved at shutdown.

Author:
Daniel Seibert


Public Types

typedef std::map< std::string,
OptionValue > 
Map

Public Member Functions

void clear ()
OptionValue get (const std::string &key, OptionValue def=0, bool add=false)
 retrieves a value
void load (const std::string &file, bool clear=true)
 loads settings from file
void reload (bool clearOld=true)
 reloads the options from OPTIONS_FILE
void remove (const std::string &key)
void save (const std::string &file) const
 saves settings to a file
void set (const std::string &key, OptionValue val)
 sets a value

Static Public Member Functions

static void destroyInstance ()
 may be used to manually destroy the singleton instance
static EngineOptionsgetInstance ()
 accesses the singleton instance
static bool isActive ()
 checks if the singleton is active
static bool isDestroyed ()
 checks if the singleton is destroyed
static bool isVirgin ()
 checks if the singleton has not been initialized

Public Attributes

Map options

Static Public Attributes

static const std::string OPTIONS_FILE

Protected Member Functions

 Singleton ()

Static Protected Member Functions

static void destroyedError ()
static void initInstance ()


Member Typedef Documentation

typedef std::map<std::string,OptionValue> ONE::util::Options::Map [inherited]
 


Member Function Documentation

void ONE::util::Options::clear  )  [inherited]
 

static void ONE::util::Automatic< EngineOptions >::destroyedError  )  [static, protected, inherited]
 

static void ONE::util::Automatic< EngineOptions >::destroyInstance  )  [static, inherited]
 

may be used to manually destroy the singleton instance

If this function is not called, the instance is destroyed automatically during shutdown.

OptionValue ONE::util::Options::get const std::string &  key,
OptionValue  def = 0,
bool  add = false
[inherited]
 

retrieves a value

If key is unknown, this function returns def. The returned value is implicitly converted to any of the types listed in the class description above. However, attempting to assign the return value to a different type that it contains will result in an error.

Parameters:
key the desired option
def an optional default value
add if true, adds def to the options table if key is not found

static EngineOptions * ONE::util::Singleton< EngineOptions , Automatic >::getInstance  )  [static, inherited]
 

accesses the singleton instance

The exact operation executed by calling this function is determined by the singleton policies.

Returns:
a pointer to the singleton instance

static void ONE::util::Automatic< EngineOptions >::initInstance  )  [static, protected, inherited]
 

static bool ONE::util::Singleton< EngineOptions , Automatic >::isActive  )  [static, inherited]
 

checks if the singleton is active

Returns:
if the singleton is instantiated

static bool ONE::util::Singleton< EngineOptions , Automatic >::isDestroyed  )  [static, inherited]
 

checks if the singleton is destroyed

This function returns true if an instance existed and was destroyed. Note that in some cases it is possible to revive a singleton.

Returns:
if the singleton is destroyed

static bool ONE::util::Singleton< EngineOptions , Automatic >::isVirgin  )  [static, inherited]
 

checks if the singleton has not been initialized

A singleton is not initialized if no instance exists and no instance has been destroyed.

Returns:
if the singleton is untouched

void ONE::util::Options::load const std::string &  file,
bool  clear = true
[inherited]
 

loads settings from file

If clear is true (the default), present settings are cleared before loading.

Exceptions:
IOException if the file cannot be read

void ONE::util::EngineOptions::reload bool  clearOld = true  ) 
 

reloads the options from OPTIONS_FILE

Parameters:
clearOld true to clear the old settings before reloading, false to keep them
Exceptions:
IOException if loading fails

void ONE::util::Options::remove const std::string &  key  )  [inherited]
 

void ONE::util::Options::save const std::string &  file  )  const [inherited]
 

saves settings to a file

Exceptions:
IOException if the file cannot be written

void ONE::util::Options::set const std::string &  key,
OptionValue  val
[inherited]
 

sets a value

If key is already present, its value is overwritten. Supported values may be direcly passed to this function; instead of

 set("foo",OptionValue(true)); 
write
 set("foo",true); 

ONE::util::Singleton< EngineOptions , Automatic >::Singleton  )  [protected, inherited]
 


Member Data Documentation

Map ONE::util::Options::options [inherited]
 

const std::string ONE::util::EngineOptions::OPTIONS_FILE [static]
 


Generated on Wed Sep 7 19:03:31 2005 for ONEngine by  doxygen 1.4.3