Goby v2
node_interface.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 PROTOBUFNODE20110607H
24 #define PROTOBUFNODE20110607H
25 
26 #include "zeromq_service.h"
27 
28 namespace goby
29 {
30 namespace common
31 {
32 template <typename NodeTypeBase> class NodeInterface
33 {
34  public:
35  ZeroMQService* zeromq_service() { return zeromq_service_; }
36  virtual void send(const NodeTypeBase& msg, int socket_id, const std::string& group = "") = 0;
37  virtual void subscribe(const std::string& identifier, int socket_id) = 0;
38 
39  protected:
40  NodeInterface(ZeroMQService* service) : zeromq_service_(service)
41  {
42  zeromq_service_->connect_inbox_slot(&NodeInterface<NodeTypeBase>::inbox, this);
43  }
44 
45  virtual void inbox(MarshallingScheme marshalling_scheme, const std::string& identifier,
46  const std::string& body, int socket_id) = 0;
47 
48  private:
49  ZeroMQService* zeromq_service_;
50 };
51 } // namespace common
52 } // namespace goby
53 
54 #endif
The global namespace for the Goby project.