async-unix-transport.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_ASYNC_UNIX_TRANSPORT_HPP
23 #define NDN_ASYNC_UNIX_TRANSPORT_HPP
24 
25 #include <string>
26 #include "../common.hpp"
27 #include "transport.hpp"
28 
29 namespace boost { namespace asio { namespace local { class stream_protocol; }}}
30 
31 namespace ndn {
32 
33 template<class AsioProtocol> class AsyncSocketTransport;
34 
42 class AsyncUnixTransport : public Transport {
43 public:
49  public:
54  ConnectionInfo(const char *filePath)
55  : filePath_(filePath)
56  {
57  }
58 
63  const std::string&
64  getFilePath() const { return filePath_; }
65 
66  virtual
67  ~ConnectionInfo();
68 
69  private:
70  std::string filePath_;
71  };
72 
79  AsyncUnixTransport(boost::asio::io_service& ioService);
80 
87  virtual bool
88  isLocal(const Transport::ConnectionInfo& connectionInfo);
89 
94  virtual bool
95  isAsync();
96 
107  virtual void
108  connect
109  (const Transport::ConnectionInfo& connectionInfo,
110  ElementListener& elementListener, const OnConnected& onConnected);
111 
119  virtual void
120  send(const uint8_t *data, size_t dataLength);
121 
125  virtual void
126  processEvents();
127 
128  virtual bool
129  getIsConnected();
130 
134  virtual void
135  close();
136 
137  virtual ~AsyncUnixTransport();
138 
139 private:
140  ptr_lib::shared_ptr<AsyncSocketTransport<boost::asio::local::stream_protocol> >
141  socketTransport_;
142 };
143 
144 }
145 
146 #endif
An AsyncUnixTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the file path of the ...
Definition: async-unix-transport.hpp:48
Definition: transport.hpp:32
AsyncSocketTransport is a helper template class for AsyncTcpTransport and AsyncUnixTransport to imple...
Definition: async-unix-transport.hpp:33
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
Copyright (C) 2015-2016 Regents of the University of California.
Definition: threadsafe-face.hpp:27
virtual void connect(const Transport::ConnectionInfo &connectionInfo, ElementListener &elementListener, const OnConnected &onConnected)
Connect according to the info in connectionInfo, and use elementListener.
An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElem...
Definition: element-listener.hpp:33
virtual void close()
Close the connection to the host.
virtual void processEvents()
Do nothing since the asio io_service reads the socket.
virtual bool isAsync()
Override to return true since connect needs to use the onConnected callback.
const std::string & getFilePath() const
Get the file path given to the constructor.
Definition: async-unix-transport.hpp:64
virtual void send(const uint8_t *data, size_t dataLength)
Send data to the host.
AsyncUnixTransport(boost::asio::io_service &ioService)
Create an AsyncUnixTransport in the unconnected state.
virtual bool isLocal(const Transport::ConnectionInfo &connectionInfo)
Determine whether this transport connecting according to connectionInfo is to a node on the current m...
ConnectionInfo(const char *filePath)
Create a ConnectionInfo with the given filePath.
Definition: async-unix-transport.hpp:54
A Transport::ConnectionInfo is a base class for connection information used by subclasses of Transpor...
Definition: transport.hpp:38
AsyncUnixTransport extends Transport for async communication over a Unix socket using Boost's asio io...
Definition: async-unix-transport.hpp:42