AOSharedServiceLibrary
zmq_interface.h
1 /*
2 MIT License Block
3 
4 Copyright (c) 2016 Alex Barry
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 */
24 
25 #ifndef AOSSL_ZMQ_INCLUDE_ZMQ_INTERFACE_H_
26 #define AOSSL_ZMQ_INCLUDE_ZMQ_INTERFACE_H_
27 
28 #include <string>
29 
30 const int REQ_RESP = 0;
31 const int PUB_SUB = 1;
32 
34 
37 class Zmqio {
38  public:
39  virtual ~Zmqio() {}
41  virtual std::string recv() = 0;
42 
44  virtual char * crecv() = 0;
45 
47  virtual void send(const char * msg, int msg_size) = 0;
48 
50  virtual void send(std::string msg) = 0;
51 
53  virtual void subscribe(std::string filter) = 0;
54 };
55 
57 
60 class ZmqOut: public Zmqio {
61  public:
62  virtual ~ZmqOut() {}
63 
65  virtual void connect(std::string conn_str) = 0;
66 
68  virtual void send(const char * msg, int msg_size) = 0;
69 
71  virtual void send(std::string msg) = 0;
72 
74  virtual std::string recv() = 0;
75 
77  virtual char * crecv() = 0;
78 
80  virtual void subscribe(std::string filter) = 0;
81 };
82 
84 
87 class ZmqIn: public Zmqio {
88  public:
89  virtual ~ZmqIn() {}
90 
92  virtual void bind(std::string conn_str) = 0;
93 
95  virtual std::string recv() = 0;
96 
98  virtual char * crecv() = 0;
99 
101  virtual void send(const char * msg, int msg_size) = 0;
102 
104  virtual void send(std::string msg) = 0;
105 
107  virtual void subscribe(std::string filter) = 0;
108 };
109 #endif // AOSSL_ZMQ_INCLUDE_ZMQ_INTERFACE_H_
An Interface for ZMQIO.
Definition: zmq_interface.h:37
An Inbound ZMQ Manager.
Definition: zmq_interface.h:87
virtual char * crecv()=0
Recieve a message on the port.
virtual void subscribe(std::string filter)=0
Subscribe on a particular filter (only effective for Pub/Sub)
An Outbound ZMQ Manager.
Definition: zmq_interface.h:60
virtual void send(const char *msg, int msg_size)=0
Send a message on the port.
virtual std::string recv()=0
Recieve a message on the port.