61 lines
2.2 KiB
C++
61 lines
2.2 KiB
C++
/*
|
|
* TestableAttachmentWriter.h
|
|
*
|
|
* Copyright 2017 Amazon.com, Inc. or its affiliates.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
#ifndef ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_TESTABLE_ATTACHMENT_WRITER_H_
|
|
#define ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_TESTABLE_ATTACHMENT_WRITER_H_
|
|
|
|
#include <AVSCommon/AVS/Attachment/InProcessAttachmentWriter.h>
|
|
|
|
namespace alexaClientSDK {
|
|
namespace acl {
|
|
namespace test {
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
class TestableAttachmentWriter : public avsCommon::avs::attachment::InProcessAttachmentWriter {
|
|
public:
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param dummySDS An 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.
|
|
* @param writer The AttachmentWriter object to be wrapped by this class.
|
|
*/
|
|
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) override;
|
|
|
|
void close() override;
|
|
|
|
private:
|
|
/// The AttachmentWriter object to be wrapped by this class.
|
|
std::unique_ptr<avsCommon::avs::attachment::AttachmentWriter> m_writer;
|
|
|
|
bool m_hasWriteBeenInvoked;
|
|
};
|
|
|
|
} // namespace test
|
|
} // namespace acl
|
|
} // namespace alexaClientSDK
|
|
|
|
#endif // ALEXA_CLIENT_SDK_ACL_TEST_TRANSPORT_TESTABLE_ATTACHMENT_WRITER_H_
|