AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | Static Public Member Functions | List of all members
alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader Class Reference

#include <InProcessAttachmentReader.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader:
Inheritance graph
Collaboration diagram for alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader:
Collaboration graph

Public Types

using SDSType = avsCommon::utils::sds::InProcessSDS
 Type aliases for convenience. More...
using SDSTypeIndex = avsCommon::utils::sds::InProcessSDS::Index
using SDSTypeReader = SDSType::Reader
- Public Types inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentReader
enum  ReadStatus {
  ReadStatus::OK, ReadStatus::OK_WOULDBLOCK, ReadStatus::OK_TIMEDOUT, ReadStatus::OK_OVERRUN_RESET,
enum  ClosePoint { ClosePoint::IMMEDIATELY, ClosePoint::AFTER_DRAINING_CURRENT_BUFFER }
 An enum class to indicate when the read() function should stop returning data after a call to close(). More...

Public Member Functions

 ~InProcessAttachmentReader ()=default
std::size_t read (void *buf, std::size_t numBytes, ReadStatus *readStatus, std::chrono::milliseconds timeoutMs=std::chrono::milliseconds(0)) override
void close (ClosePoint closePoint=ClosePoint::AFTER_DRAINING_CURRENT_BUFFER) override
bool seek (uint64_t offset) override
uint64_t getNumUnreadBytes () override
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentReader
virtual ~AttachmentReader ()=default

Static Public Member Functions

static std::unique_ptr< InProcessAttachmentReadercreate (SDSTypeReader::Policy policy, std::shared_ptr< SDSType > sds, SDSTypeIndex offset=0, SDSTypeReader::Reference reference=SDSTypeReader::Reference::ABSOLUTE, bool resetOnOverrun=false)

Detailed Description

A class that provides functionality to read data from an Attachment following an in-process memory management model.

This class is not thread-safe beyond the thread-safety provided by the underlying SharedDataStream object.

Member Typedef Documentation

◆ SDSType

Type aliases for convenience.

◆ SDSTypeIndex

◆ SDSTypeReader

Constructor & Destructor Documentation

◆ ~InProcessAttachmentReader()

alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::~InProcessAttachmentReader ( )


Member Function Documentation

◆ close()

void alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::close ( ClosePoint  closePoint = ClosePoint::AFTER_DRAINING_CURRENT_BUFFER)

The close function. An implementation will take care of any resource management when a reader no longer needs to use an attachment.

closePointThe point at which the reader should stop reading from the attachment.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ create()

static std::unique_ptr<InProcessAttachmentReader> alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::create ( SDSTypeReader::Policy  policy,
std::shared_ptr< SDSType sds,
SDSTypeIndex  offset = 0,
SDSTypeReader::Reference  reference = SDSTypeReader::Reference::ABSOLUTE,
bool  resetOnOverrun = false 

Create an InProcessAttachmentReader.

policyThe policy this reader should adhere to.
sdsThe underlying SharedDataStream which this object will use.
indexIf being constructed from an existing SharedDataStream, the index indicates where to read from.
referenceThe position in the stream offset is applied to. This parameter defaults to 0, indicating no offset from the specified reference.
resetOnOverrunIf overrun is detected on read, whether to close the attachment (default behavior) or to reset the read position to where current write position is (and skip all the bytes in between).
Returns a new InProcessAttachmentReader, or nullptr if the operation failed. This parameter defaults to ABSOLUTE, indicating offset is relative to the very beginning of the Attachment.

◆ getNumUnreadBytes()

uint64_t alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::getNumUnreadBytes ( )

Utility function to return the number of bytes in an attachment.

Number of unread bytes in the attachment by this attachment reader.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ read()

std::size_t alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::read ( void *  buf,
std::size_t  numBytes,
ReadStatus readStatus,
std::chrono::milliseconds  timeoutMs = std::chrono::milliseconds(0) 

The read function.

bufThe buffer where data should be copied to.
numBytesThe size of the buffer in bytes.
[out]readStatusThe out-parameter where the resulting state of the read will be expressed.
timeoutMsThe timeout for this read call in milliseconds. This value is only used for the BLOCKING reader policy. If this parameter is zero, there is no timeout and blocking reads will wait forever.
The number of bytes read as a result of this call.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ seek()

bool alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader::seek ( uint64_t  offset)

The seek function.

offsetThe offset to seek to within the Attachment.
true if the specified position points at unexpired data, or false otherwise. Note that it is valid to seek into a future index that has not been written to yet.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

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

AlexaClientSDK 3.0.0 - Copyright 2016-2022, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0