paul@93 | 1 | /* |
paul@93 | 2 | * Generic accessor functionality. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@6 | 22 | #pragma once |
paul@6 | 23 | |
paul@6 | 24 | #include "flexpage.h" |
paul@6 | 25 | |
paul@93 | 26 | |
paul@93 | 27 | |
paul@6 | 28 | /* A file accessor, providing flexpages corresponding to file regions. */ |
paul@6 | 29 | |
paul@6 | 30 | class Accessor |
paul@6 | 31 | { |
paul@6 | 32 | protected: |
paul@6 | 33 | offset_t _size; |
paul@6 | 34 | |
paul@56 | 35 | /* Data transfer helper methods. */ |
paul@56 | 36 | |
paul@56 | 37 | virtual void fill_populated(Flexpage *flexpage); |
paul@56 | 38 | |
paul@56 | 39 | virtual void flush_populated(Flexpage *flexpage); |
paul@56 | 40 | |
paul@6 | 41 | public: |
paul@6 | 42 | fileid_t fileid; |
paul@6 | 43 | |
paul@6 | 44 | explicit Accessor(fileid_t fileid, offset_t size=0); |
paul@6 | 45 | |
paul@79 | 46 | virtual ~Accessor() |
paul@79 | 47 | { |
paul@79 | 48 | } |
paul@79 | 49 | |
paul@6 | 50 | virtual offset_t get_size(); |
paul@6 | 51 | |
paul@53 | 52 | virtual void set_size(offset_t size); |
paul@53 | 53 | |
paul@6 | 54 | virtual void close(); |
paul@6 | 55 | |
paul@6 | 56 | virtual void open(); |
paul@6 | 57 | |
paul@6 | 58 | /* Data transfer methods. */ |
paul@6 | 59 | |
paul@56 | 60 | virtual void fill(Flexpage *flexpage); |
paul@6 | 61 | |
paul@56 | 62 | virtual void flush(Flexpage *flexpage); |
paul@6 | 63 | }; |
paul@6 | 64 | |
paul@6 | 65 | // vim: tabstop=4 expandtab shiftwidth=4 |