1 // Copyright 2022 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 #pragma once 15 16 #include "pw_stream/stream.h" 17 18 namespace pw::software_update { 19 20 // A SeekableReader that needs Open/Closed state management. This abstraction 21 // decouples pw_software_update from pw_blob_store. 22 class OpenableReader { 23 public: 24 virtual Status Open() = 0; 25 virtual Status Close() = 0; 26 virtual bool IsOpen() = 0; 27 28 // Returns the underlying SeekableReader. Must only be called after a 29 // successful call to Open, before the matching call to Close. 30 virtual stream::SeekableReader& reader() = 0; 31 32 virtual ~OpenableReader() = default; 33 }; 34 35 } // namespace pw::software_update 36