Goby v2
moos_node.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 MOOSNODE20110419H
24 #define MOOSNODE20110419H
25 
26 #include "moos_serializer.h"
27 #include "moos_string.h"
28 
29 #include "goby/common/node_interface.h"
30 #include "goby/common/zeromq_service.h"
31 
32 namespace goby
33 {
34 namespace moos
35 {
36 class MOOSNode : public goby::common::NodeInterface<CMOOSMsg>
37 {
38  public:
40 
41  virtual ~MOOSNode() {}
42 
43  void send(const CMOOSMsg& msg, int socket_id, const std::string& group_unused = "");
44  void subscribe(const std::string& full_or_partial_moos_name, int socket_id);
45  void unsubscribe(const std::string& full_or_partial_moos_name, int socket_id);
46 
47  CMOOSMsg& newest(const std::string& key);
48 
49  // returns newest for "BOB", "BIG", when substr is "B"
50  std::vector<CMOOSMsg> newest_substr(const std::string& substring);
51 
52  protected:
53  // not const because CMOOSMsg requires mutable for many const calls...
54  virtual void moos_inbox(CMOOSMsg& msg) = 0;
55 
56  private:
57  void inbox(goby::common::MarshallingScheme marshalling_scheme, const std::string& identifier,
58  const std::string& body, int socket_id);
59 
60  private:
61  std::map<std::string, boost::shared_ptr<CMOOSMsg> > newest_vars;
62 };
63 } // namespace moos
64 } // namespace goby
65 
66 #endif
The global namespace for the Goby project.