VAPoR  3.0.0
Public Member Functions | List of all members
VAPoR::ParamNode Class Reference

An Xml tree. More...

#include <ParamNode.h>

Inheritance diagram for VAPoR::ParamNode:

Public Member Functions

int SetElementDouble (const string &tag, double value)
 
int SetElementDouble (const string &tag, const vector< double > &values)
 
int SetElementDouble (const vector< string > &tagpath, const vector< double > &values)
 
virtual const vector< double > GetElementDouble (const vector< string > &tagpath, const vector< double > &defaultVal=XmlNode::_emptyDoubleVec)
 
virtual const vector< double > GetElementDouble (const string &tag, const vector< double > &defaultVal=XmlNode::_emptyDoubleVec)
 
int SetElementLong (const string &tag, const vector< long > &values)
 
int SetElementLong (const string &tag, long value)
 
int SetElementLong (const vector< string > &tagpath, const vector< long > &values)
 
virtual const vector< long > GetElementLong (const vector< string > &tagpath, const vector< long > &defaultVal=XmlNode::_emptyLongVec)
 
virtual const vector< long > GetElementLong (const string &tag, const vector< long > &defaultVal=XmlNode::_emptyLongVec)
 
int SetElementString (const string &tag, const string &value)
 
int SetElementString (const vector< string > &tagpath, const string &value)
 
int SetElementStringVec (const string &tag, const vector< string > &values)
 
int SetElementStringVec (const vector< string > &tagpath, const vector< string > &values)
 
virtual const string GetElementString (const string &tag, const string &defaultVal=XmlNode::_emptyString)
 
virtual const string GetElementString (const vector< string > &tagpath, const string &defaultVal=XmlNode::_emptyString)
 
virtual void GetElementStringVec (const vector< string > &tagpath, vector< string > &vec, const vector< string > &defaultVal=_emptyStringVec)
 
virtual void GetElementStringVec (const string &tag, vector< string > &vec, const vector< string > &defaultVal=_emptyStringVec)
 
int AddNode (const string &tag, ParamNode *child)
 
int InsertNode (const string &tag, ParamNode *child, int index)
 
int AddNode (const vector< string > &tagpath, ParamNode *child)
 
ParamNodeGetChild (size_t index) const
 
ParamNodeGetNode (const vector< string > &tagpath)
 
ParamNodeGetNode (const string &tag) const
 
int ReplaceNode (const vector< string > &tagpath, ParamNode *newNode)
 
int ReplaceNode (const string &tag, ParamNode *newNode)
 
int DeleteNode (const string &tag)
 
int DeleteNode (const vector< string > &tagpath)
 
int DeleteChildren (const string &tag)
 
int DeleteChildren (const vector< string > &tagpath)
 
void SetParamsBase (ParamsBase *pBase)
 
ParamsBaseGetParamsBase () const
 
Internal

Internal methods not intended for general use

 ParamNode (const string &tag, const map< string, string > &attrs, size_t numChildrenHint=0)
 
 ParamNode (const string &tag, size_t numChildrenHint=0)
 
virtual ParamNodeConstruct (const string &tag, const map< string, string > &attrs, size_t numChildrenHint=0)
 
 ParamNode (const ParamNode &pn)
 
ParamNodeNodeCopy ()
 
ParamNodeShallowCopy ()
 Copy only the ParamNode itself, not any of its children. More...
 
virtual ParamNodedeepCopy ()
 
virtual ~ParamNode ()
 

Detailed Description

An Xml tree.

Author
John Clyne
Version
$Revision$
Date
$Date$

This class extends the XmlNode class. The XML hierarchy includes pointers to ParamsBase instances, enabling use of classes embedded in Params instances.

Definition at line 30 of file ParamNode.h.

Constructor & Destructor Documentation

VAPoR::ParamNode::ParamNode ( const string &  tag,
const map< string, string > &  attrs,
size_t  numChildrenHint = 0 
)

Constructor for the ParamNode class.

Create a new ParamNode node

Parameters
[in]tagName of ParamNode node
[in]attrsA list of Xml attribute names and values for this node
[in]numChildrenHintReserve space for the indicated number of children. Children must be created with the NewChild() method
VAPoR::ParamNode::ParamNode ( const string &  tag,
size_t  numChildrenHint = 0 
)
VAPoR::ParamNode::ParamNode ( const ParamNode pn)

Copy constructor for the ParamNode class.

Creates a new ParamNode node from an existing one.

Parameters
[in]pnParamNode instance from which to construct a copy
virtual VAPoR::ParamNode::~ParamNode ( )
virtual

Member Function Documentation

int VAPoR::ParamNode::AddNode ( const string &  tag,
ParamNode child 
)

Add an existing node as a child of the current node. The new child node will be appended to the array of child nodes.

Note
This method differs from the base class method that it overloads in that it prohibits siblings from having duplicate tags.
Parameters
[in]tagis the tag that will identify the new node
[in]childis the ParamNode object to be added as a child
Return values
statusReturn 0 upon success. A negative number is returned if a sibling already exists with the same name.
int VAPoR::ParamNode::AddNode ( const vector< string > &  tagpath,
ParamNode child 
)

Add an existing node as a last child of a path of nodes starting at the current

The new child node will be appended to the array of child nodes of the final node.

Note
This method differs from the base class method that it overloads in that it prohibits siblings from having duplicate tags.
Parameters
[in]tagpathis vector of tags specifying path to the new node
[in]childis the ParamNode object to be added as a child
Return values
statusReturn 0 upon success. A negative number is returned if a sibling already exists with the same name, or if one of the specified nodes in the path sequence does not already exist
virtual ParamNode* VAPoR::ParamNode::Construct ( const string &  tag,
const map< string, string > &  attrs,
size_t  numChildrenHint = 0 
)
inlinevirtual

Construct a new ParamNode node

Parameters
[in]tagName of ParamNode node
[in]attrsA list of Xml attribute names and values for this node
[in]numChildrenHintReserve space for the indicated number of
Return values
nodeNewly constructed ParamNode

Definition at line 64 of file ParamNode.h.

virtual ParamNode* VAPoR::ParamNode::deepCopy ( )
virtual

Like copy constructor for the ParamNode class, but in addition to cloning the child nodes in xml hierarchy, also clones the ParamsBase instances that are referenced by child nodes

Creates a new ParamNode node from an existing one.

Return values
nodeParamNode copied from this

Referenced by VAPoR::Command::CaptureEnd().

int VAPoR::ParamNode::DeleteChildren ( const string &  tag)

Delete all children of the indicated node and all their descendants.

Parameters
[in]tagName of the node whose children will be deleted
Return values
statusReturn 0 if successful, -1 if child does not exist.
int VAPoR::ParamNode::DeleteChildren ( const vector< string > &  tagpath)

Delete all children of the indicated node and all their descendants. given a path to the child

Parameters
[in]tagpathPath to the child node to delete
Return values
statusReturn 0 if successful, -1 if child does not exist.
int VAPoR::ParamNode::DeleteNode ( const string &  tag)

Delete the indicated child node and all its descendants.

Parameters
[in]tagName of the child node to delete
Return values
statusReturn 0 if successful, -1 if child does not exist.
int VAPoR::ParamNode::DeleteNode ( const vector< string > &  tagpath)

Delete the indicated child node and all its descendants, based on a path to the child

Parameters
[in]tagpathPath to the child node to delete
Return values
statusReturn 0 if successful, -1 if child does not exist.
ParamNode* VAPoR::ParamNode::GetChild ( size_t  index) const
inline

Return the indicated child node.

Return the ith child of this node. The first child node is index=0, the last is index=GetNumChildren()-1. Return NULL if the child does not exist.

Parameters
[in]indexIndex of the child. The first child is zero
Return values
childReturns the indicated child, or NULL if the child could does not exist
See also
GetNumChildren()

Definition at line 413 of file ParamNode.h.

virtual const vector<double> VAPoR::ParamNode::GetElementDouble ( const vector< string > &  tagpath,
const vector< double > &  defaultVal = XmlNode::_emptyDoubleVec 
)
virtual

Get an element's data of type double

Return the character data associated with the Xml element identified by a sequence tagpath from this node. The data is interpreted and returned as a vector of doubles. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagpathsequence of tags leading to element
[in]defaultVal(optional) default vector<double> to be assigned if specified element does not exist
Return values
vectorVector of doubles associated with the named element
virtual const vector<double> VAPoR::ParamNode::GetElementDouble ( const string &  tag,
const vector< double > &  defaultVal = XmlNode::_emptyDoubleVec 
)
virtual

Get an Xml element's data of type double

Return the character data associated with the Xml elemented named by tag for this node. The data is interpreted and returned as a vector of doubles. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagName of element
[in]defaultVal(optional) default vector<double> to be assigned if specified element does not exist
Return values
vectorVector of doubles associated with the named element
virtual const vector<long> VAPoR::ParamNode::GetElementLong ( const vector< string > &  tagpath,
const vector< long > &  defaultVal = XmlNode::_emptyLongVec 
)
virtual

Get an Xml element's data of type long

Return the character data associated with the XML element reached via a sequence tagpath of nodes from this node. The data is interpreted and returned as a vector of longs. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagpathSequence of tags to element
[in]defaultVal(optional) vector<long> to be assigned if specified element does not exist.
Return values
vector<long>vector of longs associated with the named elemented
virtual const vector<long> VAPoR::ParamNode::GetElementLong ( const string &  tag,
const vector< long > &  defaultVal = XmlNode::_emptyLongVec 
)
virtual

Get an Xml element's data of type long

Return the character data associated with the Xml element named by tag for this node. The data is interpreted and returned as a vector of longs. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagName of element
[in]defaultVal(optional) Vector of longs that will be set if specified element does not exist
Return values
vectorVector of longs associated with the named elemented
virtual const string VAPoR::ParamNode::GetElementString ( const string &  tag,
const string &  defaultVal = XmlNode::_emptyString 
)
virtual

Get an Xml element's data of type string

Return the character data associated with the Xml elemented named by tag for this node. The data is interpreted and returned as a string. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagName of element
[in]defaultVal(optional) string to be assigned if specified element does not exist.
Return values
stringThe string associated with the named element
virtual const string VAPoR::ParamNode::GetElementString ( const vector< string > &  tagpath,
const string &  defaultVal = XmlNode::_emptyString 
)
virtual

Get an element's data of type string

Return the character data associated with the Xml element identified by tagpath for this node. The data is interpreted and returned as a string. If the element does not exist an empty vector is returned. If ErrOnMissing() is true an error is generated if the element is missing;

Parameters
[in]tagpathsequence of tags leading to element
[in]defaultVal(optional) string to be assigned if specified element does not exist.
Return values
stringThe string associated with the named element
virtual void VAPoR::ParamNode::GetElementStringVec ( const vector< string > &  tagpath,
vector< string > &  vec,
const vector< string > &  defaultVal = _emptyStringVec 
)
virtual

Get an element's data of type string vector using a path to node

Builds the string vector data associated with the Xml element identified by a sequence of tags tagpath from this node. The strings in the vector vec must not contain white characters. If the element does not exist an empty vector is returned

Parameters
[in]tagpathSequence of tags
[in]defaultVal(optional) vector<string> to be assigned if specified element does not exist.
[out]vecVector of strings associated with the named element
virtual void VAPoR::ParamNode::GetElementStringVec ( const string &  tag,
vector< string > &  vec,
const vector< string > &  defaultVal = _emptyStringVec 
)
virtual

Get an element's data of type string vector at the current node

Build the string vector data associated with the Xml element identified by a tag at this node. The strings in the vector vec must not contain white characters. If the element does not exist an empty vector is returned

Parameters
[in]tagNode tag
[in]defaultVal(optional) vector<string> to be assigned if specified element does not exist.
[out]vecVector of strings associated with the named element
ParamNode* VAPoR::ParamNode::GetNode ( const vector< string > &  tagpath)

Return the indicated child node based on a sequence of tags

Return the indicated tagged child node. Return NULL if the child does not exist.

Parameters
[in]tagpathSequence of nodes to specified child
Return values
childReturns the indicated child, or NULL if the child could does not exist

Referenced by VAPoR::IsolineParams::GetBox().

ParamNode* VAPoR::ParamNode::GetNode ( const string &  tag) const
inline

Return the indicated child node.

This method is useful whenever it is necessary to obtain data from a node in the XML hierarchy that is not the root node. For example, ParamsIso class instances are represented as XML hierarchies with a subnode for each of the variables in the VDC. In order to obtain the TransferFunction for one of these variables, one can use GetNode("var") to obtain the node associated with the variable "var", and then use GetNode(_transferFunctionTag) to obtain the XML node associated with the TransferFunction. Return the indicated tagged child node. Return NULL if the child does not exist.
Parameters
[in]tagName of the child node to return
Return values
childReturns the indicated child, or NULL if the child could does not exist

Definition at line 441 of file ParamNode.h.

ParamsBase* VAPoR::ParamNode::GetParamsBase ( ) const
inline

Get the ParamsBase node for which this is the root

The ParamsBase node is NULL unless this node is associated with a registered ParamsBase object.

Return values
Pointerto the ParamsBase node for which this is the root node
See also
SetParamsBase()

Definition at line 510 of file ParamNode.h.

Referenced by VAPoR::IsolineParams::GetBox().

int VAPoR::ParamNode::InsertNode ( const string &  tag,
ParamNode child,
int  index 
)

Insert an existing node as a child of the current node, at specified index

The new child node will be inserted into the array of child nodes.

Note
This method differs from the base class method that it overloads in that it prohibits siblings from having duplicate tags.
Parameters
[in]tagis the tag that will identify the new node
[in]childis the ParamNode object to be added as a child
[in]indexis the child index that will be used by the new child
Return values
statusReturn 0 upon success. A negative number is returned if a sibling already exists with the same name, or if the proposed index is not valid
ParamNode* VAPoR::ParamNode::NodeCopy ( )

Method that clones the ParamNode structure, using buildNode to construct the ParamNodes associated with registered ParamsBase instances in the ParamNode hierarchy

int VAPoR::ParamNode::ReplaceNode ( const vector< string > &  tagpath,
ParamNode newNode 
)

Replace the indicated child node based on a sequence of tags

Parameters
[in]tagpathSequence of nodes to specified child
[in]newNodeParamNode to install
Return values
statusReturns -1, if the child does not exist
int VAPoR::ParamNode::ReplaceNode ( const string &  tag,
ParamNode newNode 
)

Replace the indicated child node.

If child has a paramsBase instance, it is deleted.

Parameters
[in]tagName of the child node to replace
[in]newNodeParamNode to install
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementDouble ( const string &  tag,
double  value 
)

Set a single ParamNode parameter of type double

This method defines and sets a parameter of type double. The parameter data to be associated with tag is the single double specified by value

Parameters
[in]tagName of the element to define/set
[in]valuedouble
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementDouble ( const string &  tag,
const vector< double > &  values 
)

Set an ParamNode parameter of type double

This method defines and sets a parameter of type double. The parameter data data to be associated with tag is the array of double specified by values

Parameters
[in]tagName of the element to define/set
[in]valuesVector of doubles
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementDouble ( const vector< string > &  tagpath,
const vector< double > &  values 
)

Set an ParamNode parameter of type double This method defines and sets a parameter of type double. The parameter data data to be associated with tagpath is the array of double specified by values

Parameters
[in]tagpathNames of the nodes leading to the element to be set
[in]valuesVector of doubles
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementLong ( const string &  tag,
const vector< long > &  values 
)
int VAPoR::ParamNode::SetElementLong ( const string &  tag,
long  value 
)

Set a single ParamNode parameter of type long

This method defines and sets a parameter of type long. The paramter data data to be associated with tag is the single long specified by value

Parameters
[in]tagName of the element to define/set
[in]valuelong
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementLong ( const vector< string > &  tagpath,
const vector< long > &  values 
)

Set an ParamNode parameter of type long This method defines and sets a parameter of type long. The parameter data data to be associated with tagpath is the array of longs specified by values

Parameters
[in]tagpathNames of nodes leading to the value to be set
[in]valuesVector of longs
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementString ( const string &  tag,
const string &  value 
)

Set a single ParamNode parameter of type string

This method defines and sets a parameter of type string. The parameter data data to be associated with tag is the single string specified by value

Parameters
[in]tagName of the element to define/set
[in]valuestring
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementString ( const vector< string > &  tagpath,
const string &  value 
)

Set a single ParamNode parameter of type string This method defines and sets a parameter of type string. The parameter data data to be associated with tagpath is the single string specified by value

Parameters
[in]tagpathsequence of tags leading to specified element.
[in]valuestring
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementStringVec ( const string &  tag,
const vector< string > &  values 
)

Set an ParamNode parameter of type string vector

This method defines and sets a parameter of type string vector. The parameter data to be associated with tag is the array of strings specified by values The strings in the vector values must not contain white characters.

Parameters
[in]tagName(Tag) of the element to define/set
[in]valuesVector of strings
Return values
statusReturns 0 if successful
int VAPoR::ParamNode::SetElementStringVec ( const vector< string > &  tagpath,
const vector< string > &  values 
)

Set a ParamNode parameter of type string This method defines and sets a parameter of type string vector. The parameter data data to be associated with tagpath is the array of strings specified by values The strings in the vector values must not contain white characters.

Parameters
[in]tagpathNames of nodes leading to value to be set
[in]valuesVector of strings
Return values
statusReturns 0 if successful
void VAPoR::ParamNode::SetParamsBase ( ParamsBase pBase)
inline

Set a ParamsBase node for which this is the root

The ParamsBase node is NULL unless this node is associated with a registered ParamsBase object.

Parameters
[in]pBasePointer to the ParamsBase node for which this is the root node
See also
GetParamsBase()

Definition at line 500 of file ParamNode.h.

ParamNode* VAPoR::ParamNode::ShallowCopy ( )

Copy only the ParamNode itself, not any of its children.


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