AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Attachment.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_ATTACHMENT_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_ATTACHMENT_H_
18 
19 #include <atomic>
20 #include <mutex>
21 #include <string>
22 
28 
29 namespace alexaClientSDK {
30 namespace avsCommon {
31 namespace avs {
32 namespace attachment {
33 
37 class Attachment {
38 public:
44  Attachment(const std::string& attachmentId);
45 
49  virtual ~Attachment() = default;
50 
57  virtual std::unique_ptr<AttachmentWriter> createWriter(
59 
66  virtual std::unique_ptr<AttachmentReader> createReader(utils::sds::ReaderPolicy policy) = 0;
67 
73  std::string getId() const;
74 
80  bool hasCreatedReader();
81 
87  bool hasCreatedWriter();
88 
89 protected:
93  std::mutex m_mutex;
95  std::atomic<bool> m_hasCreatedWriter;
97  std::atomic<size_t> m_numReaders;
98 };
99 
100 } // namespace attachment
101 } // namespace avs
102 } // namespace avsCommon
103 } // namespace alexaClientSDK
104 
105 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_AVS_INCLUDE_AVSCOMMON_AVS_ATTACHMENT_ATTACHMENT_H_
WriterPolicy
Specifies the policy to use for writing to the stream.
Definition: WriterPolicy.h:25
std::atomic< bool > m_hasCreatedWriter
An atomic tracking variable to tell whether this object has created a writer.
Definition: Attachment.h:95
::std::string string
Definition: gtest-port.h:1097
virtual std::unique_ptr< AttachmentReader > createReader(utils::sds::ReaderPolicy policy)=0
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
ReaderPolicy
Specifies the policy to use for reading from the stream.
Definition: ReaderPolicy.h:25
const std::string m_id
The id for this attachment object.
Definition: Attachment.h:91
std::mutex m_mutex
mutex to protext access to the createReader and createWriter API.
Definition: Attachment.h:93
std::atomic< size_t > m_numReaders
An atomic tracking variable to tell how many readers have been created.
Definition: Attachment.h:97
virtual std::unique_ptr< AttachmentWriter > createWriter(utils::sds::WriterPolicy policy=utils::sds::WriterPolicy::ALL_OR_NOTHING)=0

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