Go to the documentation of this file.
24 #ifndef GOBY_MIDDLEWARE_LOG_LOG_ENTRY_H
25 #define GOBY_MIDDLEWARE_LOG_LOG_ENTRY_H
27 #include <boost/bimap.hpp>
28 #include <boost/crc.hpp>
54 template <
int Bytes>
struct uint
63 using type = std::uint16_t;
67 using type = std::uint32_t;
71 using type = std::uint64_t;
122 static std::map<
LogFilter, std::function<
void(
const std::vector<unsigned char>&
data)>>
128 : data_(std::move(
data)),
130 type_(std::move(
type)),
131 group_(std::string(
group)),
138 void parse(std::istream* s);
148 const std::vector<unsigned char>&
data()
const {
return data_; }
150 const std::string&
type()
const {
return type_; }
173 template <
typename Un
signed>
174 Unsigned read_one(std::istream* s, boost::crc_32_type* crc =
nullptr)
176 auto size = std::numeric_limits<Unsigned>::digits / 8;
177 std::string
str(size,
'\0');
178 s->read(&
str[0], size);
180 crc->process_bytes(&
str[0], size);
182 return string_to_netint<Unsigned>(
str);
185 template <
typename Un
signed> std::string netint_to_string(Unsigned u)
const
187 auto size = std::numeric_limits<Unsigned>::digits / 8;
188 std::string s(size,
'\0');
189 for (
int i = 0; i < size; ++i) s[i] = (u >> (size - (i + 1)) * 8) & 0xff;
193 template <
typename Un
signed> Unsigned string_to_netint(std::string s)
const
196 std::string::size_type size = std::numeric_limits<Unsigned>::digits / 8;
198 s.erase(0, s.size() - size);
200 s.insert(0, size - s.size(),
'\0');
202 for (decltype(size) i = 0; i < size; ++i)
203 u |=
static_cast<Unsigned
>(s[i] & 0xff) << ((size - (i + 1)) * 8);
208 std::vector<unsigned char> data_;
222 const std::string magic_{
"GBY3"};
static time_point now() noexcept
Returns the current system time unless SimulatorSettings::using_sim_time is set to true,...
static constexpr int crc_bytes_
The global namespace for the Goby project.
LogException(const std::string &s)
static int current_version_
static constexpr int version_bytes_
const Group & group() const
static uint< version_bytes_ >::type version_
static constexpr int timestamp_bytes_
static constexpr uint< scheme_bytes_ >::type scheme_group_index_
static constexpr int scheme_bytes_
static constexpr decltype(version_) invalid_version
std::string str(TimeType value=SystemClock::now< TimeType >())
Returns the provided time (or current time if omitted) as a human-readable string.
static constexpr int compiled_current_version
bool operator<(const LogFilter &a, const LogFilter &b)
const std::string & type() const
static constexpr uint< scheme_bytes_ >::type scheme_type_index_
static std::map< int, std::function< void(const Group &group)> > new_group_hook
static std::map< int, std::function< void(const std::string &type)> > new_type_hook
std::chrono::time_point< SystemClock > time_point
const goby::time::SystemClock::time_point & timestamp() const
const std::vector< unsigned char > & data() const
type
Generic JSON types used in JWTs.
static void set_current_version(decltype(version_) version)
static constexpr int magic_bytes_
size_t data_size(const Container &c)
Class for grouping publications in the Goby middleware. Analogous to "topics" in ROS,...
static std::map< LogFilter, std::function< void(const std::vector< unsigned char > &data)> > filter_hook
static constexpr int group_bytes_
LogEntry(std::vector< unsigned char > data, int scheme, std::string type, const Group &group, goby::time::SystemClock::time_point timestamp=goby::time::SystemClock::now())
void parse(std::istream *s)
static constexpr int type_bytes_
static constexpr int size_bytes_
void serialize(std::ostream *s) const
void parse_version(std::istream *s)