VPTissue Reference Manual
SimPT_Shell::PTreeComparison Class Reference

Collection of functions for recursively comparing ptrees, with some 'array' semantics applied. More...

#include <PTreeComparison.h>

Collaboration diagram for SimPT_Shell::PTreeComparison:
Collaboration graph

Static Public Member Functions

static bool CompareArray (ptree const &pt1, ptree const &pt2, double acceptable_diff)
 Test if ordered list of children of both ptrees are equal, i.e. More...
 
static bool CompareNonArray (ptree const &pt1, ptree const &pt2, double acceptable_diff)
 Test if every child in first ptree with certain key can also be found in second ptree under the same key, and vice versa. More...
 
static bool CompareRootValues (ptree const &pt1, ptree const &pt2, double acceptable_diff)
 Test if root values of both ptrees are equal, with the possibility of having some tolerance for small differences in case both root values are floats. More...
 

Detailed Description

Collection of functions for recursively comparing ptrees, with some 'array' semantics applied.

Because all data in a ptree is both ordered (sequential) and unordered (mapped by a key) at the same time, we apply the semantics that, if a subtree path ends with "_array", the order of its children is semantically taken into account. For 2 'array' subtrees to be equal, we thus require all children to be present in the same order in both subtrees. If a subtree path does not end with "_array", we just want all values with a certain key to be found under the same key in the subtree it is compared with.

This is all done recursively: For instance, the ordered items of an array can, in its turn, be arrays or unordered subtrees, and the unordered items of an indexed subtree can be arrays or unordered subtrees. The right compare method is selected on each recursion.

Definition at line 43 of file PTreeComparison.h.

Member Function Documentation

bool SimPT_Shell::PTreeComparison::CompareArray ( ptree const &  pt1,
ptree const &  pt2,
double  acceptable_diff 
)
static

Test if ordered list of children of both ptrees are equal, i.e.

lenghts must be the same, and every item in one ptree must occur in the other at the same index.

Root values of children are compared using CompareRootValues. On top of that, recursively compares children of both ptrees: When a key under which a child ptree is found ends with the suffix "_array", CompareArray is used. Otherwise, CompareNonArray is used.

Parameters
pt1First ptree.
pt2Second ptree.
acceptable_diffLargest tolerated difference between root values of children in both ptrees.
Returns
Whether both ptrees tested equal.

Definition at line 88 of file PTreeComparison.cpp.

bool SimPT_Shell::PTreeComparison::CompareNonArray ( ptree const &  pt1,
ptree const &  pt2,
double  acceptable_diff 
)
static

Test if every child in first ptree with certain key can also be found in second ptree under the same key, and vice versa.

Comparison is RECURSIVE, see PTreeComparison::CompareArray for details.

Parameters
pt1First ptree.
pt2Second ptree.
acceptable_diffLargest tolerated difference between root values of children in both ptrees.
Returns
Whether both ptrees tested equal.

Definition at line 126 of file PTreeComparison.cpp.

bool SimPT_Shell::PTreeComparison::CompareRootValues ( ptree const &  pt1,
ptree const &  pt2,
double  acceptable_diff 
)
static

Test if root values of both ptrees are equal, with the possibility of having some tolerance for small differences in case both root values are floats.

Does NOT recursively compare children of the given ptrees.

Parameters
pt1First ptree.
pt2Second ptree.
acceptable_diffLargest tolerated difference between root values if both are float type.
Returns
Whether root values tested equal.

Definition at line 42 of file PTreeComparison.cpp.


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