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

#include <DefaultAttachmentReader.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >:
Inheritance graph
[legend]
Collaboration diagram for alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >:
Collaboration graph
[legend]

Public Member Functions

 ~DefaultAttachmentReader ()
 
AttachmentReader methods.
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< AttachmentReadercreate (typename SDSType::Reader::Policy policy, std::shared_ptr< SDSType > sds, typename SDSType::Index offset=0, typename SDSType::Reader::Reference reference=SDSType::Reader::Reference::ABSOLUTE, bool resetOnOverrun=false)
 

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentReader
enum  ReadStatus {
  ReadStatus::OK, ReadStatus::OK_WOULDBLOCK, ReadStatus::OK_TIMEDOUT, ReadStatus::OK_OVERRUN_RESET,
  ReadStatus::CLOSED, ReadStatus::ERROR_OVERRUN, ReadStatus::ERROR_BYTES_LESS_THAN_WORD_SIZE, ReadStatus::ERROR_INTERNAL
}
 
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...
 

Detailed Description

template<typename SDSType>
class alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >

A class that provides functionality to read data from an Attachment.

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

Constructor & Destructor Documentation

◆ ~DefaultAttachmentReader()

Destructor.

Member Function Documentation

◆ close()

template<typename SDSType >
void alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >::close ( ClosePoint  closePoint = ClosePoint::AFTER_DRAINING_CURRENT_BUFFER)
overridevirtual

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

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

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

◆ create()

template<typename SDSType >
std::unique_ptr< AttachmentReader > alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >::create ( typename SDSType::Reader::Policy  policy,
std::shared_ptr< SDSType >  sds,
typename SDSType::Index  offset = 0,
typename SDSType::Reader::Reference  reference = SDSType::Reader::Reference::ABSOLUTE,
bool  resetOnOverrun = false 
)
static

Create an AttachmentReader.

Parameters
policyThe policy this reader should adhere to.
sdsThe underlying SharedDataStream which this object will use.
offsetIf being constructed from an existing SharedDataStream, the index indicates where to read from. This parameter defaults to 0, indicating no offset from the specified reference.
referenceThe position in the stream offset is applied to. This parameter defaults to ABSOLUTE, indicating offset is relative to the very beginning of the Attachment.
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
Returns a new AttachmentReader, or nullptr if the operation failed.

◆ getNumUnreadBytes()

template<typename SDSType >
uint64_t alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >::getNumUnreadBytes ( )
overridevirtual

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

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

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

◆ read()

template<typename SDSType >
std::size_t alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >::read ( void *  buf,
std::size_t  numBytes,
ReadStatus readStatus,
std::chrono::milliseconds  timeoutMs = std::chrono::milliseconds(0) 
)
overridevirtual

The read function.

Parameters
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.
Returns
The number of bytes read as a result of this call.

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

◆ seek()

template<typename SDSType >
bool alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >::seek ( uint64_t  offset)
overridevirtual

The seek function.

Parameters
offsetThe offset to seek to within the Attachment.
Returns
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 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0