Skip to content

Commit

Permalink
Add versioning for backward compatibility (#257)
Browse files Browse the repository at this point in the history
* Add versioning for backward compatibility
* Changing the time initialization to 0
* Update BeamDataPoint.h

---------

Co-authored-by: Andrew Sutton <asutton@anniegpvm01.fnal.gov>
  • Loading branch information
atcsutton and Andrew Sutton authored Apr 5, 2024
1 parent a8a087e commit 036d1ad
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions DataModel/BeamDataPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ struct BeamDataPoint : public SerialisableObject {

BeamDataPoint() : value(0.), unit(""), time(0) {}
BeamDataPoint(double Value, const std::string& Unit, uint64_t time=0)
: value(Value), unit(Unit), time(0) {}
: value(Value), unit(Unit), time(time) {}
double value;
std::string unit;
uint64_t time;

template<class Archive> void serialize(Archive & ar,
const unsigned int version)
{
ar & value;
ar & unit;
ar & time;
if (version > 0)
ar & time;
}

virtual bool Print() override {
Expand All @@ -41,3 +42,14 @@ struct BeamDataPoint : public SerialisableObject {
}

};

// Need to increment the class version since we added time as a new variable
// the version number ensures backward compatibility when serializing
BOOST_CLASS_VERSION(BeamDataPoint, 1)







0 comments on commit 036d1ad

Please sign in to comment.