29 VersionNumber() : _value(nextVersionNumber()), _time(
std::chrono::system_clock::now()) {}
38 explicit VersionNumber(std::chrono::system_clock::time_point timestamp);
49 [[nodiscard]] std::chrono::time_point<std::chrono::system_clock>
getTime()
const {
return _time; }
68 explicit operator std::string()
const;
79 std::chrono::time_point<std::chrono::system_clock> _time;
88 static uint64_t nextVersionNumber() {
return ++_lastGeneratedVersionNumber; }
93 static std::atomic<uint64_t> _lastGeneratedVersionNumber;
97 template<
class T,
class CharT>
104 : _value(nextVersionNumber()), _time(timestamp) {}
121 bool printVersion{
false};
122 bool printTime{
false};
124 template<
class ParseContext>
125 constexpr ParseContext::iterator
parse(ParseContext& ctx) {
126 auto it = ctx.begin();
127 if(it == ctx.end()) {
138 if(it != ctx.end() && *it !=
'}') {
139 throw std::format_error(
"Invalid format args for ChimeraTK::VersionNumber.");
141 if(!printVersion && !printTime) {
148 template<
typename FormatContext>
157 return std::vformat_to(ctx.out(), fmt, std::make_format_args(v._value, v._time));
Class for generating and holding version numbers without exposing a numeric representation.
bool operator>=(const VersionNumber &other) const
bool operator!=(const VersionNumber &other) const
std::chrono::time_point< std::chrono::system_clock > getTime() const
Return the time stamp associated with this version number.
VersionNumber(std::nullptr_t)
Create null version number, which is guaranteed to be smaller than all version numbers generated with...
bool operator==(const VersionNumber &other) const
Comparison operators.
VersionNumber & operator=(const VersionNumber &other)=default
Copy the full state of another VersionNumber object.
bool operator>(const VersionNumber &other) const
bool operator<=(const VersionNumber &other) const
VersionNumber()
Default constructor: Generate new unique version number with current time as time stamp.
friend struct std::formatter
VersionNumber(const VersionNumber &other)=default
Copy constructor.
friend std::ostream & operator<<(std::ostream &stream, const VersionNumber &version)
Stream operator passing the human readable representation to an ostream.
bool operator<(const VersionNumber &other) const
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)