Isis 3 Programmer Reference
Isis::PvlTranslationTable Class Reference

Internalizes a translation table. More...

#include <PvlTranslationTable.h>

Inheritance diagram for Isis::PvlTranslationTable:
Inheritance graph
Collaboration diagram for Isis::PvlTranslationTable:
Collaboration graph

Public Member Functions

 PvlTranslationTable (FileName transFile)
 Constructs and initializes a PvlTranslationTable object.
 
 PvlTranslationTable (std::istream &istr)
 Constructs and initializes a PvlTranslationTable object.
 
 PvlTranslationTable ()
 Construct an empty PvlTranslationTable.
 
virtual ~PvlTranslationTable ()
 Destroys the PvlTranslationTable object.
 
virtual PvlKeyword InputGroup (const QString translationGroupName, const int inst=0) const
 Returns the input group name from the translation table corresponding to the output name argument.
 
virtual QString InputKeywordName (const QString translationGroupName) const
 Returns the input keyword name from the translation table corresponding to the output name argument.
 
QString InputDefault (const QString translationGroupName) const
 Returns the input default value from the translation table corresponding to the output name argument.
 
QString Translate (const QString translationGroupName, const QString inputKeyValue="") const
 Translates a single output value from the given translation group name and input value.
 
void AddTable (std::istream &transStm)
 Adds the contents of a translation table to the searchable groups/keys Also performs a verification, to ensure that the translation table is valid.
 
void AddTable (const QString &transFile)
 Adds the contents of a translation table to the searchable groups/keys.
 

Protected Member Functions

PvlTranslationTable ()
 Protected accessor for pvl translation table passed into class.
 
const PvlTranslationTable () const
 Protected accessor for const pvl translation table passed into class.
 
virtual std::vector< std::pair< QString, int > > validKeywords () const
 Returns a vector of valid keyword names and their sizes.
 
bool hasInputDefault (const QString translationGroupName)
 Determines whether the given group has a default input value.
 
bool IsAuto (const QString translationGroupName)
 Determines whether the given group should be automatically translated.
 
bool IsOptional (const QString translationGroupName)
 Determines whether the translation group is optional.
 
PvlKeyword OutputPosition (const QString translationGroupName)
 Retrieves the OutputPosition PvlKeyword for the translation group with the given name.
 
QString OutputName (const QString translationGroupName)
 Retrieves a string containing the value of the OutputName keyword for the translation group with the given name.
 
const PvlGroupfindTranslationGroup (const QString translationGroupName) const
 Searches for translation group with the given name.
 

Private Attributes

Pvl p_trnsTbl
 

Detailed Description

Internalizes a translation table.

This class internalizes an Isis translation table and provides group/key searches and value translations. The group names listed are the output names used by applications to get the input names and values. There is only one level of groups and groups are not allowed to be nested. The Group names can NOT be repeated. OutputGroup is a comma delimited list of objects and/or groups in the input label. Traversing this list within the input label will lead to the correct level to find the input keyword. OutputKey is the keyword within the group which holds the information. OutputDefault is the value used if there is no value for the keyword. Translation is the output and corresponding input values. Translation may be repeated as needed. An example piece of a tranlation file:

Group = DataStart
OutputKey = ^IMAGE
OutputDefault = 1
Translation = (*,*)
EndGroup
Group = DataFileRecordBytes
OutputKey = RECORD_BYTES
Translation = (*,*)
EndGroup
Group = CoreSamples
OutputGroup = IMAGE
OutputKey = LINE_SAMPLES
Translation = (*,*)
EndGroup
Group = CorePixelType
OutputGroup = IMAGE
OutputKey = SAMPLE_TYPE
OutputDefault = LSB_INTEGER
Translation = (Integer,LSB_INTEGER)
Translation = (Integer,MSB_INTEGER)
Translation = (Integer,PC_INTEGER)
Translation = (Integer,MAC_INTEGER)
Translation = (Integer,SUN_INTEGER)
Translation = (Integer,VAX_INTEGER)
Translation = (Natural,UNSIGNED_INTEGER)
Translation = (Natural,LSB_UNSIGNED_INTEGER)
Translation = (Natural,MSB_UNSIGNED_INTEGER)
EndGroup
Group = CoreOrganization
OutputGroup = IMAGE
OutputKey = BAND_STORAGE_TYPE
OutputDefault = BAND_SEQUENTIAL
Translation = (BSQ,BAND_SEQUENTIAL)
Translation = (BIL,LINE_INTERLEAVED)
Translation = (BIP,SAMPLE_INTERLEAVED)
EndGroup
End
Author
2003-05-01 Stuart Sides
History

2003-09-03 Stuart Sides - Modified to work with new isis label format.

2005-02-15 Elizabeth Ribelin - Modified file to support Doxygen documentation.

2005-09-08 Stuart Sides - Modified Translate member to handle translating any input value i.e., "*" to a specific output value (Thanks Kris Becker).

2006-08-09 Brendan George - Added IsOptional function as part of support for Optional keyword translations

2006-11-16 Brendan George - Changed instances of "Foreign" to "Input" and "Native" to "Output".

2007-06-22 Stuart Sides - Added instance parameter to InputGroup member.

2006-12-05 Brendan George - Changed OutputPosition keyword to be case insensitive, and added verification to the AddTable method so that Translation Tables are verified when read in.

2008-07-10 Steven Lambright - Made trnsTbl member into a non-pointer

2010-01-04 Steven Lambright - Now using files instead of streams where possible to improve errors and added code that checks the integrity of translation files. Also now looking for "InputPosition" keyword instead of "InputGroup." The InputGroup method (which needs renamed later) now returns a PvlKeyword.

2017-11-04 Jeannie Backer - Modified Translation input value to make a case insensitive comparison.

2018-04-16 Jeannie Backer - Updated documentation and improved coding standards/style.

Todo
2005-02-15 Stuart Sides - add coded and implementation example to class documentation and finish documentation for protected methods and variable

Definition at line 106 of file PvlTranslationTable.h.

Constructor & Destructor Documentation

◆ PvlTranslationTable() [1/3]

Isis::PvlTranslationTable::PvlTranslationTable ( FileName transFile)

Constructs and initializes a PvlTranslationTable object.

Parameters
transFileThe translation file to be used.

Definition at line 26 of file PvlTranslationTable.cpp.

References AddTable().

◆ PvlTranslationTable() [2/3]

Isis::PvlTranslationTable::PvlTranslationTable ( std::istream & istr)

Constructs and initializes a PvlTranslationTable object.

Parameters
istrThe translation stream to be used to translate values

Definition at line 36 of file PvlTranslationTable.cpp.

◆ PvlTranslationTable() [3/3]

Isis::PvlTranslationTable::PvlTranslationTable ( )

Construct an empty PvlTranslationTable.

Definition at line 44 of file PvlTranslationTable.cpp.

◆ ~PvlTranslationTable()

Isis::PvlTranslationTable::~PvlTranslationTable ( )
virtual

Destroys the PvlTranslationTable object.

Definition at line 51 of file PvlTranslationTable.cpp.

Member Function Documentation

◆ AddTable() [1/2]

void Isis::PvlTranslationTable::AddTable ( const QString & transFile)

Adds the contents of a translation table to the searchable groups/keys.

Parameters
transFileThe name of the translation file to be added.

Definition at line 84 of file PvlTranslationTable.cpp.

References Isis::Pvl::read().

◆ AddTable() [2/2]

void Isis::PvlTranslationTable::AddTable ( std::istream & transStm)

Adds the contents of a translation table to the searchable groups/keys Also performs a verification, to ensure that the translation table is valid.

Parameters
transStmThe stream to be added.
Exceptions
IException::User- "Unable to find InputKey for group in translation file."
IException::User- "Keyword is not valid. Error in file."
IException::User- "Keyword does not have correct number of elements. Error in file."

Definition at line 102 of file PvlTranslationTable.cpp.

References Isis::PvlKeyword::name(), Isis::IException::User, and validKeywords().

Referenced by Isis::LabelTranslationManager::LabelTranslationManager(), Isis::LabelTranslationManager::LabelTranslationManager(), PvlTranslationTable(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager(), and Isis::XmlToPvlTranslationManager::XmlToPvlTranslationManager().

◆ findTranslationGroup()

const PvlGroup & Isis::PvlTranslationTable::findTranslationGroup ( const QString translationGroupName) const
protected

Searches for translation group with the given name.

See also
PvlObject::findGroup()
Parameters
translationGroupNameThe 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.
Returns
const PvlGroup& The first PVL group with the given name.
Exceptions
IException::Programmer- "Unable to find translation group in file."

Definition at line 538 of file PvlTranslationTable.cpp.

References Isis::PvlContainer::fileName(), Isis::PvlObject::findGroup(), Isis::PvlObject::hasGroup(), and Isis::IException::Programmer.

Referenced by hasInputDefault(), InputDefault(), InputGroup(), InputKeywordName(), IsAuto(), IsOptional(), OutputName(), OutputPosition(), and Translate().

◆ hasInputDefault()

bool Isis::PvlTranslationTable::hasInputDefault ( const QString translationGroupName)
protected

Determines whether the given group has a default input value.

This method returns true if the translation group contains a PvlKeyword with the name "InputDefault". Note: no value needs to be assigned to this keyword.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an InputDefault keyword.

Definition at line 407 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::XmlToPvlTranslationManager::Translate().

◆ InputDefault()

QString Isis::PvlTranslationTable::InputDefault ( const QString translationGroupName) const

Returns the input default value from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
Returns
QString The input default value.

Definition at line 382 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::XmlToPvlTranslationManager::Translate().

◆ InputGroup()

PvlKeyword Isis::PvlTranslationTable::InputGroup ( const QString translationGroupName,
const int inst = 0 ) const
virtual

Returns the input group name from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
instThe occurence number of the "InputGroup" keyword (first one is zero)
Returns
QString The input group name
Exceptions
IException::Programmer- "Keyword [InputPosition] cannot have a comma [,] in the value."

Definition at line 285 of file PvlTranslationTable.cpp.

References findTranslationGroup(), Isis::IException::Programmer, and Isis::PvlKeyword::size().

Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ InputKeywordName()

QString Isis::PvlTranslationTable::InputKeywordName ( const QString translationGroupName) const
virtual

Returns the input keyword name from the translation table corresponding to the output name argument.

Parameters
translationGroupNameThe 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.
Returns
QString The input keyword name
Exceptions
IException::Programmer

Definition at line 360 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::InputHasKeyword(), Isis::PvlToXmlTranslationManager::InputHasKeyword(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), Isis::PvlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ IsAuto()

bool Isis::PvlTranslationTable::IsAuto ( const QString translationGroupName)
protected

Determines whether the given group should be automatically translated.

This method returns true if the translation group contains a PvlKeyword with the name "Auto". Note: no value is assigned to this keyword.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an Auto keyword.

Definition at line 432 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().

◆ IsOptional()

bool Isis::PvlTranslationTable::IsOptional ( const QString translationGroupName)
protected

Determines whether the translation group is optional.

This method returns true if the translation group contains a PvlKeyword with the name "Optional". Note: no value is assigned to this keyword.

Parameters
translationGroupNameThe 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.
Returns
bool Indicates whether the given group has an Optional keyword.

Definition at line 457 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), and Isis::PvlToXmlTranslationManager::Auto().

◆ OutputName()

QString Isis::PvlTranslationTable::OutputName ( const QString translationGroupName)
protected

Retrieves a string containing the value of the OutputName keyword for the translation group with the given name.

Parameters
translationGroupNameThe 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.
Returns
QString The value of the OutputName keyword from the given translation group.

Definition at line 511 of file PvlTranslationTable.cpp.

References findTranslationGroup().

Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), and Isis::PvlToXmlTranslationManager::doTranslation().

◆ OutputPosition()

PvlKeyword Isis::PvlTranslationTable::OutputPosition ( const QString translationGroupName)
protected

Retrieves the OutputPosition PvlKeyword for the translation group with the given name.

Parameters
translationGroupNameThe 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.
Returns
PvlKeyword The OutputPosition keyword from the given translation group.
Exceptions
IException::Programmer- "Unable to find translation keyword [OutputPostion] in translation group in file."

Definition at line 483 of file PvlTranslationTable.cpp.

References Isis::PvlContainer::fileName(), findTranslationGroup(), and Isis::IException::Programmer.

Referenced by Isis::LabelTranslationManager::CreateContainer(), and Isis::PvlToXmlTranslationManager::createParentElements().

◆ Translate()

QString Isis::PvlTranslationTable::Translate ( const QString translationGroupName,
const QString inputKeyValue = "" ) const

Translates a single output value from the given translation group name and input value.

Parameters
translationGroupNameThe 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.
inputKeyValueThe value to be translated, from the input keyword.
Returns
QString The translated value, for the output keyword.
Exceptions
IException::Programmer- "No value or default value to translate for translation group."
IException::Programmer- "Unable to find translation value in file."

Definition at line 216 of file PvlTranslationTable.cpp.

References Isis::PvlContainer::fileName(), findTranslationGroup(), and Isis::IException::Programmer.

Referenced by Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToXmlTranslationManager::doTranslation(), Isis::PvlToPvlTranslationManager::Translate(), Isis::XmlToPvlTranslationManager::Translate(), and Isis::PvlToXmlTranslationManager::Translate().

◆ TranslationTable() [1/2]

Pvl & Isis::PvlTranslationTable::TranslationTable ( )
protected

Protected accessor for pvl translation table passed into class.

This method returns a reference to the translation table member.

Returns
Pvl The translation table as a PVL object.

Definition at line 62 of file PvlTranslationTable.cpp.

Referenced by Isis::LabelTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::Auto(), Isis::PvlToXmlTranslationManager::Auto(), Isis::PvlToPvlTranslationManager::DoTranslation(), Isis::PvlToPvlTranslationManager::InputKeyword(), Isis::PvlToXmlTranslationManager::InputKeyword(), and Isis::XmlToPvlTranslationManager::Translate().

◆ TranslationTable() [2/2]

const Pvl & Isis::PvlTranslationTable::TranslationTable ( ) const
protected

Protected accessor for const pvl translation table passed into class.

This method returns a const reference to the translation table member.

Returns
Pvl The translation table as a PVL object.

Definition at line 74 of file PvlTranslationTable.cpp.

◆ validKeywords()

vector< pair< QString, int > > Isis::PvlTranslationTable::validKeywords ( ) const
protectedvirtual

Returns a vector of valid keyword names and their sizes.

A size of -1 indicates that the keyword can be any size.

Returns
vector<pair<QString,int>> A vector of valid keyword names and their sizes.

Reimplemented in Isis::PvlToXmlTranslationManager, and Isis::XmlToPvlTranslationManager.

Definition at line 179 of file PvlTranslationTable.cpp.

References validKeywords().

Referenced by AddTable(), Isis::PvlToXmlTranslationManager::validKeywords(), validKeywords(), and Isis::XmlToPvlTranslationManager::validKeywords().

Member Data Documentation

◆ p_trnsTbl

Pvl Isis::PvlTranslationTable::p_trnsTbl
private

Definition at line 145 of file PvlTranslationTable.h.


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