1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
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 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | #ifndef GLOW_BACKENDS_BLOCKSTREAMBASE_H |
17 | #define GLOW_BACKENDS_BLOCKSTREAMBASE_H |
18 | |
19 | #include <vector> |
20 | namespace glow { |
21 | |
22 | // This is the base class of all BlockStream implemented in backends. |
23 | // BlockStream are used for read & write compiled backend function. |
24 | class BlockStreamBase { |
25 | public: |
26 | BlockStreamBase() {} |
27 | virtual ~BlockStreamBase() {} |
28 | |
29 | // Read /p size bytes from stream to /p buffer. |
30 | virtual size_t read(char *buffer, size_t size) = 0; |
31 | |
32 | // Write /p size bytes from /p buffer to stream. |
33 | virtual size_t write(const char *buffer, size_t size) = 0; |
34 | |
35 | // Get size of wriiten data. |
36 | virtual size_t getSize() = 0; |
37 | |
38 | // Release memory of block stream |
39 | virtual void releaseMemory() = 0; |
40 | }; |
41 | |
42 | } // end namespace glow |
43 | |
44 | #endif // GLOW_BACKENDS_BLOCKSTREAMBASE_H |
45 | |