Goby v2
route.h
1 // Copyright 2009-2018 Toby Schneider (http://gobysoft.org/index.wt/people/toby)
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 //
6 //
7 // This file is part of the Goby Underwater Autonomy Project Libraries
8 // ("The Goby Libraries").
9 //
10 // The Goby Libraries are free software: you can redistribute them and/or modify
11 // them under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 2.1 of the License, or
13 // (at your option) any later version.
14 //
15 // The Goby Libraries are distributed in the hope that they will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
22 
23 #ifndef ROUTE20120410
24 #define ROUTE20120410
25 
26 #include "goby/acomms/protobuf/queue.pb.h"
27 #include "goby/acomms/protobuf/route.pb.h"
28 #include "goby/acomms/queue/queue_manager.h"
29 
30 namespace goby
31 {
32 namespace acomms
33 {
35 {
36  public:
37  RouteManager() { glog.add_group("goby::acomms::route", common::Colors::yellow); }
38  ~RouteManager() {}
39 
40  void set_cfg(const protobuf::RouteManagerConfig& cfg);
41  void merge_cfg(const protobuf::RouteManagerConfig& cfg);
42 
43  void handle_in(const protobuf::QueuedMessageMeta& meta,
44  const google::protobuf::Message& data_msg, int modem_id);
45 
46  void handle_out(protobuf::QueuedMessageMeta* meta, const google::protobuf::Message& data_msg,
47  int modem_id);
48 
49  void add_subnet_queue(QueueManager* manager);
50 
51  bool is_in_route(int modem_id) { return route_index(modem_id) != -1; }
52 
53  int route_index(int modem_id);
54 
55  int find_next_hop(int us, int dest);
56  int find_next_route_hop(int us, int dest);
57 
58  private:
59  RouteManager(const RouteManager&);
60  RouteManager& operator=(const RouteManager&);
61 
62  void process_cfg();
63 
64  private:
66 
67  // maps (modem_id & subnet_mask) onto QueueManager
68  std::map<uint32, QueueManager*> subnet_map_;
69 };
70 } // namespace acomms
71 } // namespace goby
72 
73 #endif
provides an API to the goby-acomms Queuing Library.
Definition: queue_manager.h:49
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...
common::FlexOstream glog
Access the Goby logger through this object.
The global namespace for the Goby project.