Goby3  3.1.4
2024.02.22
route.h
Go to the documentation of this file.
1 // Copyright 2011-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 #ifndef GOBY_ACOMMS_ROUTE_ROUTE_H
26 #define GOBY_ACOMMS_ROUTE_ROUTE_H
27 
28 #include <cstdint> // for uint32_t
29 #include <map> // for map
30 
31 #include "goby/acomms/protobuf/route.pb.h" // for RouteManagerConfig
32 #include "goby/util/debug_logger/flex_ostream.h" // for FlexOstream, glog
33 #include "goby/util/debug_logger/term_color.h" // for Colors, Colors::yellow
34 
35 namespace google
36 {
37 namespace protobuf
38 {
39 class Message;
40 } // namespace protobuf
41 } // namespace google
42 
43 namespace goby
44 {
45 namespace acomms
46 {
47 class QueueManager;
48 namespace protobuf
49 {
50 class QueuedMessageMeta;
51 } // namespace protobuf
52 
54 {
55  public:
56  RouteManager() { glog.add_group("goby::acomms::route", util::Colors::yellow); }
57  ~RouteManager() = default;
58 
59  void set_cfg(const protobuf::RouteManagerConfig& cfg);
60  void merge_cfg(const protobuf::RouteManagerConfig& cfg);
61 
62  void handle_in(const protobuf::QueuedMessageMeta& meta,
63  const google::protobuf::Message& data_msg, int modem_id);
64 
66  int modem_id);
67 
68  void add_subnet_queue(QueueManager* manager);
69 
70  bool is_in_route(int modem_id) { return route_index(modem_id) != -1; }
71 
72  int route_index(int modem_id);
73 
74  int find_next_hop(int us, int dest);
75  int find_next_route_hop(int us, int dest);
76 
77  private:
78  RouteManager(const RouteManager&) = delete;
79  RouteManager& operator=(const RouteManager&) = delete;
80 
81  void process_cfg();
82 
83  private:
85 
86  // maps (modem_id & subnet_mask) onto QueueManager
87  std::map<std::uint32_t, QueueManager*> subnet_map_;
88 };
89 } // namespace acomms
90 } // namespace goby
91 
92 #endif
goby::acomms::protobuf::QueuedMessageMeta
Definition: queue.pb.h:1126
goby::acomms::RouteManager::find_next_route_hop
int find_next_route_hop(int us, int dest)
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::acomms::RouteManager::RouteManager
RouteManager()
Definition: route.h:56
goby::acomms::protobuf::RouteManagerConfig
Definition: route.pb.h:201
goby::acomms::RouteManager::handle_out
void handle_out(protobuf::QueuedMessageMeta *meta, const google::protobuf::Message &data_msg, int modem_id)
term_color.h
goby::acomms::RouteManager::add_subnet_queue
void add_subnet_queue(QueueManager *manager)
goby::util::FlexOstream::add_group
void add_group(const std::string &name, Colors::Color color=Colors::nocolor, const std::string &description="")
Add another group to the logger. A group provides related manipulator for categorizing log messages.
flex_ostream.h
goby::acomms::RouteManager::set_cfg
void set_cfg(const protobuf::RouteManagerConfig &cfg)
google::protobuf::Message
Definition: message.h:189
goby::acomms::QueueManager
provides an API to the goby-acomms Queuing Library.
Definition: queue_manager.h:66
goby::acomms::RouteManager
Definition: route.h:53
goby::acomms::RouteManager::find_next_hop
int find_next_hop(int us, int dest)
goby::acomms::RouteManager::handle_in
void handle_in(const protobuf::QueuedMessageMeta &meta, const google::protobuf::Message &data_msg, int modem_id)
goby::glog
util::FlexOstream glog
Access the Goby logger through this object.
goby::acomms::RouteManager::route_index
int route_index(int modem_id)
route.pb.h
goby::util::Colors::yellow
@ yellow
Definition: term_color.h:118
goby::acomms::RouteManager::~RouteManager
~RouteManager()=default
goby::acomms::RouteManager::merge_cfg
void merge_cfg(const protobuf::RouteManagerConfig &cfg)
google
Definition: dccl.h:57
goby::acomms::RouteManager::is_in_route
bool is_in_route(int modem_id)
Definition: route.h:70