Update FSFW from Upstream #27

Merged
muellerr merged 523 commits from mueller/update-from-upstream into develop 2022-05-17 10:06:59 +02:00
2 changed files with 26 additions and 14 deletions
Showing only changes of commit 8c6c8ad3c0 - Show all commits

View File

@ -11,12 +11,24 @@
#undef minor #undef minor
#endif #endif
const fsfw::Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR, const Version fsfw::FSFW_VERSION = {FSFW_VERSION_MAJOR, FSFW_VERSION_MINOR, FSFW_VERSION_REVISION};
FSFW_VERSION_REVISION};
fsfw::Version::Version(uint32_t major, uint32_t minor, uint32_t revision) Version::Version(uint32_t major, uint32_t minor, uint32_t revision, const char* addInfo)
: major(major), minor(minor), revision(revision) {} : major(major), minor(minor), revision(revision), addInfo(addInfo) {}
void fsfw::Version::getVersion(char* str, size_t maxLen) const { void Version::getVersion(char* str, size_t maxLen) const {
snprintf(str, maxLen, "%d.%d.%d", major, minor, revision); size_t len = snprintf(str, maxLen, "%d.%d.%d", major, minor, revision);
if (addInfo != nullptr) {
snprintf(str + len, maxLen - len, "-%s", addInfo);
}
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
std::ostream& operator<<(std::ostream& os, const Version& v) {
os << v.major << "." << v.minor << "." << v.revision;
if (v.addInfo != nullptr) {
os << "-" << v.addInfo;
}
return os;
}
#endif

View File

@ -8,15 +8,16 @@
#endif #endif
#include <cstdint> #include <cstdint>
namespace fsfw {
class Version { class Version {
public: public:
Version(uint32_t major, uint32_t minor, uint32_t revision); Version(uint32_t major, uint32_t minor, uint32_t revision, const char* addInfo = nullptr);
uint32_t major = 0; uint32_t major = 0;
uint32_t minor = 0; uint32_t minor = 0;
uint32_t revision = 0; uint32_t revision = 0;
// Additional information, e.g. a git SHA hash
const char* addInfo = nullptr;
friend bool operator==(const Version& v1, const Version& v2) { friend bool operator==(const Version& v1, const Version& v2) {
return (v1.major == v2.major and v1.minor == v2.minor and v1.revision == v2.revision); return (v1.major == v2.major and v1.minor == v2.minor and v1.revision == v2.revision);
} }
@ -43,10 +44,7 @@ class Version {
* @param v * @param v
* @return * @return
*/ */
friend std::ostream& operator<<(std::ostream& os, const Version& v) { friend std::ostream& operator<<(std::ostream& os, const Version& v);
os << v.major << "." << v.minor << "." << v.revision;
return os;
}
#endif #endif
/** /**
@ -57,7 +55,9 @@ class Version {
void getVersion(char* str, size_t maxLen) const; void getVersion(char* str, size_t maxLen) const;
}; };
extern const fsfw::Version FSFW_VERSION; namespace fsfw {
extern const Version FSFW_VERSION;
} // namespace fsfw } // namespace fsfw