All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
unix-transport.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_UNIX_TRANSPORT_HPP
23 #define NDN_UNIX_TRANSPORT_HPP
24 
25 #include <string>
26 #include "../common.hpp"
27 #include "transport.hpp"
28 
29 struct ndn_UnixTransport;
30 
31 namespace ndn {
32 
33 class DynamicUInt8Vector;
34 
39 class UnixTransport : public Transport {
40 public:
46  public:
51  ConnectionInfo(const char *filePath)
52  : filePath_(filePath)
53  {
54  }
55 
60  const std::string&
61  getFilePath() const { return filePath_; }
62 
63  virtual
64  ~ConnectionInfo();
65 
66  private:
67  std::string filePath_;
68  };
69 
70  UnixTransport();
71 
78  virtual bool
79  isLocal(const Transport::ConnectionInfo& connectionInfo);
80 
86  virtual bool
87  isAsync();
88 
98  virtual void
99  connect
100  (const Transport::ConnectionInfo& connectionInfo,
101  ElementListener& elementListener, const OnConnected& onConnected);
102 
108  virtual void
109  send(const uint8_t *data, size_t dataLength);
110 
120  virtual void
121  processEvents();
122 
123  virtual bool
124  getIsConnected();
125 
129  virtual void
130  close();
131 
132 private:
133  ptr_lib::shared_ptr<struct ndn_UnixTransport> transport_;
134  ptr_lib::shared_ptr<DynamicUInt8Vector> elementBuffer_;
135  bool isConnected_;
136 };
137 
138 }
139 
140 #endif
A Transport object is used by Face to send packets and to listen for incoming packets.
Definition: transport.hpp:36
virtual bool isAsync()
Override to return false since connect does not need to use the onConnected callback.
virtual bool isLocal(const Transport::ConnectionInfo &connectionInfo)
Determine whether this transport connecting according to connectionInfo is to a node on the current m...
A UnixTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the file path of the Unix s...
Definition: unix-transport.hpp:45
An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElem...
Definition: element-listener.hpp:33
virtual void send(const uint8_t *data, size_t dataLength)
Send data to the host.
virtual void processEvents()
Process any data to receive.
UnixTransport extends the Transport interface to implement communication over a Unix socket...
Definition: unix-transport.hpp:39
const std::string & getFilePath() const
Get the file path given to the constructor.
Definition: unix-transport.hpp:61
virtual void close()
Close the connection to the host.
virtual void connect(const Transport::ConnectionInfo &connectionInfo, ElementListener &elementListener, const OnConnected &onConnected)
Connect according to the info in ConnectionInfo, and processEvents() will use elementListener.
A Transport::ConnectionInfo is a base class for connection information used by subclasses of Transpor...
Definition: transport.hpp:42
Definition: transport-types.h:43
ConnectionInfo(const char *filePath)
Create a ConnectionInfo with the given filePath.
Definition: unix-transport.hpp:51