BlockEncoder.h
Go to the documentation of this file.
1 /****
2  * ArchiveStream.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the IFS Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
23 
24 namespace IFS
25 {
26 namespace FWFS
27 {
39 class IBlockEncoder
40 {
41 public:
42  virtual ~IBlockEncoder()
43  {
44  }
45 
53  virtual IDataSourceStream* getNextStream() = 0;
54 };
55 
56 class BasicEncoder : public IBlockEncoder
57 {
58 public:
60  {
61  this->stream.reset(stream);
62  }
63 
65  {
66  if(done) {
67  stream.reset();
68  return nullptr;
69  }
70 
71  done = true;
72  return stream.get();
73  }
74 
75 protected:
76  std::unique_ptr<IDataSourceStream> stream;
77  bool done{false};
78 };
79 
80 } // namespace FWFS
81 } // namespace IFS
Base class for read-only stream.
Definition: DataSourceStream.h:45
IDataSourceStream * getNextStream() override
Definition: BlockEncoder.h:98
virtual ~IBlockEncoder()
Definition: BlockEncoder.h:93
bool done
Definition: BlockEncoder.h:111
Definition: DirectoryTemplate.h:36
BasicEncoder(IDataSourceStream *stream)
Definition: BlockEncoder.h:93
std::unique_ptr< IDataSourceStream > stream
Definition: BlockEncoder.h:110
virtual IDataSourceStream * getNextStream()=0