AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
InProcessAttachmentReader.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_INPROCESSATTACHMENTREADER_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_INPROCESSATTACHMENTREADER_H_
18 
21 
22 #include "AttachmentReader.h"
23 
24 namespace alexaClientSDK {
25 namespace avsCommon {
26 namespace avs {
27 namespace attachment {
28 
36 public:
40  using SDSTypeReader = SDSType::Reader;
41 
55  static std::unique_ptr<InProcessAttachmentReader> create(
56  SDSTypeReader::Policy policy,
57  std::shared_ptr<SDSType> sds,
58  SDSTypeIndex offset = 0,
59  SDSTypeReader::Reference reference = SDSTypeReader::Reference::ABSOLUTE,
60  bool resetOnOverrun = false);
61 
65  ~InProcessAttachmentReader() = default;
66 
67  std::size_t read(
68  void* buf,
69  std::size_t numBytes,
70  ReadStatus* readStatus,
71  std::chrono::milliseconds timeoutMs = std::chrono::milliseconds(0)) override;
72 
74 
75  bool seek(uint64_t offset) override;
76 
77  uint64_t getNumUnreadBytes() override;
78 
79 private:
85  explicit InProcessAttachmentReader(std::unique_ptr<AttachmentReader> delegate);
86 
87  // Delegate reader
88  std::unique_ptr<AttachmentReader> m_delegate;
89 };
90 
91 } // namespace attachment
92 } // namespace avs
93 } // namespace avsCommon
94 } // namespace alexaClientSDK
95 
96 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_INPROCESSATTACHMENTREADER_H_
Reference
Specifies a reference to measure seek()/tell()/close() offsets against.
Definition: Reader.h:51
avsCommon::utils::sds::InProcessSDS SDSType
Type aliases for convenience.
Definition: InProcessAttachmentReader.h:38
SDSType::Reader SDSTypeReader
Definition: InProcessAttachmentReader.h:40
static std::unique_ptr< InProcessAttachmentReader > create(SDSTypeReader::Policy policy, std::shared_ptr< SDSType > sds, SDSTypeIndex offset=0, SDSTypeReader::Reference reference=SDSTypeReader::Reference::ABSOLUTE, bool resetOnOverrun=false)
Definition: InProcessAttachmentReader.cpp:24
Stop returning data when all of the data in the buffer at the time close() was called has been read...
void close(ClosePoint closePoint=ClosePoint::AFTER_DRAINING_CURRENT_BUFFER) override
Definition: InProcessAttachmentReader.cpp:50
avsCommon::utils::sds::InProcessSDS::Index SDSTypeIndex
Definition: InProcessAttachmentReader.h:39
bool seek(uint64_t offset) override
Definition: InProcessAttachmentReader.cpp:54
SharedDataStream< InProcessSDSTraits > InProcessSDS
Type alias for a SharedDataStream which works between threads in a single process.
Definition: InProcessSDS.h:54
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
uint64_t getNumUnreadBytes() override
Definition: InProcessAttachmentReader.cpp:58
std::size_t read(void *buf, std::size_t numBytes, ReadStatus *readStatus, std::chrono::milliseconds timeoutMs=std::chrono::milliseconds(0)) override
Definition: InProcessAttachmentReader.cpp:42
ClosePoint
An enum class to indicate when the read() function should stop returning data after a call to close()...
Definition: AttachmentReader.h:59

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0