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

#include <TestableAttachmentWriter.h>

Inheritance diagram for alexaClientSDK::avsCommon::utils::TestableAttachmentWriter:
Inheritance graph
Collaboration diagram for alexaClientSDK::avsCommon::utils::TestableAttachmentWriter:
Collaboration graph

Public Member Functions

 TestableAttachmentWriter (std::shared_ptr< avsCommon::utils::sds::InProcessSDS > dummySDS, std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter > writer)
std::size_t write (const void *buf, std::size_t numBytes, WriteStatus *writeStatus, std::chrono::milliseconds timeout) override
void close () override
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter
 ~InProcessAttachmentWriter ()
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentWriter
virtual ~AttachmentWriter ()=default

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter
using SDSType = avsCommon::utils::sds::InProcessSDS
 Type aliases for convenience. More...
using SDSTypeWriter = SDSType::Writer
- Public Types inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentWriter
enum  WriteStatus {
  WriteStatus::OK, WriteStatus::CLOSED, WriteStatus::OK_BUFFER_FULL, WriteStatus::ERROR_BYTES_LESS_THAN_WORD_SIZE,
  WriteStatus::ERROR_INTERNAL, WriteStatus::TIMEDOUT
- Static Public Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter
static std::unique_ptr< InProcessAttachmentWritercreate (std::shared_ptr< SDSType > sds, SDSTypeWriter::Policy policy=SDSTypeWriter::Policy::ALL_OR_NOTHING)
- Protected Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter
 InProcessAttachmentWriter (std::shared_ptr< SDSType > sds, SDSTypeWriter::Policy policy=SDSTypeWriter::Policy::ALL_OR_NOTHING)
- Protected Attributes inherited from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter
std::shared_ptr< SDSTypeWriterm_writer
 The underlying SharedDataStream reader. More...

Detailed Description

A version of the Decorator Pattern, this class allows us to simulate pausing writes without requiring an actual (slow) AttachmentReader anywhere in the test code. Besides this small change in functionality, all real work is done by the encapsulated InProcessAttachmentWriter object.

Constructor & Destructor Documentation

◆ TestableAttachmentWriter()

alexaClientSDK::avsCommon::utils::TestableAttachmentWriter::TestableAttachmentWriter ( std::shared_ptr< avsCommon::utils::sds::InProcessSDS dummySDS,
std::unique_ptr< avsCommon::avs::attachment::AttachmentWriter writer 


dummySDSAn SDS used to instantiate this class, although it will never be used. This is to avert any risk of this wrapper object being created with a nullptr.
writerThe AttachmentWriter object to be wrapped by this class.

Member Function Documentation

◆ close()

void alexaClientSDK::avsCommon::utils::TestableAttachmentWriter::close ( )

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

Reimplemented from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter.

◆ write()

std::size_t alexaClientSDK::avsCommon::utils::TestableAttachmentWriter::write ( const void *  buf,
std::size_t  numBytes,
WriteStatus writeStatus,
std::chrono::milliseconds  timeout 

The write function.

bufThe buffer where data should be copied from.
numBytesThe size of the buffer in bytes.
[out]writeStatusThe out-parameter where the resulting state of the write will be expressed.
timeoutThe maximum time to wait (if policy is BLOCKING) for space to write into. If this parameter is zero, there is no timeout and blocking writes will wait forever. If policy is not BLOCKING, this parameter is ignored.
The number of bytes written as a result of this call.

Reimplemented from alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentWriter.

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

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