Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LangmuirCore::KeyValueParser Class Reference

A class to read the parameters and store them in the correct place. More...

#include <keyvalueparser.h>

Public Member Functions

 KeyValueParser (World &world, QObject *parent=0)
 Create a KeyValueParser. More...
 
 ~KeyValueParser ()
 Destroy the KeyValueParser. More...
 
SimulationParametersparameters ()
 Get the SimulationParameters. More...
 
void parse (const QString &line)
 Parse a string and assign a value to the correct parameter. More...
 
void save (const QString &fileName="%stub.parm")
 Write the parameters to a file in a "key=value" fashion. More...
 
VariablegetVariable (const QString &key)
 Get a reference to a variable by name. More...
 
const QMap< QString, Variable * > & getVariableMap () const
 get the variable map More...
 
const QStringList & getOrderedNames () const
 get list of ordered keys More...
 
QString toQString ()
 convert parameters to a QString More...
 

Private Member Functions

template<typename T >
void registerVariable (const QString &key, T &value, Variable::VariableMode mode=0)
 Register an allowed variable with the parser. More...
 

Private Attributes

QMap< QString, Variable * > m_variableMap
 A map between variable names and variables. More...
 
QStringList m_orderedNames
 A list of variable names in a specific order. More...
 
SimulationParameters m_parameters
 The simulation parameters. More...
 
Worldm_world
 Reference to World object. More...
 

Friends

std::ostream & operator<< (std::ostream &stream, const KeyValueParser &keyValueParser)
 Write the parameters to a std::ostream in a "key=value" fashion. More...
 
QDebug operator<< (QDebug dbg, KeyValueParser &keyValueParser)
 Write the parameters to QDebug in a "key=value" fashion. More...
 

Detailed Description

A class to read the parameters and store them in the correct place.

The location of the SimulationParameters object for the entire simulation is a private variable of this class.

To add new variables, follow these steps:

Constructor & Destructor Documentation

LangmuirCore::KeyValueParser::KeyValueParser ( World world,
QObject *  parent = 0 
)

Create a KeyValueParser.

Parameters
worldreference to World Object
parentQObject this belongs to

Add calls to registerVariable() to add new variables to the simulation.

LangmuirCore::KeyValueParser::~KeyValueParser ( )

Destroy the KeyValueParser.

Member Function Documentation

const QStringList& LangmuirCore::KeyValueParser::getOrderedNames ( ) const

get list of ordered keys

Variable& LangmuirCore::KeyValueParser::getVariable ( const QString &  key)

Get a reference to a variable by name.

Parameters
keythe name of the variable
const QMap<QString,Variable*>& LangmuirCore::KeyValueParser::getVariableMap ( ) const

get the variable map

SimulationParameters& LangmuirCore::KeyValueParser::parameters ( )
void LangmuirCore::KeyValueParser::parse ( const QString &  line)

Parse a string and assign a value to the correct parameter.

template<typename T >
void LangmuirCore::KeyValueParser::registerVariable ( const QString &  key,
T &  value,
Variable::VariableMode  mode = 0 
)
private

Register an allowed variable with the parser.

void LangmuirCore::KeyValueParser::save ( const QString &  fileName = "%stub.parm")

Write the parameters to a file in a "key=value" fashion.

QString LangmuirCore::KeyValueParser::toQString ( )

convert parameters to a QString

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const KeyValueParser keyValueParser 
)
friend

Write the parameters to a std::ostream in a "key=value" fashion.

QDebug operator<< ( QDebug  dbg,
KeyValueParser keyValueParser 
)
friend

Write the parameters to QDebug in a "key=value" fashion.

Member Data Documentation

QStringList LangmuirCore::KeyValueParser::m_orderedNames
private

A list of variable names in a specific order.

SimulationParameters LangmuirCore::KeyValueParser::m_parameters
private

The simulation parameters.

QMap<QString,Variable*> LangmuirCore::KeyValueParser::m_variableMap
private

A map between variable names and variables.

World& LangmuirCore::KeyValueParser::m_world
private

Reference to World object.


The documentation for this class was generated from the following file: