Isis 3 Programmer Reference
Isis::ControlNetDiff Class Reference

Compares two Control Networks and reports their differences. More...

#include <ControlNetDiff.h>

Collaboration diagram for Isis::ControlNetDiff:
Collaboration graph

Public Member Functions

 ControlNetDiff ()
 Create a ControlNetDiff without any tolerances. More...
 
 ControlNetDiff (Pvl &diffFile)
 Create a ControlNetDiff with persistent tolerances. More...
 
virtual ~ControlNetDiff ()
 Destroy the ControlNetDiff. More...
 
void addTolerances (Pvl &diffFile)
 Add the given ignore keys and tolerances to the persisent collections of such values. More...
 
Pvl compare (FileName &net1Name, FileName &net2Name)
 Compare two Control Networks given their file names, and return their differences. More...
 

Protected Member Functions

void compare (PvlObject &point1Pvl, PvlObject &point2Pvl, PvlObject &report)
 Compare two Control Points stored as PvlObjects, and add any differences to the report object. More...
 
void compareGroups (PvlContainer &g1, PvlContainer &g2, PvlObject &report)
 Compare two collections, or groupings, of PvlKeywords. More...
 
void compare (PvlKeyword &k1, PvlKeyword &k2, PvlContainer &report)
 Compare two keywords and report the differences to the given report container. More...
 
void diff (QString name, PvlObject &o1, PvlObject &o2, PvlContainer &report)
 Add a new difference keyword to the given report if the PvlObjects have different values for the keyword with the given name. More...
 
void diff (QString name, QString v1, QString v2, PvlContainer &report)
 Add a new difference keyword to the given report if the two string are not equal. More...
 
PvlKeyword makeKeyword (QString name, QString v1, QString v2)
 Create a new keyword with the given label name and the given values. More...
 
void diff (QString name, double v1, double v2, double tol, PvlContainer &report)
 Add a new difference keyword to the given report if the two numerical values are not equal within the given tolerance. More...
 
PvlKeyword makeKeyword (QString name, double v1, double v2, double tol)
 Create a new keyword with the given label name and the given values. More...
 
void addUniquePoint (QString label, QString v1, QString v2, PvlObject &parent)
 Add a new keyword for the given point to the parent object. More...
 
void addUniqueMeasure (QString label, QString v1, QString v2, PvlObject &parent)
 Add a new keyword for the given measure to the parent object. More...
 

Private Member Functions

void init ()
 Initialize the persistent structures used to maintain the state of this instance: its ignore keys and tolerances. More...
 

Private Attributes

QMap< QString, double > * m_tolerances
 The map of tolerances going from keyword name to tolerance value. More...
 
QSet< QString > * m_ignoreKeys
 The set of keywords to ignore by name. More...
 

Detailed Description

Compares two Control Networks and reports their differences.

This class opens two Control Networks from Filenames and returns their differences as a PVL structure. It is generally stateless, able to compare multiple networks in succession without needing to reset anything. However, the tolerances that are added are persistent.

Differences will be reported as PvlKeywords with two to three values. The first value is from the first network, the second from the second network, and the third the failed tolerance (if provided). Control Point PVL Objects and Control Measure PVL Groups will only be reported if there are differences, or they appear in only one of the two networks. The number of points and measures will similarly only be reported if they differ. The tolerances are stored in a PVL structure containing an IgnoreKeys group with keywords to ignore completely, and a Tolerances group to ignore if the (numerical) values are different within the given tolerance.

Author
2012-04-25 Travis Addair
History:

2012-04-26 Travis Addair - Added documentation.

2018-01-02 Kristin Berry - Modified to use ControlNetVersioner instead of LatestControlNetFile.

Definition at line 67 of file ControlNetDiff.h.

Constructor & Destructor Documentation

◆ ControlNetDiff() [1/2]

Isis::ControlNetDiff::ControlNetDiff ( )

Create a ControlNetDiff without any tolerances.

Definition at line 25 of file ControlNetDiff.cpp.

References init().

◆ ControlNetDiff() [2/2]

Isis::ControlNetDiff::ControlNetDiff ( Pvl diffFile)
explicit

Create a ControlNetDiff with persistent tolerances.

Parameters
diffFileThe PVL of ignore keywords and tolerance values

Definition at line 35 of file ControlNetDiff.cpp.

References addTolerances(), and init().

◆ ~ControlNetDiff()

Isis::ControlNetDiff::~ControlNetDiff ( )
virtual

Destroy the ControlNetDiff.

Does not own any passed-in data.

Definition at line 44 of file ControlNetDiff.cpp.

References m_ignoreKeys, and m_tolerances.

Member Function Documentation

◆ addTolerances()

void Isis::ControlNetDiff::addTolerances ( Pvl diffFile)

Add the given ignore keys and tolerances to the persisent collections of such values.

Does not clear any previously added ignore keys or tolerances. The DateTime keyword is always ignored

Parameters
diffFileThe PVL of ignore keywords and tolerance values

Definition at line 60 of file ControlNetDiff.cpp.

References Isis::PvlObject::findGroup(), Isis::PvlObject::hasGroup(), Isis::PvlContainer::keywords(), m_ignoreKeys, m_tolerances, Isis::PvlContainer::name(), and Isis::toDouble().

Referenced by ControlNetDiff().

◆ addUniqueMeasure()

void Isis::ControlNetDiff::addUniqueMeasure ( QString  label,
QString  v1,
QString  v2,
PvlObject parent 
)
protected

Add a new keyword for the given measure to the parent object.

It is assumed that one of the two values provided represents a missing SerialNumber.

Parameters
nameThe label of the measure uniquely identifying it
v1The first measure's value for the unique label
v2The second measure's value for the unique label
parentContainer for the measure group

Definition at line 392 of file ControlNetDiff.cpp.

References Isis::PvlObject::addGroup(), Isis::PvlContainer::addKeyword(), and Isis::PvlKeyword::addValue().

Referenced by compare().

◆ addUniquePoint()

void Isis::ControlNetDiff::addUniquePoint ( QString  label,
QString  v1,
QString  v2,
PvlObject parent 
)
protected

Add a new keyword for the given point to the parent object.

It is assumed that one of the two values provided represents a missing PointId.

Parameters
nameThe label of the point uniquely identifying it
v1The first points's value for the unique label
v2The second points's value for the unique label
parentContainer for the point object

Definition at line 370 of file ControlNetDiff.cpp.

References Isis::PvlContainer::addKeyword(), Isis::PvlObject::addObject(), and Isis::PvlKeyword::addValue().

Referenced by compare().

◆ compare() [1/3]

Pvl Isis::ControlNetDiff::compare ( FileName net1Name,
FileName net2Name 
)

Compare two Control Networks given their file names, and return their differences.

Parameters
net1NameName of the first Control Network
net2NameName of the second Control Network
Returns
Pvl The collection of all differences

Definition at line 84 of file ControlNetDiff.cpp.

References Isis::PvlObject::addObject(), addUniquePoint(), diff(), Isis::PvlObject::findKeyword(), Isis::PvlObject::findObject(), Isis::FileName::name(), Isis::ControlNetVersioner::netId(), Isis::ControlNetVersioner::numPoints(), Isis::PvlObject::object(), Isis::ControlNetVersioner::targetName(), Isis::ControlNetVersioner::toPvl(), and Isis::toString().

Referenced by compareGroups().

◆ compare() [2/3]

void Isis::ControlNetDiff::compare ( PvlObject point1Pvl,
PvlObject point2Pvl,
PvlObject report 
)
protected

Compare two Control Points stored as PvlObjects, and add any differences to the report object.

A new Point object will only be added to the report if there were top-level point data differences or measure differences.

Parameters
point1PvlContainer for the first Control Point
point2PvlContainer for the second Control Point
reportContainer for reporting all differences between these points

Definition at line 149 of file ControlNetDiff.cpp.

References Isis::PvlContainer::addKeyword(), Isis::PvlObject::addObject(), addUniqueMeasure(), compareGroups(), diff(), Isis::PvlContainer::findKeyword(), Isis::PvlObject::findKeyword(), Isis::PvlObject::group(), Isis::PvlObject::groups(), Isis::PvlContainer::keywords(), makeKeyword(), and Isis::toString().

◆ compare() [3/3]

void Isis::ControlNetDiff::compare ( PvlKeyword k1,
PvlKeyword k2,
PvlContainer report 
)
protected

Compare two keywords and report the differences to the given report container.

If a tolerance value exists for the keyword name, the difference will only be reported if the numerical difference magnitude between the values is greater than the tolerance. Otherwise, the keywords must have equal values. At present, only the first value of the keywords is compared. Keywords with multiple values are not considered, nor are their units.

Parameters
k1The first keyword
k2The second keyword
reportContainer for reporting all differences between these keywords

Definition at line 258 of file ControlNetDiff.cpp.

References diff(), m_tolerances, Isis::PvlKeyword::name(), and Isis::toDouble().

◆ compareGroups()

void Isis::ControlNetDiff::compareGroups ( PvlContainer g1,
PvlContainer g2,
PvlObject report 
)
protected

Compare two collections, or groupings, of PvlKeywords.

If the container has the keyword "SerialNumber", we assume it is a Control Measure, and thus create a PvlGroup to add to our report containing all the differences. Otherwise we add differences directly to the given report object. The measure PvlGroup will only be added if there are data differences.

Parameters
g1Container for the first keyword collection
g2Container for the second keyword collection
reportContainer for reporting all differences between these groupings

Definition at line 206 of file ControlNetDiff.cpp.

References Isis::PvlObject::addGroup(), Isis::PvlContainer::addKeyword(), compare(), diff(), Isis::PvlContainer::findKeyword(), Isis::PvlContainer::hasKeyword(), Isis::PvlContainer::keywords(), m_ignoreKeys, and makeKeyword().

Referenced by compare().

◆ diff() [1/3]

void Isis::ControlNetDiff::diff ( QString  name,
PvlObject o1,
PvlObject o2,
PvlContainer report 
)
protected

Add a new difference keyword to the given report if the PvlObjects have different values for the keyword with the given name.

Parameters
nameThe name of the keyword to be compared
o1The first object
o2The second object
reportContainer for reporting differences between these objects for the keyword with the given name

Definition at line 277 of file ControlNetDiff.cpp.

Referenced by compare(), and compareGroups().

◆ diff() [2/3]

void Isis::ControlNetDiff::diff ( QString  name,
QString  v1,
QString  v2,
PvlContainer report 
)
protected

Add a new difference keyword to the given report if the two string are not equal.

The two value strings represent values of keywords to be directly compared. The first name string is the label of the keyword.

Parameters
nameThe label of the keyword whose values are being compared
v1The first keyword's value
v2The second keyword's value
reportContainer for reporting differences between these values for the keyword with the given name

Definition at line 295 of file ControlNetDiff.cpp.

References Isis::PvlContainer::addKeyword(), m_ignoreKeys, and makeKeyword().

◆ diff() [3/3]

void Isis::ControlNetDiff::diff ( QString  name,
double  v1,
double  v2,
double  tol,
PvlContainer report 
)
protected

Add a new difference keyword to the given report if the two numerical values are not equal within the given tolerance.

The two values represent values of keywords to be directly compared. The first name string is the label of the keyword.

Parameters
nameThe label of the keyword whose values are being compared
v1The first keyword's value
v2The second keyword's value
tolThe tolerance to compare against the values
reportContainer for reporting differences between these values for the keyword with the given name

Definition at line 332 of file ControlNetDiff.cpp.

References Isis::PvlContainer::addKeyword(), m_ignoreKeys, and makeKeyword().

◆ init()

void Isis::ControlNetDiff::init ( )
private

Initialize the persistent structures used to maintain the state of this instance: its ignore keys and tolerances.

Automatically ignore the "DateTime" keyword.

Definition at line 409 of file ControlNetDiff.cpp.

References m_ignoreKeys, and m_tolerances.

Referenced by ControlNetDiff().

◆ makeKeyword() [1/2]

PvlKeyword Isis::ControlNetDiff::makeKeyword ( QString  name,
QString  v1,
QString  v2 
)
protected

Create a new keyword with the given label name and the given values.

If the two values are equal, only add one of them to the keyword.

Parameters
nameThe label of the keyword whose values are being compared
v1The first keyword's value
v2The second keyword's value
Returns
PvlKeyword Container for the two values

Definition at line 311 of file ControlNetDiff.cpp.

References Isis::PvlKeyword::addValue().

Referenced by compare(), compareGroups(), and diff().

◆ makeKeyword() [2/2]

PvlKeyword Isis::ControlNetDiff::makeKeyword ( QString  name,
double  v1,
double  v2,
double  tol 
)
protected

Create a new keyword with the given label name and the given values.

If the two values are equal within the given tolerance, only add one of them to the keyword.

Parameters
nameThe label of the keyword whose values are being compared
v1The first keyword's value
v2The second keyword's value
tolThe tolerance to compare against the values
Returns
PvlKeyword Container for the two values

Definition at line 350 of file ControlNetDiff.cpp.

References Isis::PvlKeyword::addValue(), and Isis::toString().

Member Data Documentation

◆ m_ignoreKeys

QSet<QString>* Isis::ControlNetDiff::m_ignoreKeys
private

The set of keywords to ignore by name.

Definition at line 101 of file ControlNetDiff.h.

Referenced by addTolerances(), compareGroups(), diff(), init(), and ~ControlNetDiff().

◆ m_tolerances

QMap<QString, double>* Isis::ControlNetDiff::m_tolerances
private

The map of tolerances going from keyword name to tolerance value.

Definition at line 98 of file ControlNetDiff.h.

Referenced by addTolerances(), compare(), init(), and ~ControlNetDiff().


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