Files
MicrOBU/obu-firmware/external/vanetza-idf/vanetza/geonet/timestamp.hpp
T
Ashin Walpola d107534eb2 Keep vanetza-idf in obu-firmware, so a plain clone builds the firmware
obu-firmware builds against the vanetza-idf C-ITS library, which until now
came from the colleague's microbu-esp32c5 tree beside the repository and was
not tracked here, so a clone of this repository could not build the firmware
it ships. The library alone is now part of obu-firmware, as
obu-firmware/external/vanetza-idf: their external/vanetza-idf at commit
cf4b99f, unchanged (9775 files; see its PROVENANCE.md). CMake takes it from
there by default; -DVANETZA_IDF_DIR still points the build elsewhere.

The rest of the colleague's tree (their own VAM firmware, PKI tooling,
station-link Python tools, the V2X2MAP bridge) stays out of this repository
and gitignored; nothing is pushed to their repository. NOTES.md, docs/06,
TODO.md and the pcap verifier's usage line point at the new location.
2026-09-24 10:56:05 +02:00

82 lines
2.4 KiB
C++

#ifndef TIMESTAMP_HPP_SFETMZJI
#define TIMESTAMP_HPP_SFETMZJI
#include <vanetza/common/clock.hpp>
#include <vanetza/geonet/serialization.hpp>
#include <cstdint>
#include <boost/operators.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/units/absolute.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/si/time.hpp>
#include <boost/units/make_scaled_unit.hpp>
namespace vanetza
{
namespace geonet
{
class Timestamp : public boost::totally_ordered<Timestamp>
{
public:
typedef uint32_t value_type;
typedef boost::units::make_scaled_unit<
boost::units::si::time,
boost::units::scale<10, boost::units::static_rational<-3>>
>::type unit_type;
typedef boost::units::absolute<unit_type> absolute_unit_type;
typedef boost::units::quantity<absolute_unit_type, value_type> time_type;
typedef boost::units::quantity<unit_type, value_type> duration_type;
static unit_type millisecond();
static boost::posix_time::ptime start_time();
Timestamp() : m_timestamp(0) {}
Timestamp(time_type t) : m_timestamp(t) {}
Timestamp(const Clock::time_point&);
Timestamp(const boost::posix_time::ptime&);
value_type raw() const { return m_timestamp.value(); }
time_type quantity() const { return m_timestamp; }
Timestamp& operator+=(duration_type);
Timestamp& operator-=(duration_type);
/**
* Timestamp is before other one
* \param other time stamp
* \return true if other timestamp is later
*/
bool before(const Timestamp& other) const;
/**
* Timestamp is after other one
* \param other time stamp
* \return true is other timestamp is before
*/
bool after(const Timestamp& other) const;
private:
time_type m_timestamp; // since 01-01-2004 00:00:00.0
};
// timestamp calculus
Timestamp operator+(Timestamp lhs, Timestamp::duration_type rhs);
Timestamp operator-(Timestamp lhs, Timestamp::duration_type rhs);
Timestamp::duration_type operator-(Timestamp lhs, Timestamp rhs);
// timestamp comparison according to ETSI GeoNet
bool is_greater(Timestamp lhs, Timestamp rhs);
// operators required for boost::totally_ordered
bool operator<(Timestamp lhs, Timestamp rhs);
bool operator==(Timestamp lhs, Timestamp rhs);
// serialization
void serialize(const Timestamp&, OutputArchive&);
void deserialize(Timestamp&, InputArchive&);
} // namespace geonet
} // namespace vanetza
#endif /* TIMESTAMP_HPP_SFETMZJI */