Skip to content

Commit

Permalink
Merge branch 'main' into cpp17
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith authored and Dan Smith committed Aug 16, 2023
2 parents 750ddd2 + 38ce673 commit 3984e61
Show file tree
Hide file tree
Showing 26 changed files with 263 additions and 209 deletions.
6 changes: 5 additions & 1 deletion UnitTest/sicd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ TEST_CLASS(test_valid_six) { public:
#include "six/modules/c++/six.sicd/unittests/test_valid_six.cpp"
};

}
TEST_CLASS(test_valid_sixsicd) { public:
#include "six/modules/c++/six.sicd/unittests/test_valid_sixsicd.cpp"
};

}
6 changes: 3 additions & 3 deletions six/modules/c++/cphd/include/cphd/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ typedef six::MatchInformation MatchInformation;

enum class Version
{
v100, // {"1.0.0", xml::lite::Uri("urn:CPHD:1.0.0")},
v101, // {"1.0.1", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
v110, // {"1.1.0", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
v1_0_0, // {"1.0.0", xml::lite::Uri("urn:CPHD:1.0.0")},
v1_0_1, // {"1.0.1", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
v1_1_0, // {"1.1.0", xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
};
std::string to_string(Version); // "1.0.0", "1.0.1", "1.1.0"

Expand Down
12 changes: 6 additions & 6 deletions six/modules/c++/cphd/source/CPHDXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ std::unordered_map<std::string, xml::lite::Uri> CPHDXMLControl::getVersionUriMap
static std::map<Version, xml::lite::Uri> getVersionUriMap_()
{
static const std::map<Version, xml::lite::Uri> retval = {
{Version::v100, xml::lite::Uri("urn:CPHD:1.0.0")},
{Version::v101, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
{Version::v110, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
{Version::v1_0_0, xml::lite::Uri("urn:CPHD:1.0.0")},
{Version::v1_0_1, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.0.1")},
{Version::v1_1_0, xml::lite::Uri("http://api.nsgreg.nga.mil/schema/cphd/1.1.0")}
};
return retval;
}
Expand Down Expand Up @@ -231,9 +231,9 @@ std::string cphd::to_string(Version siddVersion)
// Match existing version strings, see CPHDXMLControl::getVersionUriMap
switch (siddVersion)
{
case Version::v100: return "1.0.0";
case Version::v101: return "1.0.1";
case Version::v110: return "1.1.0";
case Version::v1_0_0: return "1.0.0";
case Version::v1_0_1: return "1.0.1";
case Version::v1_1_0: return "1.1.0";
default: break;
}
throw std::logic_error("Unkown 'Version' value.");
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/cphd/source/FileHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace cphd

static const char* getDefaultVersion()
{
static const auto defaultVersion = to_string(Version::v101);
static const auto defaultVersion = to_string(Version::v1_0_1);
return defaultVersion.c_str();
}
const char* FileHeader::DEFAULT_VERSION = getDefaultVersion();
Expand Down
6 changes: 3 additions & 3 deletions six/modules/c++/cphd/source/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ void Metadata::setVersion(const std::string& version)
{
if (version == "1.0.0")
{
setVersion(Version::v100);
setVersion(Version::v1_0_0);
}
else if (version == "1.0.1")
{
setVersion(Version::v101);
setVersion(Version::v1_0_1);
}
else if (version == "1.1.0")
{
setVersion(Version::v110);
setVersion(Version::v1_1_0);
}
else
{
Expand Down
48 changes: 24 additions & 24 deletions six/modules/c++/six.sicd/unittests/test_valid_sixsicd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include <stdlib.h>

#include <string>
#include <string>
#include <std/filesystem>
#include <std/span>
Expand All @@ -37,26 +36,27 @@

#include "TestCase.h"

namespace fs = std::filesystem;

static std::unique_ptr<six::sicd::ComplexData> test_assert_round_trip(const std::string& testName,
const six::sicd::ComplexData& complexData, const std::vector<fs::path>* pSchemaPaths)
const six::sicd::ComplexData& complexData, const std::vector<std::filesystem::path>* pSchemaPaths)
{
auto strXML = six::sicd::Utilities::toXMLString(complexData, pSchemaPaths);
TEST_ASSERT_FALSE(strXML.empty());
return six::sicd::Utilities::parseDataFromString(strXML, pSchemaPaths);
}

inline static const six::UnmodeledS* get_Unmodeled(const six::sicd::ComplexData& complexData, const std::string& strVersion)
inline static const six::Unmodeled* get_Unmodeled(const six::sicd::ComplexData& complexData, const std::string& strVersion)
{
if (strVersion != "1.3.0") // Unmodeled added in SICD 1.3
{
return nullptr;
}
else

if (has_value(complexData.errorStatistics->unmodeled))
{
return complexData.errorStatistics->Unmodeled.get();
return &value(complexData.errorStatistics->unmodeled);
}

return nullptr;
}

static void test_createFakeComplexData_(const std::string& testName, const std::string& strVersion)
Expand All @@ -83,18 +83,18 @@ TEST_CASE(test_createFakeComplexData)
test_createFakeComplexData_(testName, "1.3.0");
}

static void test_assert_unmodeled_(const std::string& testName, const six::UnmodeledS& Unmodeled)
static void test_assert_unmodeled_(const std::string& testName, const six::Unmodeled& unmodeled)
{
TEST_ASSERT_EQ(1.23, Unmodeled.Xrow);
TEST_ASSERT_EQ(4.56, Unmodeled.Ycol);
TEST_ASSERT_EQ(7.89, Unmodeled.XrowYcol);

const auto& unmodeledDecor = Unmodeled.unmodeledDecorr;
TEST_ASSERT(has_value(unmodeledDecor));
TEST_ASSERT_EQ(12.34, value(unmodeledDecor).Xrow.CorrCoefZero);
TEST_ASSERT_EQ(56.78, value(unmodeledDecor).Xrow.DecorrRate);
TEST_ASSERT_EQ(123.4, value(unmodeledDecor).Ycol.CorrCoefZero);
TEST_ASSERT_EQ(567.8, value(unmodeledDecor).Ycol.DecorrRate);
TEST_ASSERT_EQ(1.23, unmodeled.Xrow);
TEST_ASSERT_EQ(4.56, unmodeled.Ycol);
TEST_ASSERT_EQ(7.89, unmodeled.XrowYcol);

TEST_ASSERT(has_value(unmodeled.unmodeledDecorr));
auto&& unmodeledDecor = value(unmodeled.unmodeledDecorr);
TEST_ASSERT_EQ(12.34, value(unmodeledDecor.Xrow).corrCoefZero);
TEST_ASSERT_EQ(56.78, value(unmodeledDecor.Xrow).decorrRate);
TEST_ASSERT_EQ(123.4, value(unmodeledDecor.Ycol).corrCoefZero);
TEST_ASSERT_EQ(567.8, value(unmodeledDecor.Ycol).decorrRate);
}
static void test_assert(const std::string& testName, const six::sicd::ComplexData& complexData)
{
Expand All @@ -105,9 +105,9 @@ static void test_assert(const std::string& testName, const six::sicd::ComplexDat
return;
}
TEST_ASSERT(errorStatistics.get() != nullptr);
auto Unmodeled = errorStatistics->Unmodeled;
TEST_ASSERT(Unmodeled.get() != nullptr);
test_assert_unmodeled_(testName, *Unmodeled);
auto&& unmodeled = errorStatistics->unmodeled;
TEST_ASSERT(has_value(unmodeled));
test_assert_unmodeled_(testName, value(unmodeled));

// for SICD 1.3, also check the polarization type; this is set either in the fake data or scid130.xml
const auto txRcvPolarizationProc = complexData.imageFormation->txRcvPolarizationProc;
Expand All @@ -116,9 +116,9 @@ static void test_assert(const std::string& testName, const six::sicd::ComplexDat
TEST_ASSERT_EQ(strTxRcvPolarizationProc,"OTHER_TxRcvPolarizationProc:OTHER_TxRcvPolarizationProc");
}

static void test_read_sicd_xml(const std::string& testName, const fs::path& path)
static void test_read_sicd_xml(const std::string& testName, const std::filesystem::path& path)
{
const auto pathname = six::testing::getSampleXmlPath(fs::path("six.sicd") / "tests" / "sample_xml", path);
const auto pathname = six::testing::getSampleXmlPath(std::filesystem::path("six.sicd") / "tests" / "sample_xml", path);

// NULL schemaPaths, no validation
auto pComplexData = six::sicd::Utilities::parseDataFromFile(pathname, nullptr /*pSchemaPaths*/);
Expand Down Expand Up @@ -149,5 +149,5 @@ TEST_CASE(test_read_sicd130_xml)
TEST_MAIN(
TEST_CHECK(test_createFakeComplexData);
TEST_CHECK(test_read_sicd110_xml);
TEST_CHECK(test_read_sicd110_xml);
TEST_CHECK(test_read_sicd130_xml);
)
8 changes: 4 additions & 4 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ namespace sidd
// SIDD 3.0.0
enum class Version
{
v100,
v200,
v300,
v1_0_0,
v2_0_0,
v3_0_0,
};
std::string to_string(Version); // "1.0.0", "2.0.0", "3.0.0"
Version normalizeVersion(const std::string&);
Expand Down Expand Up @@ -377,7 +377,7 @@ struct DerivedData : public Data
static const char VENDOR_ID[];
bool equalTo(const Data& rhs) const override;

Version mVersion = Version::v100; // existing code
Version mVersion = Version::v1_0_0; // existing code
six::sidd300::ISMVersion mISMVersion = six::sidd300::ISMVersion::current; // only for SIDD 3.0.0
};
}
Expand Down
10 changes: 5 additions & 5 deletions six/modules/c++/six.sidd/source/DerivedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ DerivedData::DerivedData(Version siddVersion, six::sidd300::ISMVersion ismVersio
}
DerivedData::DerivedData(Version siddVersion) : DerivedData(siddVersion, six::sidd300::get(six::sidd300::ISMVersion::current))
{
if (siddVersion == Version::v300)
if (siddVersion == Version::v3_0_0)
{
throw std::invalid_argument("Must use ISMVersion overload.");
}
}
DerivedData::DerivedData() : DerivedData(Version::v100) // existing code
DerivedData::DerivedData() : DerivedData(Version::v1_0_0) // existing code
{
}

Expand Down Expand Up @@ -99,15 +99,15 @@ DateTime DerivedData::getCollectionStartDateTime() const

const mem::ScopedCopyablePtr<LUT>& DerivedData::getDisplayLUT() const
{
if (mVersion == Version::v100)
if (mVersion == Version::v1_0_0)
{
if (display->remapInformation.get() == nullptr)
{
throw except::Exception(Ctxt("Display.RemapInformation is nullptr"));
}
return display->remapInformation->remapLUT;
}
else if ((mVersion == Version::v200) || (mVersion == Version::v300))
else if ((mVersion == Version::v2_0_0) || (mVersion == Version::v3_0_0))
{
return nitfLUT;
}
Expand Down Expand Up @@ -191,7 +191,7 @@ void DerivedData::setSIDDVersion(Version siddVersion, six::sidd300::ISMVersion i
}
void DerivedData::setSIDDVersion(Version siddVersion)
{
if (siddVersion == Version::v300)
if (siddVersion == Version::v3_0_0)
{
throw std::invalid_argument("Must use ISMVersion overload."); // TODO
}
Expand Down
18 changes: 9 additions & 9 deletions six/modules/c++/six.sidd/source/DerivedXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ six::sidd::Version six::sidd::normalizeVersion(const std::string& strVersion)
// SIDD 3.0.0
if (normalizedVersion == "100")
{
return six::sidd::Version::v100;
return six::sidd::Version::v1_0_0;
}
if (normalizedVersion == "200")
{
return six::sidd::Version::v200;
return six::sidd::Version::v2_0_0;
}
if (normalizedVersion == "300")
{
return six::sidd::Version::v300;
return six::sidd::Version::v3_0_0;
}

if (normalizedVersion == "110")
Expand All @@ -92,9 +92,9 @@ namespace sidd
// Match "incoming" SIDD version strings; this is also what the XML expects, see normalizeVersion()
switch (siddVersion)
{
case Version::v100: return "1.0.0";
case Version::v200: return "2.0.0";
case Version::v300: return "3.0.0";
case Version::v1_0_0: return "1.0.0";
case Version::v2_0_0: return "2.0.0";
case Version::v3_0_0: return "3.0.0";
default: break;
}
throw std::logic_error("Unkown 'Version' value.");
Expand Down Expand Up @@ -330,15 +330,15 @@ DerivedXMLControl::getParser(Version normalizedVersion, std::optional<six::sidd3
// SIDD 1.0.0
// SIDD 2.0.0
// SIDD 3.0.0
if (normalizedVersion == Version::v100)
if (normalizedVersion == Version::v1_0_0)
{
return std::make_unique<DerivedXMLParser100>(mLog);
}
if (normalizedVersion == Version::v200)
if (normalizedVersion == Version::v2_0_0)
{
return std::make_unique<DerivedXMLParser200>(mLog);
}
if (normalizedVersion == Version::v300)
if (normalizedVersion == Version::v3_0_0)
{
if (!ismVersion.has_value())
{
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace six
{
namespace sidd
{
constexpr Version VERSION = Version::v100;
constexpr Version VERSION = Version::v1_0_0;
const char SI_COMMON_URI[] = "urn:SICommon:0.1";
const char ISM_URI[] = "urn:us:gov:ic:ism";
inline static xml::lite::Uri getISMUri()
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ProjectionType DerivedXMLParser200::getProjectionType(const xml::lite::Element&
}


constexpr Version VERSION = Version::v200;
constexpr Version VERSION = Version::v2_0_0;
const char SI_COMMON_URI[] = "urn:SICommon:1.0";
inline static xml::lite::Uri getISMUri()
{
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace six
{
namespace sidd
{
constexpr Version VERSION = Version::v300;
constexpr Version VERSION = Version::v3_0_0;
static const char SI_COMMON_URI[] = "urn:SICommon:1.0";

// There is a need to support two different versions of ISM with SIDD 3.0 :-(
Expand Down
Loading

0 comments on commit 3984e61

Please sign in to comment.