Thunderbots Project
Loading...
Searching...
No Matches
protobuf_sink.h
1#pragma once
2#include <fstream>
3#include <g3log/logmessage.hpp>
4#include <iostream>
5
6#include "google/protobuf/any.pb.h"
7#include "software/logger/custom_logging_levels.h"
8#include "software/logger/proto_logger.h"
9#include "software/networking/unix/threaded_unix_sender.h"
10
11static const std::string TYPE_DELIMITER = "!!!";
12
13
14using UnixSenderMap =
15 std::unordered_map<std::string, std::unique_ptr<ThreadedUnixSender>>;
16
17
19{
20 public:
26 ProtobufSink(std::string runtime_dir,
27 const std::shared_ptr<ProtoLogger>& proto_logger);
28
29 /*
30 * Send the protobuf to /tmp/tbots/(protobuf typename)
31 *
32 * @param log_entry The entry to log
33 */
34 void sendProtobuf(g3::LogMessageMover log_entry);
35
36 private:
37 UnixSenderMap unix_senders_;
38 std::string runtime_dir_;
39 std::shared_ptr<ProtoLogger> proto_logger;
40};
41
42/*
43 * Serialize a protobuf and pack it into a msg
44 *
45 * @param os The output stream
46 * @param message The message to serialize
47 * @return The output stream containing the base64 encoded serialized Any protobuf
48 */
49std::ostream& operator<<(std::ostream& os, const google::protobuf::Message& message);
Definition protobuf_sink.h:19