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 
35 class UnixTransport : public Transport {
36 public:
42  public:
47  ConnectionInfo(const char *filePath)
48  : filePath_(filePath)
49  {
50  }
51 
56  const std::string&
57  getFilePath() const { return filePath_; }
58 
59  virtual
60  ~ConnectionInfo();
61 
62  private:
63  std::string filePath_;
64  };
65 
66  UnixTransport();
67 
74  virtual bool
75  isLocal(const Transport::ConnectionInfo& connectionInfo);
76 
82  virtual bool
83  isAsync();
84 
94  virtual void
95  connect
96  (const Transport::ConnectionInfo& connectionInfo,
97  ElementListener& elementListener, const OnConnected& onConnected);
98 
104  virtual void
105  send(const uint8_t *data, size_t dataLength);
106 
116  virtual void
117  processEvents();
118 
119  virtual bool
120  getIsConnected();
121 
125  virtual void
126  close();
127 
128 private:
129  ptr_lib::shared_ptr<struct ndn_UnixTransport> transport_;
130  ptr_lib::shared_ptr<DynamicUInt8Vector> elementBuffer_;
131  bool isConnected_;
132 };
133 
134 }
135 
136 #endif
Definition: transport.hpp:32
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
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:41
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.
Definition: unix-transport.hpp:35
const std::string & getFilePath() const
Get the file path given to the constructor.
Definition: unix-transport.hpp:57
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:38
Definition: transport-types.h:43
ConnectionInfo(const char *filePath)
Create a ConnectionInfo with the given filePath.
Definition: unix-transport.hpp:47