Loading isis/src/base/objs/TrackingTable/TrackingTable.cpp +22 −18 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ namespace Isis { TableRecord dummyRecord; TableField fileNameField("FileName", TableField::Text, fieldLength); TableField serialNumberField("SerialNumber", TableField::Text, fieldLength); TableField indexField("Index", TableField::Integer); TableField indexField("PixelValue", TableField::Integer); dummyRecord += fileNameField; dummyRecord += serialNumberField; dummyRecord += indexField; Loading @@ -128,38 +128,42 @@ namespace Isis { /** * Returns the FileName at the given index within m_fileList. * Returns the FileName that corresponds to a pixel value. * * @param index The index to find the filename for * @returns FileName The FileName at the index specified * @param pixel The pixel value to find the filename for * @returns @b FileName The FileName represented by the pixel value */ FileName TrackingTable::indexToFileName(unsigned int index) { if (index < VALID_MINUI4) { QString msg = "Cannot convert index [" + toString(index) + "] to a filename, index is below valid minimum [" FileName TrackingTable::pixelToFileName(unsigned int pixel) { if (pixel < VALID_MINUI4) { QString msg = "Cannot convert pixel [" + toString(pixel) + "] to a filename, pixel is below valid minimum [" + toString(VALID_MINUI4) + "]."; throw IException(IException::Programmer, msg, _FILEINFO_); } unsigned int shiftedIndex = index - VALID_MINUI4; if (shiftedIndex >= (unsigned int)m_fileList.size()) { QString msg = "Cannot convert index [" + toString(index) + "] to a filename, index is out of bounds."; unsigned int index = pixel - VALID_MINUI4; if (index >= (unsigned int)m_fileList.size()) { QString msg = "Cannot convert pixel [" + toString(pixel) + "] to a filename, pixel is above valid maximum [" + toString(VALID_MINUI4 + m_fileList.size()) + "]."; throw IException(IException::Programmer, msg, _FILEINFO_); } return m_fileList[shiftedIndex].first; return m_fileList[index].first; } /** * Returns the index of the filename/serialnumber combination. * Returns the pixel value of the filename/serialnumber combination. * * @param file The FileName within m_fileList to find the index of * @param serialNumber The QString of the serial number within m_fileList to find the index of * @return unsighned int The index of the filename/serialnumber combination * @param file The FileName within m_fileList to find the pixel value of * @param serialNumber The QString of the serial number within m_fileList * to find the pixel value of * * @return @b unsigned @b int The pixel value corresponding to the * filename/serialnumber combination */ unsigned int TrackingTable::fileNameToIndex(FileName file, QString serialNumber) { unsigned int TrackingTable::fileNameToPixel(FileName file, QString serialNumber) { for (int i = 0; i < m_fileList.size(); i++) { if (m_fileList[i].first == file) { return i + VALID_MINUI4; Loading isis/src/base/objs/TrackingTable/TrackingTable.h +3 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ namespace Isis { * * @internal * @history 2018-07-26 Jesse Mapel - Added offset based on minimum unsigned integer value. * Renamed methods to better convey output/input meaning. */ class TrackingTable{ Loading @@ -60,9 +61,9 @@ namespace Isis { Table toTable(); FileName indexToFileName(unsigned int index); FileName pixelToFileName(unsigned int pixel); unsigned int fileNameToIndex(FileName file, QString serialNumber); unsigned int fileNameToPixel(FileName file, QString serialNumber); private: Loading isis/src/base/objs/TrackingTable/TrackingTable.truth +20 −12 Original line number Diff line number Diff line Loading @@ -11,18 +11,20 @@ Second record: fileName2.cub, 123 Third record : fileName3.dat, 456789 TrackingTable object created Testing the indexToFileName method ... FileName at index 3: fileName1.cub FileName at index 4: fileName2.cub FileName at index 5: fileName3.dat FileName at index 6 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert index [6] to a filename, index is out of bounds. Testing the fileNameToIndex method ... Index of FileName fileName1.cub: 3 Index of FileName fileName2.cub: 4 Index of FileName fileName3.cub: 5 Index of the non-existent FileName fileName4.cub (demonstrating its addition): 6 Testing the pixelToFileName method ... FileName with pixel value 2 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert pixel [2] to a filename, pixel is below valid minimum [3]. FileName with pixel value 3: fileName1.cub FileName with pixel value 4: fileName2.cub FileName with pixel value 5: fileName3.dat FileName with pixel value 6 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert pixel [6] to a filename, pixel is above valid maximum [6]. Testing the fileNameToPixel method ... Pixel value of FileName fileName1.cub: 3 Pixel value of FileName fileName2.cub: 4 Pixel value of FileName fileName3.cub: 5 Pixel value of the non-existent FileName fileName4.cub (demonstrating its addition): 6 Testing the toTable method ... First record : fileName1.cub, 1234567890, 3 Loading @@ -33,6 +35,12 @@ Fourth record: fileName4.cub, 12345678901234567890, 6 Creating a new TrackingTable object with the table returned from toTable method ... New TrackingTable object created Verifying that the pixel values are the same ... Pixel value of FileName fileName1.cub: 3 Pixel value of FileName fileName2.cub: 4 Pixel value of FileName fileName3.cub: 5 Pixel value of FileName fileName4.cub: 6 Testing that the Table returned from toTable on new TrackingTable matches ... First record : fileName1.cub, 1234567890, 3 Second record: fileName2.cub, 123, 4 Loading isis/src/base/objs/TrackingTable/unitTest.cpp +29 −14 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) { TrackingTable trackingTable1; trackingTable1.fileNameToIndex("fileName1.cub", "1"); trackingTable1.fileNameToPixel("fileName1.cub", "1"); Table tableOut1 = trackingTable1.toTable(); Loading Loading @@ -68,14 +68,16 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the indexToFileName method ..." << endl; cout << "Testing the pixelToFileName method ..." << endl; for (int i = 3; i < 7; i++) { for (int i = 2; i < 7; i++) { try { cout << "FileName at index " << i << ": " << trackingTable2.indexToFileName(i).name() << endl; cout << "FileName with pixel value " << i << ": " << trackingTable2.pixelToFileName(i).name() << endl; } catch (IException e) { cout << "FileName at index " << i << " does not exist and an exception is thrown." << endl; cout << "FileName with pixel value " << i << " does not exist and an exception is thrown." << endl; e.print(); } } Loading @@ -83,16 +85,16 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the fileNameToIndex method ..." << endl; cout << "Testing the fileNameToPixel method ..." << endl; cout << "Index of FileName fileName1.cub: " << trackingTable2.fileNameToIndex("fileName1.cub", "1234567890") << endl; cout << "Index of FileName fileName2.cub: " << trackingTable2.fileNameToIndex("fileName2.cub", "123") << endl; cout << "Index of FileName fileName3.cub: " << trackingTable2.fileNameToIndex("fileName3.dat", "456789") << endl; cout << "Index of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable2.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; cout << "Pixel value of FileName fileName1.cub: " << trackingTable2.fileNameToPixel("fileName1.cub", "1234567890") << endl; cout << "Pixel value of FileName fileName2.cub: " << trackingTable2.fileNameToPixel("fileName2.cub", "123") << endl; cout << "Pixel value of FileName fileName3.cub: " << trackingTable2.fileNameToPixel("fileName3.dat", "456789") << endl; cout << "Pixel value of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable2.fileNameToPixel("fileName4.cub", "12345678901234567890") << endl; cout << endl; Loading Loading @@ -125,6 +127,19 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Verifying that the pixel values are the same ..." << endl; cout << "Pixel value of FileName fileName1.cub: " << trackingTable3.fileNameToPixel("fileName1.cub", "1234567890") << endl; cout << "Pixel value of FileName fileName2.cub: " << trackingTable3.fileNameToPixel("fileName2.cub", "123") << endl; cout << "Pixel value of FileName fileName3.cub: " << trackingTable3.fileNameToPixel("fileName3.dat", "456789") << endl; cout << "Pixel value of FileName fileName4.cub: " << trackingTable3.fileNameToPixel("fileName4.cub", "12345678901234567890") << endl; cout << endl; cout << "Testing that the Table returned from toTable on new TrackingTable matches ..." << endl; Loading Loading
isis/src/base/objs/TrackingTable/TrackingTable.cpp +22 −18 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ namespace Isis { TableRecord dummyRecord; TableField fileNameField("FileName", TableField::Text, fieldLength); TableField serialNumberField("SerialNumber", TableField::Text, fieldLength); TableField indexField("Index", TableField::Integer); TableField indexField("PixelValue", TableField::Integer); dummyRecord += fileNameField; dummyRecord += serialNumberField; dummyRecord += indexField; Loading @@ -128,38 +128,42 @@ namespace Isis { /** * Returns the FileName at the given index within m_fileList. * Returns the FileName that corresponds to a pixel value. * * @param index The index to find the filename for * @returns FileName The FileName at the index specified * @param pixel The pixel value to find the filename for * @returns @b FileName The FileName represented by the pixel value */ FileName TrackingTable::indexToFileName(unsigned int index) { if (index < VALID_MINUI4) { QString msg = "Cannot convert index [" + toString(index) + "] to a filename, index is below valid minimum [" FileName TrackingTable::pixelToFileName(unsigned int pixel) { if (pixel < VALID_MINUI4) { QString msg = "Cannot convert pixel [" + toString(pixel) + "] to a filename, pixel is below valid minimum [" + toString(VALID_MINUI4) + "]."; throw IException(IException::Programmer, msg, _FILEINFO_); } unsigned int shiftedIndex = index - VALID_MINUI4; if (shiftedIndex >= (unsigned int)m_fileList.size()) { QString msg = "Cannot convert index [" + toString(index) + "] to a filename, index is out of bounds."; unsigned int index = pixel - VALID_MINUI4; if (index >= (unsigned int)m_fileList.size()) { QString msg = "Cannot convert pixel [" + toString(pixel) + "] to a filename, pixel is above valid maximum [" + toString(VALID_MINUI4 + m_fileList.size()) + "]."; throw IException(IException::Programmer, msg, _FILEINFO_); } return m_fileList[shiftedIndex].first; return m_fileList[index].first; } /** * Returns the index of the filename/serialnumber combination. * Returns the pixel value of the filename/serialnumber combination. * * @param file The FileName within m_fileList to find the index of * @param serialNumber The QString of the serial number within m_fileList to find the index of * @return unsighned int The index of the filename/serialnumber combination * @param file The FileName within m_fileList to find the pixel value of * @param serialNumber The QString of the serial number within m_fileList * to find the pixel value of * * @return @b unsigned @b int The pixel value corresponding to the * filename/serialnumber combination */ unsigned int TrackingTable::fileNameToIndex(FileName file, QString serialNumber) { unsigned int TrackingTable::fileNameToPixel(FileName file, QString serialNumber) { for (int i = 0; i < m_fileList.size(); i++) { if (m_fileList[i].first == file) { return i + VALID_MINUI4; Loading
isis/src/base/objs/TrackingTable/TrackingTable.h +3 −2 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ namespace Isis { * * @internal * @history 2018-07-26 Jesse Mapel - Added offset based on minimum unsigned integer value. * Renamed methods to better convey output/input meaning. */ class TrackingTable{ Loading @@ -60,9 +61,9 @@ namespace Isis { Table toTable(); FileName indexToFileName(unsigned int index); FileName pixelToFileName(unsigned int pixel); unsigned int fileNameToIndex(FileName file, QString serialNumber); unsigned int fileNameToPixel(FileName file, QString serialNumber); private: Loading
isis/src/base/objs/TrackingTable/TrackingTable.truth +20 −12 Original line number Diff line number Diff line Loading @@ -11,18 +11,20 @@ Second record: fileName2.cub, 123 Third record : fileName3.dat, 456789 TrackingTable object created Testing the indexToFileName method ... FileName at index 3: fileName1.cub FileName at index 4: fileName2.cub FileName at index 5: fileName3.dat FileName at index 6 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert index [6] to a filename, index is out of bounds. Testing the fileNameToIndex method ... Index of FileName fileName1.cub: 3 Index of FileName fileName2.cub: 4 Index of FileName fileName3.cub: 5 Index of the non-existent FileName fileName4.cub (demonstrating its addition): 6 Testing the pixelToFileName method ... FileName with pixel value 2 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert pixel [2] to a filename, pixel is below valid minimum [3]. FileName with pixel value 3: fileName1.cub FileName with pixel value 4: fileName2.cub FileName with pixel value 5: fileName3.dat FileName with pixel value 6 does not exist and an exception is thrown. **PROGRAMMER ERROR** Cannot convert pixel [6] to a filename, pixel is above valid maximum [6]. Testing the fileNameToPixel method ... Pixel value of FileName fileName1.cub: 3 Pixel value of FileName fileName2.cub: 4 Pixel value of FileName fileName3.cub: 5 Pixel value of the non-existent FileName fileName4.cub (demonstrating its addition): 6 Testing the toTable method ... First record : fileName1.cub, 1234567890, 3 Loading @@ -33,6 +35,12 @@ Fourth record: fileName4.cub, 12345678901234567890, 6 Creating a new TrackingTable object with the table returned from toTable method ... New TrackingTable object created Verifying that the pixel values are the same ... Pixel value of FileName fileName1.cub: 3 Pixel value of FileName fileName2.cub: 4 Pixel value of FileName fileName3.cub: 5 Pixel value of FileName fileName4.cub: 6 Testing that the Table returned from toTable on new TrackingTable matches ... First record : fileName1.cub, 1234567890, 3 Second record: fileName2.cub, 123, 4 Loading
isis/src/base/objs/TrackingTable/unitTest.cpp +29 −14 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ int main(int argc, char *argv[]) { TrackingTable trackingTable1; trackingTable1.fileNameToIndex("fileName1.cub", "1"); trackingTable1.fileNameToPixel("fileName1.cub", "1"); Table tableOut1 = trackingTable1.toTable(); Loading Loading @@ -68,14 +68,16 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the indexToFileName method ..." << endl; cout << "Testing the pixelToFileName method ..." << endl; for (int i = 3; i < 7; i++) { for (int i = 2; i < 7; i++) { try { cout << "FileName at index " << i << ": " << trackingTable2.indexToFileName(i).name() << endl; cout << "FileName with pixel value " << i << ": " << trackingTable2.pixelToFileName(i).name() << endl; } catch (IException e) { cout << "FileName at index " << i << " does not exist and an exception is thrown." << endl; cout << "FileName with pixel value " << i << " does not exist and an exception is thrown." << endl; e.print(); } } Loading @@ -83,16 +85,16 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Testing the fileNameToIndex method ..." << endl; cout << "Testing the fileNameToPixel method ..." << endl; cout << "Index of FileName fileName1.cub: " << trackingTable2.fileNameToIndex("fileName1.cub", "1234567890") << endl; cout << "Index of FileName fileName2.cub: " << trackingTable2.fileNameToIndex("fileName2.cub", "123") << endl; cout << "Index of FileName fileName3.cub: " << trackingTable2.fileNameToIndex("fileName3.dat", "456789") << endl; cout << "Index of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable2.fileNameToIndex("fileName4.cub", "12345678901234567890") << endl; cout << "Pixel value of FileName fileName1.cub: " << trackingTable2.fileNameToPixel("fileName1.cub", "1234567890") << endl; cout << "Pixel value of FileName fileName2.cub: " << trackingTable2.fileNameToPixel("fileName2.cub", "123") << endl; cout << "Pixel value of FileName fileName3.cub: " << trackingTable2.fileNameToPixel("fileName3.dat", "456789") << endl; cout << "Pixel value of the non-existent FileName fileName4.cub (demonstrating its addition): " << trackingTable2.fileNameToPixel("fileName4.cub", "12345678901234567890") << endl; cout << endl; Loading Loading @@ -125,6 +127,19 @@ int main(int argc, char *argv[]) { cout << endl; cout << "Verifying that the pixel values are the same ..." << endl; cout << "Pixel value of FileName fileName1.cub: " << trackingTable3.fileNameToPixel("fileName1.cub", "1234567890") << endl; cout << "Pixel value of FileName fileName2.cub: " << trackingTable3.fileNameToPixel("fileName2.cub", "123") << endl; cout << "Pixel value of FileName fileName3.cub: " << trackingTable3.fileNameToPixel("fileName3.dat", "456789") << endl; cout << "Pixel value of FileName fileName4.cub: " << trackingTable3.fileNameToPixel("fileName4.cub", "12345678901234567890") << endl; cout << endl; cout << "Testing that the Table returned from toTable on new TrackingTable matches ..." << endl; Loading