Skip to content

Commit

Permalink
Correct registration of RepeatDateTime serialisation ECFLOW-1992
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosbento authored Nov 29, 2024
2 parents 66aadf8 + 009cf50 commit a36bea6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/attribute/src/ecflow/attribute/RepeatAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@ bool RepeatDay::operator==(const RepeatDay& rhs) const {
}
return true;
}

// =========================================================================================

template <class Archive>
Expand Down Expand Up @@ -1840,6 +1841,7 @@ void Repeat::serialize(Archive& ar, std::uint32_t const version) {

CEREAL_TEMPLATE_SPECIALIZE(RepeatBase);
CEREAL_TEMPLATE_SPECIALIZE_V(RepeatDate);
CEREAL_TEMPLATE_SPECIALIZE_V(RepeatDateTime);
CEREAL_TEMPLATE_SPECIALIZE_V(RepeatDateList);
CEREAL_TEMPLATE_SPECIALIZE_V(RepeatInteger);
CEREAL_TEMPLATE_SPECIALIZE_V(RepeatEnumerated);
Expand All @@ -1848,6 +1850,7 @@ CEREAL_TEMPLATE_SPECIALIZE_V(RepeatDay);
CEREAL_TEMPLATE_SPECIALIZE_V(Repeat);

CEREAL_REGISTER_TYPE(RepeatDate)
CEREAL_REGISTER_TYPE(RepeatDateTime)
CEREAL_REGISTER_TYPE(RepeatDateList)
CEREAL_REGISTER_TYPE(RepeatInteger)
CEREAL_REGISTER_TYPE(RepeatEnumerated)
Expand Down
15 changes: 15 additions & 0 deletions libs/core/src/ecflow/core/Chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include <boost/lexical_cast.hpp>

#include "ecflow/core/Serialization.hpp"

namespace ecf {

namespace {
Expand Down Expand Up @@ -237,4 +239,17 @@ bool operator>=(const Duration& rhs, const Duration& lhs) {
return !(rhs < lhs);
}

template <class Archive>
void Instant::serialize(Archive& ar, std::uint32_t const version) {
ar(instant_);
}

template <class Archive>
void Duration::serialize(Archive& ar, std::uint32_t const version) {
ar(duration_);
}

CEREAL_TEMPLATE_SPECIALIZE_V(Instant);
CEREAL_TEMPLATE_SPECIALIZE_V(Duration);

} // namespace ecf
12 changes: 12 additions & 0 deletions libs/core/src/ecflow/core/Chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <chrono>
#include <string>

namespace cereal {
class access;
}

namespace ecf {

class Instant;
Expand Down Expand Up @@ -47,6 +51,10 @@ class Instant {

private:
instant_t instant_;

friend class cereal::access;
template <class Archive>
void serialize(Archive& ar, std::uint32_t const version);
};

std::ostream& operator<<(std::ostream& o, const Instant& v);
Expand Down Expand Up @@ -76,6 +84,10 @@ class Duration {

private:
duration_t duration_;

friend class cereal::access;
template <class Archive>
void serialize(Archive& ar, std::uint32_t const version);
};

std::ostream& operator<<(std::ostream& o, const Duration& v);
Expand Down
1 change: 1 addition & 0 deletions libs/core/src/ecflow/core/Serialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <string>

#include <cereal/archives/json.hpp>
#include <cereal/types/chrono.hpp>
#include <cereal/types/deque.hpp>
#include <cereal/types/map.hpp>
#include <cereal/types/memory.hpp>
Expand Down

0 comments on commit a36bea6

Please sign in to comment.