Skip to content
Snippets Groups Projects

GUI: serialization refactoring part 7

Merged Mikhail Svechnikov requested to merge serialization_7 into main
2 files
+ 66
6
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -12,10 +12,11 @@
//
// ************************************************************************************************
#include "GUI/Model/Device/FootprintItems.h"
#include "Device/Beam/FootprintGauss.h"
#include "Device/Beam/FootprintSquare.h"
#include "GUI/Model/Device/FootprintItems.h"
#include "GUI/Support/XML/Serialize.h"
#include "GUI/Support/XML/UtilXML.h"
namespace {
namespace Tag {
@@ -40,8 +41,33 @@ FootprintGaussianItem::FootprintGaussianItem(double value)
void FootprintGaussianItem::serialize(Streamer& s)
{
s.assertVersion(0);
Serialize::rwProperty(s, Tag::GaussianFootprint, m_gaussianFootprintValue);
// s.assertVersion(0);
// Serialize::rwProperty(s, Tag::GaussianFootprint, m_gaussianFootprintValue);
if (s.xmlReader())
readFrom(s.xmlReader());
else if (s.xmlWriter())
writeTo(s.xmlWriter());
}
void FootprintGaussianItem::writeTo(QXmlStreamWriter *w) const
{
XML::writeAttribute(w, XML::Attrib::version, uint(1));
m_gaussianFootprintValue.writeTo(w, Tag::GaussianFootprint);
}
void FootprintGaussianItem::readFrom(QXmlStreamReader *r)
{
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::GaussianFootprint)
m_gaussianFootprintValue.readFrom(r, tag);
else
r->skipCurrentElement();
}
}
std::unique_ptr<IFootprintFactor> FootprintGaussianItem::createFootprint() const
@@ -58,8 +84,33 @@ FootprintSquareItem::FootprintSquareItem(double value)
void FootprintSquareItem::serialize(Streamer& s)
{
s.assertVersion(0);
Serialize::rwProperty(s, Tag::SquareFootprint, m_squareFootprintValue);
// s.assertVersion(0);
// Serialize::rwProperty(s, Tag::SquareFootprint, m_squareFootprintValue);
if (s.xmlReader())
readFrom(s.xmlReader());
else if (s.xmlWriter())
writeTo(s.xmlWriter());
}
void FootprintSquareItem::writeTo(QXmlStreamWriter *w) const
{
XML::writeAttribute(w, XML::Attrib::version, uint(1));
m_squareFootprintValue.writeTo(w, Tag::SquareFootprint);
}
void FootprintSquareItem::readFrom(QXmlStreamReader *r)
{
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
while (r->readNextStartElement()) {
QString tag = r->name().toString();
if (tag == Tag::SquareFootprint)
m_squareFootprintValue.readFrom(r, tag);
else
r->skipCurrentElement();
}
}
std::unique_ptr<IFootprintFactor> FootprintSquareItem::createFootprint() const
Loading