#pragma once #include #include #include #include #include #include struct EofException{}; struct TimeoutError{}; size_t readn2(int fd, void* buffer, size_t len); size_t readn2Timeout(int fd, void* buffer, size_t len, double* timeout); std::string humanTimeNow(); std::string humanTime(time_t t); std::string humanTime(time_t t, uint32_t nanoseconds); struct SatID { uint32_t gnss{255}; // these could all be 'int16_t' but leads to howling numbers of warnings with protobuf uint32_t sv{0}; uint32_t sigid{0}; bool operator<(const SatID& rhs) const { return std::tie(gnss, sv, sigid) < std::tie(rhs.gnss, rhs.sv, rhs.sigid); } }; template class GetterSetter { public: void set(const T& t) { std::lock_guard mut(d_lock); d_t = t; } T get() { T ret; { std::lock_guard mut(d_lock); ret = d_t; } return ret; } private: T d_t; std::mutex d_lock; };