Skip to content

Commit

Permalink
already had convertJ2KToXML(), make it virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Mar 13, 2024
1 parent 0c3ec12 commit 7ffac43
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 45 deletions.
5 changes: 2 additions & 3 deletions six/modules/c++/six.sidd/include/six/sidd/DerivedXMLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ struct DerivedXMLParser : public six::XMLParser
XMLElem parent = nullptr) const = 0;
XMLElem convertAnnotationToXML(const Annotation *a,
XMLElem parent = nullptr) const;
virtual XMLElem convertCompressionToXML(const Compression*, XMLElem = nullptr) const { return nullptr; }
void convertJ2KToXML(const J2KCompression* c, XMLElem& parent) const;
XMLElem convertSFAGeometryToXML(const SFAGeometry *g,
public: virtual void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const {}
protected: XMLElem convertSFAGeometryToXML(const SFAGeometry *g,
XMLElem parent = nullptr) const;
XMLElem convertGeographicCoordinateSystemToXML(
const SFAGeographicCoordinateSystem* geographicCoordinateSystem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ struct DerivedXMLParser200 final : public DerivedXMLParser
static ProjectionType getProjectionType(const xml::lite::Element& measurementElem);
static std::unique_ptr<LUT> parseSingleLUT(const std::string& lutStr, size_t size);

static xml::lite::Element& convertCompressionToXML(const DerivedXMLParser&,
const Compression& compression, xml::lite::Element& parent);

static xml::lite::Element& convertDigitalElevationDataToXML(const DerivedXMLParser&,
const DigitalElevationData&, xml::lite::Element& parent);

Expand Down Expand Up @@ -88,7 +91,6 @@ struct DerivedXMLParser200 final : public DerivedXMLParser

virtual void parseCompressionFromXML(const xml::lite::Element* compressionElem,
Compression& compression) const;
XMLElem convertCompressionToXML(const Compression*, XMLElem parent = nullptr) const override;

virtual XMLElem convertDisplayToXML(const Display& display,
XMLElem parent = nullptr) const override;
Expand Down Expand Up @@ -136,8 +138,7 @@ struct DerivedXMLParser200 final : public DerivedXMLParser
static xml::lite::Element& convertFilterToXML(const DerivedXMLParser&,
const std::string& name, const Filter&, xml::lite::Element& parent);

static void convertJ2KToXML(const DerivedXMLParser&,
const J2KCompression&, xml::lite::Element& parent);
void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const override;

void parseJ2KCompression(const xml::lite::Element* j2kElem,
J2KCompression& j2k) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ struct DerivedXMLParser300 final : public DerivedXMLParser
std::unique_ptr<LUT> parseSingleLUT(const xml::lite::Element& elem, size_t size) const;

void parseCompressionFromXML(const xml::lite::Element& compressionElem, Compression&) const;
XMLElem convertCompressionToXML(const Compression*, XMLElem parent = nullptr) const override;

void parseInteractiveProcessingFromXML(const xml::lite::Element& interactiveElem, InteractiveProcessing&) const;
void parseLookupTableFromXML(const xml::lite::Element& lookupElem, LookupTable&) const;
void parseNonInteractiveProcessingFromXML(const xml::lite::Element& procElem, NonInteractiveProcessing&) const;
void parsePredefinedFilterFromXML(const xml::lite::Element* predefinedElem, Filter::Predefined&) const;
void parseKernelFromXML(const xml::lite::Element* kernelElem, Filter::Kernel&) const;
void parseBankFromXML(const xml::lite::Element* bankElem, Filter::Bank&) const;
void parseFilterFromXML(const xml::lite::Element& filterELem, Filter& filter) const;

void parseJ2KCompression(const xml::lite::Element& j2kElem, J2KCompression& j2k) const;
static void convertJ2KToXML(const DerivedXMLParser&,
const J2KCompression&, xml::lite::Element& parent);

void convertJ2KToXML(const J2KCompression&, xml::lite::Element&) const override;
void parseGeoDataFromXML(const xml::lite::Element& elem, GeoDataBase&) const;
void parseDigitalElevationDataFromXML(const xml::lite::Element& elem, DigitalElevationData&) const;
void parseProductGenerationOptionsFromXML(const xml::lite::Element& optionsElem, ProductGenerationOptions&) const;
Expand Down
22 changes: 10 additions & 12 deletions six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ xml::lite::Document* DerivedXMLParser200::toXML(const DerivedData* derived) cons
// optional
if (derived->compression.get())
{
convertCompressionToXML(derived->compression.get(), root);
convertCompressionToXML(*this, *(derived->compression), *root);
}
// optional
if (derived->digitalElevationData.get())
Expand Down Expand Up @@ -1482,28 +1482,26 @@ xml::lite::Element& DerivedXMLParser200::convertFilterToXML(const DerivedXMLPars
return filterElem;
}

XMLElem DerivedXMLParser200::convertCompressionToXML(const Compression* compression, XMLElem pParent) const
xml::lite::Element& DerivedXMLParser200::convertCompressionToXML(const DerivedXMLParser& parser,
const Compression& compression, xml::lite::Element& parent)
{
assert(pParent != nullptr);
auto& parent = *pParent;

const auto& parser = *this;
auto& compressionElem = parser.newElement("Compression", parent);
auto& j2kElem = parser.newElement("J2K", compressionElem);
auto& originalElem = parser.newElement("Original", j2kElem);
convertJ2KToXML(parser, compression->original, originalElem);
parser.convertJ2KToXML(compression.original, originalElem);

if (compression->parsed.get())
if (compression.parsed.get())
{
auto& parsedElem = parser.newElement("Parsed", j2kElem);
convertJ2KToXML(parser, *(compression->parsed), parsedElem);
parser.convertJ2KToXML(*(compression.parsed), parsedElem);
}
return &compressionElem;
return compressionElem;
}

void DerivedXMLParser200::convertJ2KToXML(const DerivedXMLParser& parser,
const J2KCompression& j2k, xml::lite::Element& parent)
void DerivedXMLParser200::convertJ2KToXML(const J2KCompression& j2k, xml::lite::Element& parent) const
{
auto& parser = *this;

parser.createInt("NumWaveletLevels", j2k.numWaveletLevels, parent);
parser.createInt("NumBands", j2k.numBands, parent);

Expand Down
24 changes: 3 additions & 21 deletions six/modules/c++/six.sidd/source/DerivedXMLParser300.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ xml::lite::Document* DerivedXMLParser300::toXML(const DerivedData* derived) cons
// optional
if (derived->compression.get())
{
convertCompressionToXML(derived->compression.get(), root);
DerivedXMLParser200::convertCompressionToXML(*this, *(derived->compression), *root);
}
// optional
if (derived->digitalElevationData.get())
Expand Down Expand Up @@ -339,28 +339,10 @@ void DerivedXMLParser300::parseJ2KCompression(const xml::lite::Element& j2kElem,
}
}

XMLElem DerivedXMLParser300::convertCompressionToXML(const Compression* compression, XMLElem pParent) const
void DerivedXMLParser300::convertJ2KToXML(const J2KCompression& j2k, xml::lite::Element& parent) const
{
assert(pParent != nullptr);
auto& parent = *pParent;
auto& parser = *this;

const auto& parser = *this;
auto& compressionElem = parser.newElement("Compression", parent);
auto& j2kElem = parser.newElement("J2K", compressionElem);
auto& originalElem = parser.newElement("Original", j2kElem);
convertJ2KToXML(parser, compression->original, originalElem);

if (compression->parsed.get())
{
auto& parsedElem = parser.newElement("Parsed", j2kElem);
convertJ2KToXML(parser, *(compression->parsed), parsedElem);
}
return &compressionElem;
}

void DerivedXMLParser300::convertJ2KToXML(const DerivedXMLParser& parser,
const J2KCompression& j2k, xml::lite::Element& parent)
{
parser.createInt("NumWaveletLevels", j2k.numWaveletLevels, parent);
parser.createInt("NumBands", j2k.numBands, parent);

Expand Down

0 comments on commit 7ffac43

Please sign in to comment.