1#ifndef TIME_HPP_GFC1AX6E
2#define TIME_HPP_GFC1AX6E
4#include <vanetza/common/clock.hpp>
5#include <boost/units/quantity.hpp>
6#include <boost/units/systems/si/time.hpp>
13namespace si = boost::units::si;
14typedef boost::units::quantity<boost::units::si::time> Duration;
17
18
19
20
21
22
23template<
typename U,
typename T>
24Clock::duration clock_cast(
const boost::units::quantity<U, T>& duration)
26 using chrono_type = std::chrono::duration<Duration::value_type>;
27 const Duration quantity { duration };
28 const chrono_type chrono_duration { quantity / si::seconds };
29 return std::chrono::duration_cast<
Clock::duration>(chrono_duration);
33
34
35
36
37
38
39template<
class T,
class P>
40Duration clock_cast(
const std::chrono::duration<T, P>& duration)
42 using chrono_type = std::chrono::duration<Duration::value_type>;
43 const auto value = std::chrono::duration_cast<chrono_type>(duration);
44 return value.count() * si::seconds;
ChunckPacket is a packet consisting of several memory chunks.
ByteBufferConvertible & operator[](OsiLayer ol)
ChunkPacket & merge(ChunkPacket &packet, OsiLayer from, OsiLayer to)
const ByteBufferConvertible & layer(OsiLayer ol) const
const ByteBufferConvertible & operator[](OsiLayer ol) const
ByteBufferConvertible & layer(OsiLayer ol)
std::size_t size(OsiLayer from, OsiLayer to) const
ChunkPacket extract(OsiLayer from, OsiLayer to)
std::size_t size(OsiLayer from, OsiLayer to) const
buffer_const_range operator[](OsiLayer layer) const
void set_boundary(OsiLayer, unsigned bytes)
const ByteBuffer & buffer() const
CohesivePacket(const ByteBuffer &buffer, OsiLayer layer)
void trim(OsiLayer from, unsigned bytes)
std::size_t size(OsiLayer single_layer) const
value_type operator[](size_type) const
byte_view_range(ByteBuffer &&)
byte_view_range(const ByteBuffer::const_iterator &, const ByteBuffer::const_iterator &)
ByteBuffer::const_pointer data() const
void encode(units::Duration)
units::Duration decode() const