26#ifndef GOBY_ACOMMS_QUEUE_QUEUE_MANAGER_H
27#define GOBY_ACOMMS_QUEUE_QUEUE_MANAGER_H
37#include <boost/signals2/signal.hpp>
38#include <google/protobuf/descriptor.h>
56class ModemTransmission;
89 template <
typename ProtobufMessage>
92 add_queue(ProtobufMessage::descriptor(), queue_cfg);
96 void add_queue(
const google::protobuf::Descriptor* desc,
159 template <
typename ProtobufMessage>
void info(std::ostream* os)
const
161 info(ProtobufMessage::descriptor(), os);
165 void info(
const google::protobuf::Descriptor* desc, std::ostream* os)
const;
173 std::string
msg_string(
const google::protobuf::Descriptor* desc)
175 return desc->full_name() +
" (" + goby::util::as<std::string>(codec_->
id(desc)) +
")";
183 unsigned dccl_id = codec_->
id(
msg.GetDescriptor());
184 if (!queues_.count(dccl_id))
188 return queues_[dccl_id]->meta_from_msg(
msg);
242 void qsize(
Queue* q);
246 bool first_user_frame);
257 std::string encode_repeated(
const std::list<QueuedMessage>& msgs);
258 std::list<QueuedMessage> decode_repeated(
const std::string& orig_bytes);
259 unsigned size_repeated(
const std::list<QueuedMessage>& msgs);
264 std::map<unsigned, std::shared_ptr<Queue> > queues_;
268 std::multimap<unsigned, Queue*> waiting_for_ack_;
271 unsigned packet_ack_{0};
275 std::set<ModemId> network_ack_src_ids_;
276 std::set<ModemId> route_additional_modem_ids_;
279 std::map<ModemId, std::string> encrypt_rules_;
285 std::string glog_push_group_;
286 std::string glog_pop_group_;
287 std::string glog_priority_group_;
288 std::string glog_out_group_;
289 std::string glog_in_group_;
293 class ManipulatorManager
298 manips_.insert(std::make_pair(
id, manip));
304 std::multimap<unsigned int, goby::acomms::protobuf::Manipulator>::const_iterator;
305 std::pair<iterator, iterator> p = manips_.equal_range(
id);
307 for (
auto it = p.first; it != p.second; ++it)
309 if (it->second == manip)
316 void clear() { manips_.clear(); }
321 std::multimap<unsigned, goby::acomms::protobuf::Manipulator> manips_;
324 ManipulatorManager manip_manager_;
Exception class for libdccl.
provides an API to the goby-acomms Queuing Library.
boost::signals2::signal< void(protobuf::QueuedMessageMeta *meta, const google::protobuf::Message &data_msg, int modem_id)> signal_out_route
Used by a router to change next-hop destination (in meta)
const std::string & glog_push_group()
QueueManager()
constructor
boost::signals2::signal< void(const google::protobuf::Message &orig_msg)> signal_expire
Signals when a message is expires (exceeds its time-to-live or ttl) before being sent (if queue....
boost::signals2::signal< void(const protobuf::ModemTransmission &request_msg, google::protobuf::Message *data_msg)> signal_data_on_demand
Forwards the data request to the application layer. This advanced feature is used when queue....
void set_cfg(const protobuf::QueueManagerConfig &cfg)
Set (and overwrite completely if present) the current configuration. (protobuf::QueueManagerConfig de...
void add_queue(const protobuf::QueuedMessageEntry &queue_cfg)
Add a DCCL queue for use with QueueManager. Note that the queue must be added before receiving messag...
~QueueManager()=default
destructor
void handle_modem_receive(const protobuf::ModemTransmission &message)
Receive incoming data from the modem.
const std::string & glog_pop_group()
void info_all(std::ostream *os) const
Writes a human readable summary (including DCCLCodec info) of all loaded queues.
void handle_modem_data_request(protobuf::ModemTransmission *msg)
Finds data to send to the modem.
boost::signals2::signal< void(const protobuf::QueuedMessageMeta &meta, const google::protobuf::Message &data_msg, int modem_id)> signal_in_route
Used by a router to intercept messages and requeue them if desired.
std::string msg_string(const google::protobuf::Descriptor *desc)
protobuf::QueuedMessageMeta meta_from_msg(const google::protobuf::Message &msg)
boost::signals2::signal< void(protobuf::QueueSize size)> signal_queue_size_change
Signals when any queue changes size (message is popped or pushed)
const std::string & glog_in_group()
void push_message(const google::protobuf::Message &new_message)
Push a message (and add the queue if it does not exist)
void push_message(const google::protobuf::Message &new_message, const protobuf::QueuedMessageMeta *meta)
void info(const google::protobuf::Descriptor *desc, std::ostream *os) const
An alterative form for getting information for Queues for message types not known at compile-time ("d...
void flush_queue(const protobuf::QueueFlush &flush)
Flush (delete all messages in) a queue.
void do_work()
Calculates which messages have expired and emits the goby::acomms::QueueManager::signal_expire as nec...
const std::string & glog_priority_group()
void add_queue(const google::protobuf::Descriptor *desc, const protobuf::QueuedMessageEntry &queue_cfg)
Alternative method for adding Queues when using Dynamic Protobuf Messages.
void info(std::ostream *os) const
Writes a human readable summary (including DCCLCodec info) of the queue for the provided DCCL type to...
void merge_cfg(const protobuf::QueueManagerConfig &cfg)
Set (and merge "repeat" fields) the current configuration. (protobuf::QueueManagerConfig defined in a...
boost::signals2::signal< void(const google::protobuf::Message &msg)> signal_receive
Signals when a DCCL message is received.
boost::signals2::signal< void(const protobuf::ModemTransmission &ack_msg, const google::protobuf::Message &orig_msg)> signal_ack
Signals when acknowledgment of proper message receipt has been received. This is only sent for queues...
int modem_id()
The current modem ID (MAC address) of this node.
const std::string & glog_out_group()
std::ostream & operator<<(std::ostream &os, const MACManager &mac)
The global namespace for the Goby project.
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::PROTOBUF_NAMESPACE_ID::MessageOptions, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::GobyMessageOptions >, 11, false > msg