Commit 36f34db8 authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Xml read/write improvements.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@5943 41f8697f-d340-4b68-9986-7bafba869bb8
parent 2072faae
Loading
Loading
Loading
Loading
+33 −34
Original line number Diff line number Diff line
@@ -110,6 +110,9 @@ namespace Isis {
   *                 will be dynamically tracked
   */
  void StatCumProbDistDynCalc::initialize(unsigned int nodes) {
    m_id = NULL;
    m_id = new QUuid(QUuid::createUuid());

    m_quantiles.clear();
    m_idealNum.clear();
    m_n.clear();
@@ -502,19 +505,19 @@ namespace Isis {

    stream.writeStartElement("quantiles");
    for (int i = 0; i < m_quantiles.size(); i++) {
      stream.writeTextElement("value", toString(m_quantiles[i]));
      stream.writeTextElement("quantile", toString(m_quantiles[i]));
    }
    stream.writeEndElement();
  
    stream.writeStartElement("idealNum");
    stream.writeStartElement("idealNumObsBelowEachQuantile");
    for (int i = 0; i < m_idealNum.size(); i++) {
      stream.writeTextElement("value", toString(m_idealNum[i]));
      stream.writeTextElement("idealNumObsBelowQuantile", toString(m_idealNum[i]));
    }
    stream.writeEndElement();
    
    stream.writeStartElement("n");
    stream.writeStartElement("numObsBelowEachQuantile");
    for (int i = 0; i < m_n.size(); i++) {
      stream.writeTextElement("value", toString(m_n[i]));
      stream.writeTextElement("numObsBelowQuantile", toString(m_n[i]));
    }
    stream.writeEndElement();
  
@@ -523,7 +526,6 @@ namespace Isis {
      stream.writeTextElement("value", toString(m_quantileValues[i]));
    }
    stream.writeEndElement();
    stream.writeEndElement();

  }

@@ -538,7 +540,7 @@ namespace Isis {


  StatCumProbDistDynCalc::XmlHandler::~XmlHandler() {
    // ??? compile error ??? delete m_project;    // TODO: does xml stuff need project???
    delete m_project;    // TODO: does xml stuff need project???
    m_project = NULL;
  }

@@ -568,38 +570,27 @@ namespace Isis {
                                     const QString &qName) {
    if (!m_characters.isEmpty()) {
      if (localName == "id") {
        delete m_probabilityCalc->m_id;
        m_probabilityCalc->m_id = NULL;
        m_probabilityCalc->m_id = new QUuid(m_characters);
      }
      if (localName == "numberCells") {
      else if (localName == "numberCells") {
        m_probabilityCalc->m_numberCells = toInt(m_characters);
      }
      if (localName == "numberObservations") {
      else if (localName == "numberObservations") {
        m_probabilityCalc->m_numberObservations = toInt(m_characters);
      }
//
//    stream.writeStartElement("quantileValue");
//    for (int i = 0; i < m_quantiles.size(); i++) {
//      stream.writeTextElement("value", toString(m_quantiles[i]));
//    }
//    stream.writeEndElement();
//
//    stream.writeStartElement("idealNum");
//    for (int i = 0; i < m_idealNum.size(); i++) {
//      stream.writeTextElement("value", toString(m_idealNum[i]));
//    }
//    stream.writeEndElement();
//    
//    stream.writeStartElement("n");
//    for (int i = 0; i < m_n.size(); i++) {
//      stream.writeTextElement("value", toString(m_n[i]));
//    }
//    stream.writeEndElement();
//
//    stream.writeStartElement("quantileValues");
//    for (int i = 0; i < m_quantileValues.size(); i++) {
//      stream.writeTextElement("value", toString(m_quantileValues[i]));
      else if (localName == "quantile") {
        m_probabilityCalc->m_quantiles.append(toDouble(m_characters));
      }
      else if (localName == "idealNumObsBelowQuantile") {
        m_probabilityCalc->m_idealNum.append(toDouble(m_characters));
      }
      else if (localName == "numObsBelowQuantile") {
        m_probabilityCalc->m_n.append(toInt(m_characters));
      }
      else if (localName == "value") {
        m_probabilityCalc->m_quantileValues.append(toDouble(m_characters));
      }
                                           
      m_characters = "";
    }
@@ -609,7 +600,8 @@ namespace Isis {


  QDataStream &StatCumProbDistDynCalc::write(QDataStream &stream) const {
    stream << (qint32)m_numberCells
    stream << m_id->toString()
           << (qint32)m_numberCells
           << (qint32)m_numberQuantiles 
           << m_quantiles
           << m_idealNum
@@ -622,14 +614,21 @@ namespace Isis {


  QDataStream &StatCumProbDistDynCalc::read(QDataStream &stream) {
    QString id;
    qint32 numCells, numQuantiles, numObservations;
    stream >> numCells
    stream >> id
           >> numCells
           >> numQuantiles
           >> m_quantiles
           >> m_idealNum
           >> m_n
           >> m_quantileValues
           >> numObservations;

    delete m_id;
    m_id = NULL;
    m_id = new QUuid(id);

    m_numberCells = (unsigned int)numCells;
    m_numberQuantiles  = (unsigned int)numQuantiles;
    m_numberObservations   = (unsigned int)numObservations;
+8 −8
Original line number Diff line number Diff line
Testing failure modes
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a value (as a function of cumulative probability) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a cumulative probability (as a function of value) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a value (as a function of cumulative probability) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a cumulative probability (as a function of value) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a nonsense cumulative probability (2.0): **PROGRAMMER ERROR** Invalid cumulative probability [2.0] passed in to StatCumProbDistDynCalc::value(double cumProb). Must be on the domain [0, 1].
Querying a nonsense cumulative probability (-1.0): **PROGRAMMER ERROR** Invalid cumulative probability [-1.0] passed in to StatCumProbDistDynCalc::value(double cumProb). Must be on the domain [0, 1].

@@ -38,10 +38,10 @@ percent error: 0.00216297%

reinitiliaze the class and redo the tests
Testing failure modes
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a value (as a function of cumulative probability) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a cumulative probability (as a function of value) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying minimum before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a value (as a function of cumulative probability) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a cumulative probability (as a function of value) before the number of observations is greater than or equal to the number of quantiles: **PROGRAMMER ERROR** StatCumProbDistDynCalc will return no data until the number of observations added [20] matches the number of quantiles [51] (i.e. number of nodes) selected.
Querying a nonsense cumulative probability (2.0): **PROGRAMMER ERROR** Invalid cumulative probability [2.0] passed in to StatCumProbDistDynCalc::value(double cumProb). Must be on the domain [0, 1].
Querying a nonsense cumulative probability (-1.0): **PROGRAMMER ERROR** Invalid cumulative probability [-1.0] passed in to StatCumProbDistDynCalc::value(double cumProb). Must be on the domain [0, 1].

+22 −3
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ using namespace std;
namespace Isis {
  //! Constructs an IsisStats object with accumulators and counters set to zero.
  Statistics::Statistics(QObject *parent) : QObject(parent) {
    m_id = NULL;
    m_id = new QUuid(QUuid::createUuid());
    SetValidRange();
    Reset();
  }
@@ -654,7 +656,6 @@ namespace Isis {
                                     const QString &qName) {
    if (!m_characters.isEmpty()) {
      if (localName == "id") {
        delete m_statistics->m_id;
        m_statistics->m_id = NULL;
        m_statistics->m_id = new QUuid(m_characters);
      }
@@ -712,7 +713,8 @@ namespace Isis {


  QDataStream &Statistics::write(QDataStream &stream) const {
    stream << m_sum
    stream << m_id->toString()
           << m_sum
           << m_sumsum
           << m_minimum
           << m_maximum
@@ -735,10 +737,12 @@ namespace Isis {

  QDataStream &Statistics::read(QDataStream &stream) {

    QString id;
    qint32 totalPixels, validPixels, nullPixels, lrsPixels, lisPixels,
           hrsPixels, hisPixels, underRangePixels, overRangePixels;

    stream >> m_sum
    stream >> id
           >> m_sum
           >> m_sumsum
           >> m_minimum
           >> m_maximum
@@ -755,6 +759,21 @@ namespace Isis {
           >> overRangePixels
           >> m_removedData;

    delete m_id;
    m_id = NULL;
    m_id = new QUuid(id);

    m_totalPixels      = (BigInt)totalPixels;
    m_validPixels      = (BigInt)validPixels;
    m_nullPixels       = (BigInt)nullPixels;
    m_lrsPixels        = (BigInt)lrsPixels;
    m_lisPixels        = (BigInt)lisPixels;
    m_hrsPixels        = (BigInt)hrsPixels;
    m_hisPixels        = (BigInt)hisPixels;
    m_underRangePixels = (BigInt)underRangePixels;
    m_overRangePixels  = (BigInt)overRangePixels;
    

    return stream;
  }

+7 −3
Original line number Diff line number Diff line
@@ -265,8 +265,8 @@ namespace Isis {
  }

  QDataStream &BundleResults::write(QDataStream &stream) const {
    // TODO: add m_id???
    stream << m_controlNetworkFileName->expanded()
    stream << m_id->toString()
           << m_controlNetworkFileName->expanded()
           << *m_settings
           << *m_statisticsResults;
    // TODO: add m_images???
@@ -278,7 +278,11 @@ namespace Isis {

  QDataStream &BundleResults::read(QDataStream &stream) {

    // TODO: add m_id???
    QString id;
    stream >> id;
    delete m_id;
    m_id = NULL;
    m_id = new QUuid(id);

    QString controlNetworkFileName;
    stream >> controlNetworkFileName;
+133 −83

File changed.

Preview size limit exceeded, changes collapsed.

Loading