esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ndnph::SegmentConsumerBase Class Reference

#include <segment-consumer.hpp>

Inherits ndnph::PacketHandler.

Inherited by ndnph::BasicSegmentConsumer< SegmentConvention, regionCap >.

Classes

struct  Options
 
class  SaveDest
 Destination and context of saving accumulated payload. More...
 

Public Types

using SegmentCallback = void(*)(void *ctx, uint64_t segment, Data data)
 Callback upon segment arrival. More...
 
- Public Types inherited from ndnph::PacketHandler
using PacketInfo = Face::PacketInfo
 

Public Member Functions

 SegmentConsumerBase (Face &face, Options opts)
 Constructor. More...
 
 SegmentConsumerBase (Face &face)
 
void setSegmentCallback (SegmentCallback cb, void *ctx)
 Assign SegmentCallback. More...
 
void saveTo (SaveDest &dest)
 Save content to destination. More...
 
void start (Name prefix)
 Start fetching content under given prefix. More...
 
void stop ()
 Stop fetching. More...
 
bool isRunning () const
 Determine whether fetching is in progress (not completed or failed). More...
 
- Public Member Functions inherited from ndnph::PacketHandler
 PacketHandler ()=default
 Construct without adding to Face. More...
 
 PacketHandler (Face &face, int8_t prio=0)
 Construct and add handler to Face. More...
 

Protected Member Functions

void invokeCallback (Data data)
 
- Protected Member Functions inherited from ndnph::PacketHandler
virtual ~PacketHandler ()
 Remove handler from Face. More...
 
FacegetFace () const
 
const PacketInfogetCurrentPacketInfo () const
 Retrieve information about current processing packet. More...
 
template<typename Packet >
bool send (Region &region, const Packet &packet, PacketInfo pi={})
 Synchronously transmit a packet. More...
 
template<typename Packet , typename... PacketInfoModifier>
bool send (Region &region, const Packet &packet, const PacketInfoModifier &... pim)
 Synchronously transmit a packet. More...
 
template<typename Packet , typename... Arg, typename = typename std::enable_if< !std::is_base_of<Region, typename std::decay<Packet>::type>::value>::type>
bool send (const Packet &packet, Arg &&... arg)
 Synchronously transmit a packet. More...
 
template<typename... Arg>
bool reply (Arg &&... arg)
 Synchronously transmit a packet in reply to current processing packet. More...
 

Protected Attributes

Options m_opts
 
SegmentCallback m_cb = nullptr
 
void * m_cbCtx = nullptr
 
Name m_prefix
 
uint64_t m_segment = 0
 
OutgoingPendingInterest m_pending
 
int m_retxRemain = 0
 
bool m_running = false
 

Member Typedef Documentation

◆ SegmentCallback

using ndnph::SegmentConsumerBase::SegmentCallback = void (*)(void* ctx, uint64_t segment, Data data)

Callback upon segment arrival.

Parameters
ctxuser specified context.
segmentsegment number; they will appear sequentially.
datathe Data packet.

If a segment retrieval has failed, the callback will be invoked with invalid Data where !data evaluates to true, and no more callbacks will be invoked. If fetching has completed successfully, the callback will be invoked with the last Data where data.getIsFinalBlock() evaluates to true, and no more callbacks will be invoked.

Constructor & Destructor Documentation

◆ SegmentConsumerBase() [1/2]

ndnph::SegmentConsumerBase::SegmentConsumerBase ( Face face,
Options  opts 
)
inlineexplicit

Constructor.

Parameters
faceface for communication.
optsoptions.

◆ SegmentConsumerBase() [2/2]

ndnph::SegmentConsumerBase::SegmentConsumerBase ( Face face)
inlineexplicit

Member Function Documentation

◆ invokeCallback()

void ndnph::SegmentConsumerBase::invokeCallback ( Data  data)
inlineprotected

◆ isRunning()

bool ndnph::SegmentConsumerBase::isRunning ( ) const
inline

Determine whether fetching is in progress (not completed or failed).

◆ saveTo()

void ndnph::SegmentConsumerBase::saveTo ( SaveDest dest)
inline

Save content to destination.

Parameters
destsaving destination, must be kept alive while SegmentConsumer is running.

This should be invoked before start() . This cannot be used together with SegmentCallback.

◆ setSegmentCallback()

void ndnph::SegmentConsumerBase::setSegmentCallback ( SegmentCallback  cb,
void *  ctx 
)
inline

Assign SegmentCallback.

This should be invoked before start() .

◆ start()

void ndnph::SegmentConsumerBase::start ( Name  prefix)
inline

Start fetching content under given prefix.

If another fetching is in progress, it will be aborted. The callback will not be invoked.

◆ stop()

void ndnph::SegmentConsumerBase::stop ( )
inline

Stop fetching.

The callback will not be invoked.

Member Data Documentation

◆ m_cb

SegmentCallback ndnph::SegmentConsumerBase::m_cb = nullptr
protected

◆ m_cbCtx

void* ndnph::SegmentConsumerBase::m_cbCtx = nullptr
protected

◆ m_opts

Options ndnph::SegmentConsumerBase::m_opts
protected

◆ m_pending

OutgoingPendingInterest ndnph::SegmentConsumerBase::m_pending
protected

◆ m_prefix

Name ndnph::SegmentConsumerBase::m_prefix
protected

◆ m_retxRemain

int ndnph::SegmentConsumerBase::m_retxRemain = 0
protected

◆ m_running

bool ndnph::SegmentConsumerBase::m_running = false
protected

◆ m_segment

uint64_t ndnph::SegmentConsumerBase::m_segment = 0
protected

The documentation for this class was generated from the following file: