FairMQ  1.3.7
C++ Message Passing Framework
FairMQSocket.h
1 /********************************************************************************
2  * Copyright (C) 2014-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIRMQSOCKET_H_
10 #define FAIRMQSOCKET_H_
11 
12 #include <string>
13 #include <vector>
14 #include <memory>
15 
16 #include "FairMQMessage.h"
18 
20 {
21  public:
22  FairMQSocket() {}
23  FairMQSocket(FairMQTransportFactory* fac): fTransport(fac) {}
24 
25  virtual std::string GetId() = 0;
26 
27  virtual bool Bind(const std::string& address) = 0;
28  virtual bool Connect(const std::string& address) = 0;
29 
30  virtual int Send(FairMQMessagePtr& msg, int timeout = -1) = 0;
31  virtual int Receive(FairMQMessagePtr& msg, int timeout = -1) = 0;
32  virtual int64_t Send(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0;
33  virtual int64_t Receive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, int timeout = -1) = 0;
34 
35  virtual void Close() = 0;
36 
37  virtual void SetOption(const std::string& option, const void* value, size_t valueSize) = 0;
38  virtual void GetOption(const std::string& option, void* value, size_t* valueSize) = 0;
39 
40  virtual void SetLinger(const int value) = 0;
41  virtual int GetLinger() const = 0;
42  virtual void SetSndBufSize(const int value) = 0;
43  virtual int GetSndBufSize() const = 0;
44  virtual void SetRcvBufSize(const int value) = 0;
45  virtual int GetRcvBufSize() const = 0;
46  virtual void SetSndKernelSize(const int value) = 0;
47  virtual int GetSndKernelSize() const = 0;
48  virtual void SetRcvKernelSize(const int value) = 0;
49  virtual int GetRcvKernelSize() const = 0;
50 
51  virtual unsigned long GetBytesTx() const = 0;
52  virtual unsigned long GetBytesRx() const = 0;
53  virtual unsigned long GetMessagesTx() const = 0;
54  virtual unsigned long GetMessagesRx() const = 0;
55 
56  FairMQTransportFactory* GetTransport() { return fTransport; }
57  void SetTransport(FairMQTransportFactory* transport) { fTransport=transport; }
58 
59  virtual ~FairMQSocket() {};
60 
61  private:
62  FairMQTransportFactory* fTransport{nullptr};
63 };
64 
65 using FairMQSocketPtr = std::unique_ptr<FairMQSocket>;
66 
67 namespace fair
68 {
69 namespace mq
70 {
71 
72 using Socket = FairMQSocket;
73 using SocketPtr = FairMQSocketPtr;
74 struct SocketError : std::runtime_error { using std::runtime_error::runtime_error; };
75 
76 } /* namespace mq */
77 } /* namespace fair */
78 
79 #endif /* FAIRMQSOCKET_H_ */
Definition: FairMQSocket.h:74
Definition: FairMQTransportFactory.h:28
Definition: FairMQSocket.h:19
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23

privacy