Unverified Commit 5be78fac authored by Kristin's avatar Kristin Committed by GitHub
Browse files

Merge pull request #145 from jcwbacker/m05369

Updated class documentation and variable names for PvlTranslationTable
parents e70d885c 7bb2bc18
Loading
Loading
Loading
Loading
+66 −45
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ namespace Isis {
   * set the input label before translating. This may be done by using
   * SetLabel(Pvl inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel).
   *
   * @param transFile The translation file to be used to tranlate keywords in
   * @param transFile The translation file to be used to translate keywords in
   *                  the input label.
   */
  PvlToPvlTranslationManager::PvlToPvlTranslationManager(const QString &transFile)
@@ -53,8 +53,8 @@ namespace Isis {
   * input label before translating. This may be done by using SetLabel(Pvl
   * inputLabel) or Auto(Pvl inputLabel, Pvl outputLabel).
   *
   * @param transStrm A stream containing the tranlation table to be used to
   *                  tranlate keywords in the input label.
   * @param transStrm A stream containing the translation table to be used to
   *                  translate keywords in the input label.
   */
  PvlToPvlTranslationManager::PvlToPvlTranslationManager(std::istream &transStrm)
      : LabelTranslationManager(transStrm) {
@@ -66,7 +66,7 @@ namespace Isis {
   *
   * @param inputLabel The Pvl holding the input label.
   *
   * @param transFile The translation file to be used to tranlate keywords in
   * @param transFile The translation file to be used to translate keywords in
   *                  the input label.
   */
  PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel,
@@ -81,8 +81,8 @@ namespace Isis {
   *
   * @param inputLabel The Pvl holding the input label.
   *
   * @param transStrm A stream containing the tranlation table to be used to
   *                  tranlate keywords in the input label.
   * @param transStrm A stream containing the translation table to be used to
   *                  translate keywords in the input label.
   */
  PvlToPvlTranslationManager::PvlToPvlTranslationManager(Pvl &inputLabel,
      std::istream &transStrm)
@@ -103,34 +103,37 @@ namespace Isis {

  /**
   * Returns a translated value. The output name is used to find the input
   * group, keyword, default and tranlations in the translation table. If the
   * group, keyword, default and translations in the translation table. If the
   * keyword does not exist in the input label and an input default is available,
   * then this default will be used as the input value. This input value is
   * then used to search all of the translations. If a match is found the
   * translated value is returned. 
   *
   * @param nName The output name used to identify the input keyword to be
   *              translated.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   *
   * @param findex The index into the input keyword array.  Defaults to 0
   *
   * @return string
   */
  QString PvlToPvlTranslationManager::Translate(QString nName, int findex) {
  QString PvlToPvlTranslationManager::Translate(QString translationGroupName, int findex) {
    const PvlContainer *con;
    int inst = 0;
    PvlKeyword grp;

    while((grp = InputGroup(nName, inst++)).name() != "") {
    while((grp = InputGroup(translationGroupName, inst++)).name() != "") {
      if((con = GetContainer(grp)) != NULL) {
        if(con->hasKeyword(InputKeywordName(nName))) {
          return PvlTranslationTable::Translate(nName,
                                                (*con)[InputKeywordName(nName)][findex]);
        if(con->hasKeyword(InputKeywordName(translationGroupName))) {
          return PvlTranslationTable::Translate(translationGroupName,
                                                (*con)[InputKeywordName(translationGroupName)][findex]);
        }
      }
    }

    return PvlTranslationTable::Translate(nName);
    return PvlTranslationTable::Translate(translationGroupName);
  }


@@ -143,12 +146,15 @@ namespace Isis {
   *  
   * @see Auto().
   *
   * @param nName The output name used to identify the input keyword to be
   *              translated.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   *
   * @return PvlKeyword
   */
   PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString nName) {
   PvlKeyword PvlToPvlTranslationManager::DoTranslation(const QString translationGroupName) {
     const PvlContainer *con = NULL;
     PvlKeyword key;

@@ -156,9 +162,9 @@ namespace Isis {
     PvlGroup transGroup;
     PvlKeyword grp;

     while((grp = InputGroup(nName, inst++)).name() != "") {
     while((grp = InputGroup(translationGroupName, inst++)).name() != "") {
       if((con = GetContainer(grp)) != NULL) {
         transGroup = TranslationTable().findGroup(nName);
         transGroup = TranslationTable().findGroup(translationGroupName);
         Pvl::ConstPvlKeywordIterator it = transGroup.findKeyword("InputKey",
                                           transGroup.begin(),
                                           transGroup.end());
@@ -167,10 +173,10 @@ namespace Isis {
         while(it != transGroup.end()) {
           const PvlKeyword &result = *it;
           if(con->hasKeyword(result[0])) {
             key.setName(OutputName(nName));
             key.setName(OutputName(translationGroupName));

             for(int v = 0; v < (*con)[(result[0])].size(); v++) {
               key.addValue(PvlTranslationTable::Translate(nName,
               key.addValue(PvlTranslationTable::Translate(translationGroupName,
                                                           (*con)[result[0]][v]),
                            (*con)[result[0]].unit(v));
             }
@@ -182,8 +188,8 @@ namespace Isis {
       }
     }

     return PvlKeyword(OutputName(nName),
                       PvlTranslationTable::Translate(nName, ""));
     return PvlKeyword(OutputName(translationGroupName),
                       PvlTranslationTable::Translate(translationGroupName, ""));
   }


@@ -227,16 +233,20 @@ namespace Isis {
  /**
   * Returns the ith input value associated with the output name argument.
   *
   * @param nName The output name used to identify the input keyword.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   *
   * @param findex The index into the input keyword array.  Defaults to 0
   *
   * @throws IException::Programmer
   */
  const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString nName) const {
  const PvlKeyword &PvlToPvlTranslationManager::InputKeyword(const QString translationGroupName) const {

    int instanceNumber = 0;
    PvlKeyword inputGroupKeyword = InputGroup(nName, instanceNumber);
    PvlKeyword inputGroupKeyword = InputGroup(translationGroupName, instanceNumber);
    bool anInputGroupFound = false;

    while(inputGroupKeyword.name() != "") {
@@ -244,31 +254,31 @@ namespace Isis {
      if(containingGroup != NULL) {
        anInputGroupFound = true;

        if(containingGroup->hasKeyword(InputKeywordName(nName))) {
          return containingGroup->findKeyword(InputKeywordName(nName));
        if(containingGroup->hasKeyword(InputKeywordName(translationGroupName))) {
          return containingGroup->findKeyword(InputKeywordName(translationGroupName));
        }
      }

      instanceNumber ++;
      inputGroupKeyword = InputGroup(nName, instanceNumber);
      inputGroupKeyword = InputGroup(translationGroupName, instanceNumber);
    }

    if(anInputGroupFound) {
      QString msg = "Unable to find input keyword [" + InputKeywordName(nName) +
                   "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]";
      QString msg = "Unable to find input keyword [" + InputKeywordName(translationGroupName) +
                   "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    else {
      QString container = "";

      for(int i = 0; i < InputGroup(nName).size(); i++) {
      for(int i = 0; i < InputGroup(translationGroupName).size(); i++) {
        if(i > 0) container += ",";

        container += InputGroup(nName)[i];
        container += InputGroup(translationGroupName)[i];
      }

      QString msg = "Unable to find input group [" + container +
                   "] for output name [" + nName + "] in file [" + TranslationTable().fileName() + "]";
                   "] for output name [" + translationGroupName + "] in file [" + TranslationTable().fileName() + "]";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
@@ -278,21 +288,25 @@ namespace Isis {
   * Indicates if the input keyword corresponding to the output name exists in
   * the label
   *
   * @param nName The output name used to identify the input keyword.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   */
  bool PvlToPvlTranslationManager::InputHasKeyword(const QString nName) {
  bool PvlToPvlTranslationManager::InputHasKeyword(const QString translationGroupName) {

    // Set the current position in the input label pvl
    // by finding the input group corresponding to the output group
    const PvlContainer *con;
    int inst = 0;
    //while ((con = GetContainer(InputGroup(nName, inst++))) != NULL) {
    //if ((con = GetContainer (InputGroup(nName))) != NULL) {
    //while ((con = GetContainer(InputGroup(translationGroupName, inst++))) != NULL) {
    //if ((con = GetContainer (InputGroup(translationGroupName))) != NULL) {

    PvlKeyword grp;
    while((grp = InputGroup(nName, inst++)).name() != "") {
    while((grp = InputGroup(translationGroupName, inst++)).name() != "") {
      if((con = GetContainer(grp)) != NULL) {
        if(con->hasKeyword(InputKeywordName(nName))) return true;
        if(con->hasKeyword(InputKeywordName(translationGroupName))) return true;
      }
    }

@@ -340,10 +354,17 @@ namespace Isis {

  /**
   * Create the requsted container and any containers above it and
   * return a reference to the container
   * list is an PvlKeyword with an array of container types an their names
   * return a reference to the container. List is a PvlKeyword 
   * with an array of container types and their names. 
   *  
   * @param translationGroupName The name of the PVL translation 
   *                        group used to identify the
   *                        input/output keywords to be
   *                        translated. Often, this is the
   *                        same as the output keyword name.
   * @param pvl Pvl 
   */
  PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString nName, Pvl &pvl) {
    return LabelTranslationManager::CreateContainer(nName, pvl);
  PvlContainer *PvlToPvlTranslationManager::CreateContainer(const QString translationGroupName, Pvl &pvl) {
    return LabelTranslationManager::CreateContainer(translationGroupName, pvl);
  }
} // end namespace isis
+7 −6
Original line number Diff line number Diff line
@@ -71,7 +71,8 @@ namespace Isis {
   *                          PvlToPvlTranslationManager. Fixes #4901.
   *  @history 2018-01-10 Christopher Combs - Changed ProcessDataFilePointer call to reflect 
   *                          changes made to voy2isis. Fixes #4345, #4421.
   *  @history 2018-04-16 Jeannie Backer - Fixed indentation of history comments.
   *  @history 2018-04-16 Jeannie Backer - Fixed indentation of history comments and
   *                          brought code closer to coding standards.
   *  @todo 2005-02-15 Stuart Sides - add coded example and implementation example
   *                          to class documentation, and finish
   *                          documentation.
@@ -92,24 +93,24 @@ namespace Isis {

      // Attempt to translate the requested output name to output value
      // using the input name and value/default value
      virtual QString Translate(QString nName, int findex = 0);
      virtual QString Translate(QString translationGroupName, int findex = 0);

      // Translate all translation table groups which contain "Auto"
      void Auto(Pvl &outputLabel);
      void Auto(Pvl &inputLabel, Pvl &outputLabel);

      // Return the ith input value associated with a output name
      virtual const PvlKeyword &InputKeyword(const QString nName) const;
      virtual const PvlKeyword &InputKeyword(const QString translationGroupName) const;

      // Return true if the input lable contains the translated group and key names
      virtual bool InputHasKeyword(const QString nName);
      virtual bool InputHasKeyword(const QString translationGroupName);

      void SetLabel(Pvl &inputLabel);

    protected:
      virtual PvlKeyword DoTranslation(const QString nName);
      virtual PvlKeyword DoTranslation(const QString translationGroupName);
      virtual const PvlContainer *GetContainer(const PvlKeyword &inputGroup) const;
      virtual PvlContainer *CreateContainer(const QString nName, Pvl &pvl);
      virtual PvlContainer *CreateContainer(const QString translationGroupName, Pvl &pvl);
    private:
      Pvl p_fLabel; //!< A Pvl object for the input label file
  };
+53 −13
Original line number Diff line number Diff line
@@ -214,9 +214,11 @@ namespace Isis {
   * Translates a single output value from the given translation 
   * group name and input value. 
   *
   * @param translationGroupName The name of the pvl translation 
   *                             group. Often, this is the same
   *                             as the output keyword name.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * @param inputKeyValue The value to be translated, from the 
   *                      input keyword.
   *
@@ -283,7 +285,11 @@ namespace Isis {
   * Returns the input group name from the translation table corresponding to
   * the output name argument.
   *
   * @param translationGroupName The output name to be used to search the translation table.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * @param inst The occurence number of the "InputGroup" keyword
   *             (first one is zero)
   *
@@ -357,9 +363,15 @@ namespace Isis {
   * Returns the input keyword name from the translation table corresponding to
   * the output name argument.
   *
   * @param translationGroupName The output name to be used to search the translation table.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   *  
   * @return QString The input keyword name.
   * @return QString The input keyword name
   *
   * @throws IException::Programmer
   */
  QString PvlTranslationTable::InputKeywordName(const QString translationGroupName) const {

@@ -375,7 +387,11 @@ namespace Isis {
   * Returns the input default value from the translation table corresponding
   * to the output name argument.
   *
   * @param translationGroupName The output name to be used to search the translation table.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   *
   * @return QString The input default value.
   */
@@ -395,7 +411,11 @@ namespace Isis {
   * PvlKeyword with the name "InputDefault". Note: no value needs
   * to be assigned to this keyword. 
   *  
   * @param translationGroupName The name of the PVL translation group.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return bool Indicates whether the given group has an 
   *         InputDefault keyword.
@@ -416,7 +436,11 @@ namespace Isis {
   * group contains a PvlKeyword with the name "Auto". Note: 
   * no value is assigned to this keyword. 
   *  
   * @param translationGroupName The name of the PVL translation group.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return bool Indicates whether the given group has an Auto 
   *         keyword.
@@ -437,7 +461,11 @@ namespace Isis {
   * PvlKeyword with the name "Optional". Note: no value is 
   * assigned to this keyword. 
   *  
   * @param translationGroupName The name of the PVL translation group.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return bool Indicates whether the given group has an 
   *         Optional keyword.
@@ -456,7 +484,11 @@ namespace Isis {
   * Retrieves the OutputPosition PvlKeyword for the translation 
   * group with the given name. 
   *  
   * @param translationGroupName The name of the PVL translation group.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return PvlKeyword The OutputPosition keyword from the given 
   *         translation group.
@@ -483,7 +515,11 @@ namespace Isis {
   * Retrieves a string containing the value of the OutputName 
   * keyword for the translation group with the given name. 
   *  
   * @param translationGroupName The name of the PVL translation group.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return @b QString The value of the OutputName keyword from 
   *         the given translation group.
@@ -504,7 +540,11 @@ namespace Isis {
   *  
   * @see PvlObject::findGroup() 
   *  
   * @param translationGroupName Name of the PVL group to search for.
   * @param translationGroupName The name of the PVL translation 
   *                             group used to identify the
   *                             input/output keywords to be
   *                             translated. Often, this is the
   *                             same as the output keyword name.
   * 
   * @return const PvlGroup& The first PVL group with the given name.
   *  
+28 −23
Original line number Diff line number Diff line
@@ -142,19 +142,24 @@ namespace Isis {


  /**
   * Returns a translated value. The output name is used to find the input
   * group, keyword, default and tranlations in the translation table. If the
   * keyword does not exist in the input label, the input default if
   * available will be used as the input value. This input value
   * is then used to search all of the translations. If a match is
   * found the translated value is returned.
   * Returns a translated value. The translation group name is 
   * used to find the input group, keyword, default and 
   * tranlations in the translation table. If the keyword does not 
   * exist in the input label, the input default if available will 
   * be used as the input value. This input value is then used to 
   * search all of the translations. If a match is found the 
   * translated value is returned. 
   *
   * @param outputName The output name used to identify the input keyword to
   *                   be translated.
   * @param translationGroupName The name of the PVL translation 
   *                        group used to identify the
   *                        input/output keywords to be
   *                        translated. Often, this is the
   *                        same as the output keyword name.
   *
   * @param index The index into the input keyword array.  Defaults to 0
   *
   * @return string The ISIS cube label value for the outputName.
   * @return @b QString The translated output value to be 
   *         placed in the ISIS3 cube label.
   *
   * @throws IException::Unknown "Failed to translate output value."
   * @throws IException::Unknown "Cannot translate value. Xml files can only
@@ -170,7 +175,7 @@ namespace Isis {
   * @throws IException::Unknown "Could not find an input value or default value."
   * @throws IException::Unknown "Input element does not have the named attribute."
   */
  QString XmlToPvlTranslationManager::Translate(QString outputName, 
  QString XmlToPvlTranslationManager::Translate(QString translationGroupName, 
                                                int index) {
    try {
    if (index != 0) {
@@ -182,7 +187,7 @@ namespace Isis {
    const Pvl &transTable = TranslationTable();
    PvlGroup transGroup;
    try {
      transGroup = transTable.findGroup(outputName);
      transGroup = transTable.findGroup(translationGroupName);
    }
    catch (IException &e){
      QString msg = "Unable to retrieve translation group from translation table.";
@@ -228,7 +233,7 @@ namespace Isis {
    // Notify what we are translating and what the translating group is.
    if (isDebug) {
      cout << endl << "          ====================          " << endl;
      cout << endl << "Translating output keyword: " << outputName << endl;
      cout << endl << "Translating output keyword: " << translationGroupName << endl;
      cout << endl << "Translation group:" << endl;
      cout << transGroup << endl << endl;
    }
@@ -269,13 +274,13 @@ namespace Isis {
    }
     
    if (inputParentElement.isNull()) {
      if (hasInputDefault(outputName)) {
      if (hasInputDefault(translationGroupName)) {
        if (isDebug) {
          cout << endl << "Could not traverse input position, " <<
            "using default value: " <<
            InputDefault(outputName) << endl;
            InputDefault(translationGroupName) << endl;
        }
        return PvlTranslationTable::Translate( outputName );
        return PvlTranslationTable::Translate( translationGroupName );
      }
      else {
        QString msg = "Failed traversing input position. [" +
@@ -312,12 +317,12 @@ namespace Isis {
    // If the parent element is NULL at this point then we traversed every
    // potential input element and none of them satisfied the dependencies.
    if ( inputParentElement.isNull() ) {
      if ( hasInputDefault(outputName) ) {
      if ( hasInputDefault(translationGroupName) ) {
        if (isDebug) {
          cout << endl << "No input value found, using default value: " <<
                          InputDefault(outputName) << endl;
                          InputDefault(translationGroupName) << endl;
        }
        return PvlTranslationTable::Translate( outputName );
        return PvlTranslationTable::Translate( translationGroupName );
      }
      else {
        QString msg = "Could not find an input or default value that fits the given input "
@@ -333,12 +338,12 @@ namespace Isis {
      if ( inputKeyElement.hasAttribute(attributeName) ) {
        inputValue = inputKeyElement.attribute(attributeName);
      }
      else if (hasInputDefault(outputName) ) {
      else if (hasInputDefault(translationGroupName) ) {
        if (isDebug) {
          cout << endl << "No input value found, using default value: " <<
                          InputDefault(outputName) << endl;
                          InputDefault(translationGroupName) << endl;
        }
        return PvlTranslationTable::Translate( outputName );
        return PvlTranslationTable::Translate( translationGroupName );
      }
      else {
        QString msg = "Input element [" + inputKeyElement.tagName() +
@@ -350,10 +355,10 @@ namespace Isis {
    if (isDebug) {
          cout << endl << "Translating input value: " << inputValue << endl;
        }
    return PvlTranslationTable::Translate( outputName, inputValue.trimmed() );
    return PvlTranslationTable::Translate( translationGroupName, inputValue.trimmed() );
    }
    catch (IException &e){
      QString msg = "Failed to translate output value for [" + outputName + "].";
      QString msg = "Failed to translate output value for [" + translationGroupName + "].";
      throw IException(e, IException::Unknown, msg, _FILEINFO_);
    }
  }
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.