Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index

Class: UserInterface

This is a base class.

Description:
This is an abstract base class for a generic user interface. It provides a framework for obtaining string or numerical parameters by keyword and for setting their defaults. It also provides methods for opening [io]streams which can refer to files or stdout/stderr.

Sub-classes must define the two pure virtual methods which obtain the parameter values from the command line, a parameter file, or some other source.

Embedded Classes:
UserInterface::Exception, UserInterface::Value, UserInterface::Double, UserInterface::Integer, UserInterface::String, UserInterface::Boolean

Data Fields
publicprivate: map<string,UserInterface::Value*>defaults
publicvector<ios*>streams

Constructors / Destructor
public UserInterface()
Constructor.
public ~UserInterface()
Destructor - delete temporary storage.

Methods
public virtual void setDefaultValue(const string& key, UserInterface::Value* value)
public virtual void setDefault(const string& key, double value)
Set a default value for a given keyword.
public virtual void setDefault(const string& key, int value)
Set a default value for a given keyword.
public virtual void setDefault(const string& key, long value)
Set a default value for a given keyword.
public virtual void setDefault(const string& key, bool value)
Set a default value for a given keyword.
public virtual void setDefault(const string& key, const string& value)
Set a default value for a given keyword.
public virtual void setDefault(const string& key, const char* value)
Set a default value for a given keyword.
public virtual UserInterface::Value* getValue(const string& key)
Return a Value object containing the value associated with the given key. First it tries to extract the value in an interface dependant way. If this fails, it returns the default value, if there was one. If that fails it returns a NULL pointer.
Throws: UserInterface::Exception
public virtual double getReal(const string& key)
Return the value associated with a key interpreted as a double.
Throws: UserInterface::Exception
public virtual long getInteger(const string& key)
Return the value associated with a key interpreted as an integer.
Throws: UserInterface::Exception
public virtual bool getBoolean(const string& key)
Return the value associated with a key interpreted as a bool.
Throws: UserInterface::Exception
public virtual const string& getString(const string& key)
Return the value associated with a key interpreted as an integer.
Throws: UserInterface::Exception
public virtual istream* getIstream(const string& key, ios::openmode mode=ios::in|ios::binary)
Throws: UserInterface::Exception
public virtual ostream* getOstream(const string& key, ios::openmode mode=ios::out|ios::binary)
Throws: UserInterface::Exception
public pure virtual UserInterface::Value* extract(const string& key)
Throws: UserInterface::Exception
public pure virtual void setValue(const string& key, UserInterface::Value* value)
Throws: UserInterface::Exception
public virtual void set(const string& key, double value)
Set a value for a given keyword.
Throws: UserInterface::Exception
public virtual void set(const string& key, long value)
Set a value for a given keyword.
Throws: UserInterface::Exception
public virtual void set(const string& key, bool value)
Set a value for a given keyword.
Throws: UserInterface::Exception
public virtual void set(const string& key, const string& value)
Set a value for a given keyword.
Throws: UserInterface::Exception

Operators


Alphabetic Class Index   |   Class Inheritance Tree Index   |   Tool Index