UAPUtilities Class Reference

A collection of utility methods for dealing with various UAP model activities. More...

#include <UAPUtilities.hpp>

Collaboration diagram for UAPUtilities:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 UAPUtilities (UAPNode *_UAPRootNode)
 Creates a new collection of utilities for use with the specified UAPNode.
 ~UAPUtilities ()
 Destructor.
void setUAPRootNode (UAPNode *_UAPRootNode)
 Sets the root UAP node to use for this class.
UAPNodegetUAPRootNode ()
 Returns the root UAP node used by this class.
int evaluate ()
 Evaluates arithmetic expressions.
int evaluate (UAPNode *node, UAPNode *context=0)
 Evaluates arithmetic expressions starting from the specified node.
double evaluate (const std::string attrib, UAPNode *context=NULL) throw (UAPParserException)
 Returns the evaluted value of the specified attribute.
int getParameterValue (UAPNode *node, std::string &param_name, std::string &param_value)
 Returns the value for the specified parameter or controller element.
void addConstant (const std::string &name, double value, bool allow_overwrite=false)
 Appends the specified constant to the list of constants.
int removeConstant (const std::string &name)
 Removes the constant with the specified name from the list of constants.
std::list< std::string > parseIdentifiers (const std::string &expr) throw (UAPParserException)
 Parses the specified expression and returns a list of identifiers in the expression.
double nextGaussian ()
 Returns the next pseudorandom, Gaussian distributed, number with mean 0.0 and variance 1.0.
double nextDouble ()
 Returns the next pseudorandom number between 0.0 and 1.0.


Detailed Description

A collection of utility methods for dealing with various UAP model activities.

Author:
Andy Wolski, Daniel Bates, David Sagan

Definition at line 51 of file UAPUtilities.hpp.


Constructor & Destructor Documentation

UAPUtilities::UAPUtilities ( UAPNode _UAPRootNode  ) 

Creates a new collection of utilities for use with the specified UAPNode.

Parameters:
_UAPRootNode the root node of the UAP model
See also:
UAPNode

Definition at line 42 of file UAPUtilities.cpp.

UAPUtilities::~UAPUtilities (  ) 

Destructor.

Definition at line 61 of file UAPUtilities.cpp.


Member Function Documentation

void UAPUtilities::addConstant ( const std::string &  name,
double  value,
bool  allow_overwrite = false 
)

Appends the specified constant to the list of constants.

If the argument allow_overwrite is true any existing value for the constant will be overwritten with specified value.

Parameters:
name The name of the constant
value The value of the constant
allow_overwrite true to overwrite the value of the constant if it exists; false otherwise (default: false).

Definition at line 209 of file UAPUtilities.cpp.

double UAPUtilities::evaluate ( const std::string  attrib,
UAPNode context = NULL 
) throw (UAPParserException)

Returns the evaluted value of the specified attribute.

Parameters:
attrb The attribute to evaluate
context The UAPNode object to use to resolve element attribute names (default: NULL)
Returns:
The evaluted value of the attribute.
Exceptions:
UAPParserException if evaluation failed

The result of this evaluation.

The chain of exceptions for missing parameters.

Definition at line 153 of file UAPUtilities.cpp.

int UAPUtilities::evaluate ( UAPNode node,
UAPNode context = 0 
)

Evaluates arithmetic expressions starting from the specified node.

This method reduces all arithmetic expressions to a constant.

Parameters:
node The node to evaluate
context The UAPNode object to use to resolve element attribute names (default: NULL)
Returns:
-1.

Definition at line 98 of file UAPUtilities.cpp.

int UAPUtilities::evaluate (  ) 

Evaluates arithmetic expressions.

This method reduces all arithmetic expressions to a constant starting from the root node.

Returns:
see evaluate(UAPNode)

Definition at line 93 of file UAPUtilities.cpp.

int UAPUtilities::getParameterValue ( UAPNode node,
std::string &  param_name,
std::string &  param_value 
)

Returns the value for the specified parameter or controller element.

This method stores the value of the specified parameter in the variable specified by the argument param_value.

Parameters:
node The root node for the search for a parameter with name = param_name.
param_name The parameter name.
param_value The variable to store the value.
See also:
UAPNode

Definition at line 73 of file UAPUtilities.cpp.

UAPNode * UAPUtilities::getUAPRootNode (  ) 

Returns the root UAP node used by this class.

Returns:
the root node.
See also:
UAPNode

Definition at line 68 of file UAPUtilities.cpp.

double UAPUtilities::nextDouble (  ) 

Returns the next pseudorandom number between 0.0 and 1.0.

Returns:
the next pseudorandom number.

Definition at line 248 of file UAPUtilities.cpp.

double UAPUtilities::nextGaussian (  ) 

Returns the next pseudorandom, Gaussian distributed, number with mean 0.0 and variance 1.0.

Returns:
the next pseudorandom number.

Definition at line 243 of file UAPUtilities.cpp.

list< string > UAPUtilities::parseIdentifiers ( const std::string &  expr  )  throw (UAPParserException)

Parses the specified expression and returns a list of identifiers in the expression.

Parameters:
expr the expression to parse
Returns:
a list of identifier in the expression.
Exceptions:
UAPParserException if the expression is malformed or invalid

Definition at line 228 of file UAPUtilities.cpp.

int UAPUtilities::removeConstant ( const std::string &  name  ) 

Removes the constant with the specified name from the list of constants.

Parameters:
name the name of the constant
Returns:
-1 if constant was removed; 0 if the constant does not exist.

Definition at line 219 of file UAPUtilities.cpp.

void UAPUtilities::setUAPRootNode ( UAPNode _UAPRootNode  ) 

Sets the root UAP node to use for this class.

Parameters:
_UAPRootNode the node
See also:
UAPNode

Definition at line 63 of file UAPUtilities.cpp.


Generated on Fri Feb 12 15:47:58 2010 for Universal Accelerator Parser by  doxygen 1.5.7