ndn::Transport Class Referenceabstract

Provides a "TLV-oriented" delivery service. More...

#include <ndn-cxx/transport/transport.hpp>

+ Inheritance diagram for ndn::Transport:
+ Collaboration diagram for ndn::Transport:

Classes

class  Error
 

Public Types

using ReceiveCallback = std::function< void(const Block &)>
 
enum class  State {
  CLOSED ,
  CONNECTING ,
  RUNNING ,
  PAUSED
}
 

Public Member Functions

virtual ~Transport ()=default
 
virtual void close ()=0
 Close the connection. More...
 
virtual void connect (boost::asio::io_service &ioService, ReceiveCallback receiveCallback)
 Asynchronously open the connection. More...
 
State getState () const noexcept
 Return the current state of the transport. More...
 
virtual void pause ()=0
 Pause the transport, canceling all pending operations. More...
 
virtual void resume ()=0
 Resume the transport. More...
 
virtual void send (const Block &block)=0
 Send a TLV block through the transport. More...
 

Protected Member Functions

void setState (State state) noexcept
 

Protected Attributes

boost::asio::io_service * m_ioService = nullptr
 
ReceiveCallback m_receiveCallback
 

Detailed Description

Provides a "TLV-oriented" delivery service.

Definition at line 36 of file transport.hpp.

Member Typedef Documentation

◆ ReceiveCallback

using ndn::Transport::ReceiveCallback = std::function<void(const Block&)>

Definition at line 54 of file transport.hpp.

Member Enumeration Documentation

◆ State

enum ndn::Transport::State
strong
Enumerator
CLOSED 
CONNECTING 
RUNNING 
PAUSED 

Definition at line 47 of file transport.hpp.

Constructor & Destructor Documentation

◆ ~Transport()

virtual ndn::Transport::~Transport ( )
virtualdefault

Member Function Documentation

◆ close()

virtual void ndn::Transport::close ( )
pure virtual

Close the connection.

Implemented in ndn::UnixTransport, and ndn::TcpTransport.

◆ connect()

void ndn::Transport::connect ( boost::asio::io_service &  ioService,
ReceiveCallback  receiveCallback 
)
virtual

Asynchronously open the connection.

Parameters
ioServiceio_service to create socket on
receiveCallbackcallback function when a TLV block is received; must not be empty
Exceptions
boost::system::system_errorconnection cannot be established

Reimplemented in ndn::UnixTransport, and ndn::TcpTransport.

Definition at line 32 of file transport.cpp.

◆ getState()

State ndn::Transport::getState ( ) const
inlinenoexcept

Return the current state of the transport.

Definition at line 103 of file transport.hpp.

◆ pause()

virtual void ndn::Transport::pause ( )
pure virtual

Pause the transport, canceling all pending operations.

Postcondition
the receive callback will not be invoked
Note
This operation has no effect if the transport has been paused, or when the connection is being established.

Implemented in ndn::UnixTransport, and ndn::TcpTransport.

◆ resume()

virtual void ndn::Transport::resume ( )
pure virtual

Resume the transport.

Postcondition
the receive callback will be invoked
Note
This operation has no effect if the transport is not paused, or when the connection is being established.

Implemented in ndn::UnixTransport, and ndn::TcpTransport.

◆ send()

virtual void ndn::Transport::send ( const Block block)
pure virtual

Send a TLV block through the transport.

Implemented in ndn::UnixTransport, and ndn::TcpTransport.

◆ setState()

void ndn::Transport::setState ( State  state)
inlineprotectednoexcept

Definition at line 110 of file transport.hpp.

Member Data Documentation

◆ m_ioService

boost::asio::io_service* ndn::Transport::m_ioService = nullptr
protected

Definition at line 116 of file transport.hpp.

◆ m_receiveCallback

ReceiveCallback ndn::Transport::m_receiveCallback
protected

Definition at line 117 of file transport.hpp.