mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-03 19:30:04 +02:00

- removed getClientServerAPIVersion in server (not used) - removed rxr side (clientversion compatibility check), removed enum as well as it is now done on the client side. - versionAPI.h - GITBRANCH changed to RELEASE - dates for all API changed to "sem_version date". Scripts to compile servers modified for this. Empty "branch" name will end up with developer for sem_version. - Version class with constructor taking in the long version (APILIB date). Other member functions including concise(to get sem_version for new releases and date for old releases), - bypassing initial tests, also now bypasses the client-rxr compatibility check (at rx_hostname command) - previously, compatibility between client-det was ensuring both had the same detector API (eg. same APIJUNGFRAU) - Now, compatibility only checks APILIB (client side) and detector API(eg. APIJUNGFRAU) (detector side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. - If server is from an older release, it will compare dates like previous implementation (APIJUNGFRAU from both client and det) - - previously, compatibility between client-rxr was ensuring both had the same APIRECEIVER - Now, compatibility only checks APILIB (client side) and APIRECEIVER (rxr side) have same major version. It only does backward compatibility test. Rest is upto user to ensure. - If rxr is from an older release, it will compare dates like previous implementation (APIRECEIVER from both client and rxr) - removed APIGUI, evalVersionVariables.sh, genVersionHeader.sh (not needed or not used) - clientVersion, rxrversion and detectorserverversion all return strings and not integers (in hex) anymore. Depending if it has semantic versioning, it will print that or the date if it is too old. - fixed in python (strings for versions) - check_version function in detector server changed to "initial checks" as it only checks server-firmware compatibility and initial server checks. Client compatibilities are moved to client side. - --version gives sem_version and date? Is date needed as well. The clientversion, detserverversion and rxrversion API gives only sem_version (no date) - - formatting
84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
// SPDX-License-Identifier: LGPL-3.0-or-other
|
|
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
|
#include "sls/Version.h"
|
|
#include "sls/sls_detector_exceptions.h"
|
|
#include "sls/string_utils.h"
|
|
#include <sstream>
|
|
|
|
namespace sls {
|
|
|
|
Version::Version(const std::string &s) {
|
|
auto list = split(s, ' ');
|
|
// only date from previous releases
|
|
if (list.size() == 1) {
|
|
date_ = list[0];
|
|
}
|
|
// semantic versioning + date
|
|
else {
|
|
version_ = list[0];
|
|
date_ = list[1];
|
|
}
|
|
}
|
|
|
|
bool Version::hasSemanticVersioning() const {
|
|
return version_ != defaultBranch_;
|
|
}
|
|
|
|
std::string Version::getVersion() const { return version_; }
|
|
std::string Version::getDate() const { return date_; }
|
|
|
|
std::string Version::concise() const {
|
|
if (hasSemanticVersioning())
|
|
return version_;
|
|
return date_;
|
|
}
|
|
|
|
int Version::getMajorVersion() const {
|
|
int major = 0, minor = 0, patch = 0;
|
|
if (sscanf(version_.c_str(), "%d.%d.%d", &major, &minor, &patch) == 3) {
|
|
return major;
|
|
}
|
|
throw sls::RuntimeError("Could not get major version from " + version_);
|
|
}
|
|
|
|
bool Version::isBackwardCompatible(const Version &other) const {
|
|
return getMajorVersion() == other.getMajorVersion();
|
|
}
|
|
|
|
bool Version::operator!=(const Version &other) const {
|
|
return !(*this == other);
|
|
}
|
|
|
|
bool Version::operator==(const Version &other) const {
|
|
// both have semantic versioning
|
|
if (hasSemanticVersioning() && other.hasSemanticVersioning()) {
|
|
return version_ == other.getVersion();
|
|
}
|
|
// compare dates
|
|
return date_ == other.getDate();
|
|
}
|
|
|
|
bool Version::operator<=(const Version &other) const {
|
|
// both have semantic versioning
|
|
if (hasSemanticVersioning() && other.hasSemanticVersioning()) {
|
|
// release version
|
|
std::string otherVersion = other.getVersion();
|
|
if (version_ == otherVersion)
|
|
return true;
|
|
// less than
|
|
return (std::lexicographical_compare(version_.begin(), version_.end(),
|
|
otherVersion.begin(),
|
|
otherVersion.end()));
|
|
}
|
|
// compare dates
|
|
return date_ <= other.getDate();
|
|
}
|
|
|
|
std::ostream &operator<<(std::ostream &out, const Version &v) {
|
|
std::ostringstream oss;
|
|
oss << v.getVersion() << " " << v.getDate();
|
|
return out << oss.str();
|
|
}
|
|
|
|
} // namespace sls
|