diff options
author | Jerry Ge <jerry.ge@arm.com> | 2023-08-02 21:48:39 +0000 |
---|---|---|
committer | Tai Ly <tai.ly@arm.com> | 2023-09-06 17:25:38 +0000 |
commit | c4733b015781b044041955997f79c4667eb841a0 (patch) | |
tree | 49180c544dbc050eb0342845b6fd8653f24c651d /include | |
parent | c6939a4d269968a34b0ae0aa579f0f0736aaeccc (diff) | |
download | serialization_lib-c4733b015781b044041955997f79c4667eb841a0.tar.gz |
Enable backward compatibilityv0.90a0
Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Change-Id: I572ae70f8d693c89739ab892a31157235700c3f2
Diffstat (limited to 'include')
-rw-r--r-- | include/tosa_serialization_handler.h | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/include/tosa_serialization_handler.h b/include/tosa_serialization_handler.h index 24c77a6..a980336 100644 --- a/include/tosa_serialization_handler.h +++ b/include/tosa_serialization_handler.h @@ -57,7 +57,7 @@ struct TosaVersion enum class compat_t { COMPLETELY_COMPATIBLE, - PARTIALLY_COMPATIBLE, + BACKWARD_COMPATIBLE, NOT_COMPATIBLE }; @@ -86,17 +86,54 @@ struct TosaVersion return str; } - compat_t is_compatible(const TosaVersion& rhs) const + static bool less_than(const TosaVersion& version1, const TosaVersion& version2) { - if (rhs._major == _major && rhs._minor == _minor) + if (version1._major < version2._major) { - if (rhs._patch == _patch && rhs._draft == _draft) + return true; + } + else if (version1._major == version2._major) + { + if (version1._minor < version2._minor) + { + return true; + } + else if (version1._minor == version2._minor) { - return TosaVersion::compat_t::COMPLETELY_COMPATIBLE; + if (version1._patch < version2._patch) + { + return true; + } + else if (version1._patch == version2._patch) + { + if (version1._draft == true && version2._draft == false) + { + return true; + } + } } - else + } + return false; + } + + static TosaVersion::compat_t is_compatible(const TosaVersion& tosa_fb_version, + const TosaVersion& serializer_version) + { + bool major_match = (serializer_version._major == tosa_fb_version._major); + bool minor_match = (serializer_version._minor == tosa_fb_version._minor); + bool patch_match = (serializer_version._patch == tosa_fb_version._patch); + bool draft_match = (serializer_version._draft == tosa_fb_version._draft); + + if (major_match && minor_match && patch_match && draft_match) + return TosaVersion::compat_t::COMPLETELY_COMPATIBLE; + + // We currently support backward compatibility starting from 0.70.0 + // TODO: need to double-check this logic right before TOSA 1.0.0 release + if ((tosa_fb_version._major == 0 && tosa_fb_version._minor >= 70) || (tosa_fb_version._major > 0)) + { + if (less_than(tosa_fb_version, serializer_version)) { - return TosaVersion::compat_t::PARTIALLY_COMPATIBLE; + return TosaVersion::compat_t::BACKWARD_COMPATIBLE; } } return TosaVersion::compat_t::NOT_COMPATIBLE; |